Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © thebearfib
- //@version=5
- indicator("sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs", overlay = true)
- sma30 = ta.sma(close,30)
- plot(sma30,title = "SMA 30",
- color=color.rgb(255, 0, 0),
- linewidth=2,
- display=display.all)
- //
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Inputs ———————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
- _Xxq = input(false,'═══════ sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs ════════════════════')
- showxA = input.bool(defval = true, title = "Show sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs",
- group='Toggle Stats', inline='1')
- position3b = input.string("Bottom Right","- Table Position",
- options = ["Top Right", "Top Center", "Top Left", "Middle Right", "Middle Center", "Middle Left", "Bottom Right", "Bottom Center", "Bottom Left"],
- group='Toggle Stats', inline='1')
- _skSP500 = input.symbol("SP:SPX", "Symbol")
- _sp500 = request.security(_skSP500, 'D', close)
- autodraw_lookback_period =input.int(defval = 504,title = "LookBack AutoDraw resistance & support",minval = 63,maxval = 1260,step = 21)
- gap_between_2_lines =input.int(defval = 15,title = "Days gap between 2 same stage lines",minval = 5,maxval =63,step = 1)
- ///
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Start Array / Moving Avgs ————————————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
- var stages = array.new_int()
- var stages2 = array.new_float()
- ema126=ta.ema(close,126),vwmah126=ta.vwma(high,126),vwma126=ta.vwma(ohlc4,126)
- //
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Market Conditions Table Stats ——————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
- rs=(close/_sp500)
- rs21=ta.ema(rs,21)
- rs42=ta.ema(rs,42)
- rs63=ta.ema(rs,63)
- rs72=ta.ema(rs,72)
- rs84=ta.ema(rs,84)
- rs126=ta.ema(rs,126)
- rs147=ta.ema(rs,147)
- rs168=ta.ema(rs,168)
- //
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Set High/Low —————————————————————————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
- hh7=ta.highest(high,7)
- hh15=ta.highest(high,15)
- //
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Variables ————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
- var stage1_line_bar_index = 0
- var stage1_proper_line_bar_index = 0
- var stage3_line_bar_index = 0
- var stage2_line_bar_index = 0
- var stage2_proper_line_bar_index = 0
- //
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Stage Conditions ————————————————————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
- if(rs>=rs84 and rs < rs126)
- //stage 1
- array.push(stages,1)
- array.push(stages2,1)
- else if(rs < rs42 and rs >= rs72 and rs >= rs84 and rs >= rs126 and (rs42 > rs63 or rs < rs63) and rs63 > rs126 and close >= ema126)
- //stage 3
- array.push(stages,3)
- array.push(stages2,3)
- else if(rs >= rs168 and rs >= rs147 and rs>=rs126 and close>=ema126 and (rs21 >= rs42 or rs42 >= rs63))
- //stage 2
- array.push(stages,2)
- array.push(stages2,2.1)
- else if(rs>=rs126 and close>=ema126 and (rs21 >= rs42 or rs42 >= rs63))
- //stage 2
- array.push(stages,2)
- array.push(stages2,2)
- else if((rs<rs63 and rs < rs126) or (rs63 < rs126 and rs < rs126))
- //stage 4
- array.push(stages,4)
- array.push(stages2,4)
- else if((open >= ema126 or close >= ema126) and rs >= rs72 and rs < rs126)
- //stage 1
- array.push(stages,1)
- array.push(stages2,1)
- else if(rs >= rs84 and rs >= rs72 and (open >= ema126 or close >= ema126))
- //stage 1
- array.push(stages,1)
- array.push(stages2,1)
- else
- array.push(stages,0)
- array.push(stages2,0)
- //
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Table Layouts ————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
- tableposGo2 = switch position3b
- "Top Right" => position.top_right
- "Top Center" => position.top_center
- "Top Left" => position.top_left
- "Middle Right" => position.middle_right
- "Middle Center" => position.middle_center
- "Middle Left" => position.middle_left
- "Bottom Right" => position.bottom_right
- "Bottom Center" => position.bottom_center
- "Bottom Left" => position.bottom_left
- if barstate.islast or barstate.islastconfirmedhistory
- var table tab = table.new(tableposGo2, 99, 99,
- bgcolor = color.rgb(255, 255, 255, 100),
- frame_color=color.rgb(255, 255, 255, 100),
- frame_width = 1,
- border_color =color.rgb(255, 255, 255, 100),
- border_width = 1)
- if showxA
- table.cell(tab, 1, 1, "sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs:",text_halign = text.align_left, text_color = color.white)
- table.cell(tab, 2, 1, str.tostring(stages.last()), text_color = color.white, text_halign = text.align_left)
- //
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- // ————————————————————————————————— Is it ever really the End? ——————————————————————————————————————————————————————————
- // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
- //
Advertisement
Comments
-
- i founded all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement