Advertisement
xmd79

sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs

Sep 27th, 2023
339
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.18 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © thebearfib
  3.  
  4. //@version=5
  5. indicator("sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs", overlay = true)
  6.  
  7. sma30 = ta.sma(close,30)
  8.  
  9. plot(sma30,title = "SMA 30",
  10. color=color.rgb(255, 0, 0),
  11. linewidth=2,
  12. display=display.all)
  13. //
  14. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  15. // ————————————————————————————————— Inputs ———————————————————————————————————————————————————————————————————————————
  16. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  17. //
  18. _Xxq = input(false,'═══════ sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs ════════════════════')
  19.  
  20. showxA = input.bool(defval = true, title = "Show sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs",
  21. group='Toggle Stats', inline='1')
  22.  
  23.  
  24. position3b = input.string("Bottom Right","- Table Position",
  25. options = ["Top Right", "Top Center", "Top Left", "Middle Right", "Middle Center", "Middle Left", "Bottom Right", "Bottom Center", "Bottom Left"],
  26. group='Toggle Stats', inline='1')
  27.  
  28. _skSP500 = input.symbol("SP:SPX", "Symbol")
  29. _sp500 = request.security(_skSP500, 'D', close)
  30. autodraw_lookback_period =input.int(defval = 504,title = "LookBack AutoDraw resistance & support",minval = 63,maxval = 1260,step = 21)
  31. gap_between_2_lines =input.int(defval = 15,title = "Days gap between 2 same stage lines",minval = 5,maxval =63,step = 1)
  32.  
  33. ///
  34. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  35. // ————————————————————————————————— Start Array / Moving Avgs ————————————————————————————————————————————————————————
  36. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  37. //
  38. var stages = array.new_int()
  39. var stages2 = array.new_float()
  40.  
  41. ema126=ta.ema(close,126),vwmah126=ta.vwma(high,126),vwma126=ta.vwma(ohlc4,126)
  42.  
  43. //
  44. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  45. // ————————————————————————————————— Market Conditions Table Stats ——————————————————————————————————————————————————
  46. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  47. //
  48. rs=(close/_sp500)
  49. rs21=ta.ema(rs,21)
  50. rs42=ta.ema(rs,42)
  51. rs63=ta.ema(rs,63)
  52. rs72=ta.ema(rs,72)
  53. rs84=ta.ema(rs,84)
  54. rs126=ta.ema(rs,126)
  55. rs147=ta.ema(rs,147)
  56. rs168=ta.ema(rs,168)
  57. //
  58. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  59. // ————————————————————————————————— Set High/Low —————————————————————————————————————————————————————————————————————
  60. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  61. //
  62. hh7=ta.highest(high,7)
  63. hh15=ta.highest(high,15)
  64. //
  65. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  66. // ————————————————————————————————— Variables ————————————————————————————————————————————————————————————————————————
  67. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  68. //
  69. var stage1_line_bar_index = 0
  70. var stage1_proper_line_bar_index = 0
  71. var stage3_line_bar_index = 0
  72. var stage2_line_bar_index = 0
  73. var stage2_proper_line_bar_index = 0
  74. //
  75. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  76. // ————————————————————————————————— Stage Conditions ————————————————————————————————————————————————————————————————
  77. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  78. //
  79. if(rs>=rs84 and rs < rs126)
  80. //stage 1
  81. array.push(stages,1)
  82. array.push(stages2,1)
  83.  
  84. 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)
  85. //stage 3
  86. array.push(stages,3)
  87. array.push(stages2,3)
  88.  
  89. else if(rs >= rs168 and rs >= rs147 and rs>=rs126 and close>=ema126 and (rs21 >= rs42 or rs42 >= rs63))
  90. //stage 2
  91. array.push(stages,2)
  92. array.push(stages2,2.1)
  93.  
  94. else if(rs>=rs126 and close>=ema126 and (rs21 >= rs42 or rs42 >= rs63))
  95. //stage 2
  96. array.push(stages,2)
  97. array.push(stages2,2)
  98.  
  99. else if((rs<rs63 and rs < rs126) or (rs63 < rs126 and rs < rs126))
  100. //stage 4
  101. array.push(stages,4)
  102. array.push(stages2,4)
  103.  
  104. else if((open >= ema126 or close >= ema126) and rs >= rs72 and rs < rs126)
  105. //stage 1
  106. array.push(stages,1)
  107. array.push(stages2,1)
  108.  
  109. else if(rs >= rs84 and rs >= rs72 and (open >= ema126 or close >= ema126))
  110. //stage 1
  111. array.push(stages,1)
  112. array.push(stages2,1)
  113.  
  114. else
  115. array.push(stages,0)
  116. array.push(stages2,0)
  117. //
  118. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  119. // ————————————————————————————————— Table Layouts ————————————————————————————————————————————————————————————————————————
  120. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  121. //
  122. tableposGo2 = switch position3b
  123.  
  124. "Top Right" => position.top_right
  125. "Top Center" => position.top_center
  126. "Top Left" => position.top_left
  127. "Middle Right" => position.middle_right
  128. "Middle Center" => position.middle_center
  129. "Middle Left" => position.middle_left
  130. "Bottom Right" => position.bottom_right
  131. "Bottom Center" => position.bottom_center
  132. "Bottom Left" => position.bottom_left
  133.  
  134. if barstate.islast or barstate.islastconfirmedhistory
  135. var table tab = table.new(tableposGo2, 99, 99,
  136. bgcolor = color.rgb(255, 255, 255, 100),
  137. frame_color=color.rgb(255, 255, 255, 100),
  138. frame_width = 1,
  139. border_color =color.rgb(255, 255, 255, 100),
  140. border_width = 1)
  141.  
  142. if showxA
  143. table.cell(tab, 1, 1, "sᴛᴀɢᴇ ᴀɴᴀʏʟsɪs:",text_halign = text.align_left, text_color = color.white)
  144. table.cell(tab, 2, 1, str.tostring(stages.last()), text_color = color.white, text_halign = text.align_left)
  145. //
  146. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  147. // ————————————————————————————————— Is it ever really the End? ——————————————————————————————————————————————————————————
  148. // ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
  149. //
Advertisement
Comments
  • hemal9022
    1 year
    # text 0.12 KB | 0 0
    1. 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