xmd79

Thunderbolt 3.0

Dec 25th, 2022
640
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 71.76 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. // © Bheemanadhuni_stocks Modified and Version Upgarded by Option Forward
  3. //@version=5
  4.  
  5. indicator(title='Thunderbolt 3.0', overlay=true)
  6.  
  7. showBB = input(title='Show BB', defval=false, group = 'Bollinger Band')
  8. showVWAP = input(title='Show VWAP', defval=false, group = 'Vwap')
  9. showEMA9 = input(title='showEMA9', defval=false, group = 'EMA 9')
  10. showEMA20 = input(title='showEMA20 ', defval=false, group = 'EMA 20')
  11. showEMA50 = input(title='showEMA50 ', defval=false, group = 'EMA 50')
  12. showEMA100 = input(title='showEMA100', defval=false, group = 'EMA 100')
  13. showEMA200 = input(title='showEMA200', defval=false, group = 'EMA 200')
  14. showSMA9 = input(title='Show SMA-9', defval=false, group = 'SMA 9')
  15. showSMA20 = input(title='Show SMA -20', defval=false, group = 'SMA 20')
  16. showSMA50 = input(title='Show SMA-50', defval=false, group = 'SMA 50')
  17. showSMA100 = input(title='Show SMA-100', defval=false, group = 'SMA 100')
  18. showwMA9 = input(title='Show WMA-9', defval=false, group = 'WMA 9')
  19. showwMA20 = input(title='Show WMA-20', defval=false, group = 'WMA 20')
  20. showwMA50 = input(title='Show WMA-50', defval=false, group = 'WMA 50')
  21. showwMA100 = input(title='Show WMA-100', defval=false, group = 'WMA 100')
  22. showVWMA9 = input(title='Show VWMA9', defval=false, group = 'VWMA9')
  23. showVWMA20 = input(title='Show VWMA20', defval=false, group = 'VWMA20')
  24. showVWMA50 = input(title='Show VWMA50', defval=false, group = 'VWMA50')
  25.  
  26. showPSAR = input(title='Show PSAR', defval=false, group = 'PSAR')
  27. showPSAR2 = input(title='Show PSAR2', defval=false, group = 'PSAR2')
  28.  
  29.  
  30.  
  31. /////// Alerts ///////
  32. alertMode = input.string (alert.freq_once_per_bar_close , "Alerts Mode" , group = "Alert Frequency", options= [alert.freq_once_per_bar, alert.freq_once_per_bar_close])
  33. ////////////////////////////////////////////////////////////
  34. //////////////////
  35. // BB //
  36. //////////////////
  37. length = input.int(20, minval=1, group = 'Bollinger Band')
  38. src = input(close, title='BB_Source', group = 'Bollinger Band')
  39. mult = input.float(2.0, minval=0.001, maxval=50, title='BB_StdDev', group = 'Bollinger Band')
  40. basis = ta.sma(src, length)
  41. dev = mult * ta.stdev(src, length)
  42. upper = basis + dev
  43. lower = basis - dev
  44. plot(showBB ? basis : na, 'Basis', color=color.new(#872323, 0))
  45. p1 = plot(showBB ? upper : na, 'Upper', color=color.new(color.teal, 0))
  46. p2 = plot(showBB ? lower : na, 'Lower', color=color.new(color.teal, 0))
  47. fill(p1, p2, title='Background', color=color.new(#198787, 95))
  48.  
  49. ////////////////////////////////////////////////////EMA/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  50.  
  51. EMA9_Len = input.int(9, minval=1, title='EMA9_Length', group = 'EMA 9')
  52. EMA9_src = input(close, title='EMA9_Source', group = 'EMA 9')
  53. EMA9_out = ta.ema(EMA9_src, EMA9_Len)
  54. plot(showEMA9 ? EMA9_out : na, title='EMA9', color=color.new(color.blue, 0))
  55.  
  56. EMA20_Len = input.int(20, minval=1, title='EMA20_Length', group = 'EMA 20')
  57. EMA20_src = input(close, title='EMA20_Source', group = 'EMA 20')
  58. EMA20_out = ta.ema(EMA20_src, EMA20_Len)
  59. plot(showEMA20 ? EMA20_out : na, title='EMA20', color=color.new(color.yellow, 0))
  60.  
  61. EMA50_Len = input.int(50, minval=1, title='EMA50_Length', group = 'EMA 50')
  62. EMA50_src = input(close, title='EMA50_Source', group = 'EMA 50')
  63. EMA50_out = ta.ema(EMA50_src, EMA50_Len)
  64. plot(showEMA50 ? EMA50_out : na, title='EMA50', color=color.new(color.red, 0))
  65.  
  66.  
  67. EMA100_Len = input.int(100, minval=1, title='EMA100_Length', group = 'EMA 100')
  68. EMA100_src = input(close, title='EMA100_Source', group = 'EMA 100')
  69. EMA100_out = ta.ema(EMA100_src, EMA100_Len)
  70. plot(showEMA100 ? EMA100_out : na, title='EMA100', color=color.new(color.purple, 0))
  71.  
  72. EMA200_Len = input.int(200, minval=1, title='EMA200_Length', group = 'EMA 200')
  73. EMA200_src = input(close, title='EMA200_Source', group = 'EMA 200')
  74. EMA200_out = ta.ema(EMA200_src, EMA200_Len)
  75. plot(showEMA200 ? EMA200_out : na, title='EMA200', color=color.new(color.green, 0))
  76.  
  77. //////////////////////////////////////////////////////////////SMA///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  78.  
  79. SMA9_Len = input.int(9, minval=1, title='SMA9_Length', group = 'SMA 9')
  80. SMA9_src = input(close, title="SMA9_Source", group = 'SMA 9')
  81. //SMA9_offset = input(title="SMA9_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  82. SMA9_out = ta.sma(close, SMA9_Len)
  83. plot(showSMA9 ? SMA9_out : na, title='SMA9', color=color.new(color.green, 0))
  84.  
  85. SMA20_Len = input.int(20, minval=1, title='SMA20_Length', group = 'SMA 20')
  86. SMA20_src = input(close, title="SMA20_Source", group = 'SMA 20')
  87. //SMA20_offset = input(title="SMA20_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  88. SMA20_out = ta.sma(close, SMA20_Len)
  89. plot(showSMA20 ? SMA20_out : na, title='SMA20', color=color.new(color.red, 0))
  90.  
  91. SMA50_Len = input.int(50, minval=1, title='SMA50_Length', group = 'SMA 50')
  92. SMA50_src = input(close, title="SMA50_Source", group = 'SMA 50')
  93. //SMA50_offset = input(title="SMA50_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  94. SMA50_out = ta.sma(close, SMA50_Len)
  95. plot(showSMA50 ? SMA50_out : na, title='SMA50', color=color.new(color.olive, 0))
  96.  
  97. SMA100_Len = input.int(100, minval=1, title='SMA100_Length', group = 'SMA 100')
  98. SMA100_src = input(close, title="SMA100_Source", group = 'SMA 100')
  99. //SMA100_offset = input(title="SMA100_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  100. SMA100_out = ta.sma(close, SMA100_Len)
  101. plot(showSMA100 ? SMA100_out : na, title='SMA100', color=color.new(color.maroon, 0))
  102.  
  103. ////////////////////////////////////////////////////WMA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  104.  
  105. wMA9_Len = input.int(9, minval=1, title='wMA9_Length', group = 'WMA 9')
  106. wMA9_src = input(close, title="wMA9_Source", group = 'WMA 9')
  107. //wMA9_offset = input(title="wMA9_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  108. wMA9_out = ta.wma(close, wMA9_Len)
  109. plot(showwMA9 ? wMA9_out : na, title='wMA9', color=color.new(color.navy, 0))
  110.  
  111. wMA20_Len = input.int(20, minval=1, title='wMA20_Length', group = 'WMA 20')
  112. wMA20_src = input(close, title="wMA20_Source", group = 'WMA 20')
  113. //wMA20_offset = input(title="wMA20_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  114. wMA20_out = ta.wma(close, wMA20_Len)
  115. plot(showwMA20 ? wMA20_out : na, title='wMA20', color=color.new(color.olive, 0))
  116.  
  117. wMA50_Len = input.int(50, minval=1, title='wMA50_Length', group = 'WMA 50')
  118. wMA50_src = input(close, title="wMA50_Source", group = 'WMA 50')
  119. //wMA50_offset = input(title="wMA50_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  120. wMA50_out = ta.wma(close, wMA50_Len)
  121. plot(showwMA50 ? wMA50_out : na, title='wMA50', color=color.new(color.purple, 0))
  122.  
  123. wMA100_Len = input.int(100, minval=1, title='wMA100_Length', group = 'WMA 100')
  124. wMA100_src = input(close, title="wMA100_Source", group = 'WMA 100')
  125. //wMA100_offset = input(title="wMA100_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  126. wMA100_out = ta.wma(close, wMA100_Len)
  127. plot(showwMA100 ? wMA100_out : na, title='wMA100', color=color.new(color.gray, 0))
  128.  
  129. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  130.  
  131. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  132. /////////////////////////////////////////////////// VWAP /////////////////////////////////////////////////////////
  133. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  134. //vwaplength = input(title="VWAP Length", type=input.integer, defval=1)
  135. //cvwap = ema(vwap,vwaplength)
  136. cvwap1 = ta.vwap(hlc3)
  137. plotvwap = plot(showVWAP ? cvwap1 : na, title='VWAP', color=color.new(color.black, 0), linewidth=2)
  138.  
  139. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  140. /////////////////////////////////////////////////// VWMA9 /////////////////////////////////////////////////////////
  141. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  142. VWMAlen9 = input.int(9, "Length", minval=1,group = 'VWMA9')
  143. srcVWMA9 = input(close, title='VWMA9_Source', group = 'VWMA9')
  144. vwma9 = ta.vwma(srcVWMA9, VWMAlen9)
  145. offset = 0
  146. plot(showVWMA9 ? vwma9 : na, title='VWMA9', offset = offset,color=color.new(color.yellow, 0))
  147. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  148. /////////////////////////////////////////////////// VWMA20 /////////////////////////////////////////////////////////
  149. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  150. VWMAlen20 = input.int(20, "Length", minval=1,group = 'VWMA20')
  151. srcVWMA20 = input(close, title='VWMA20_Source', group = 'VWMA20')
  152. vwma20 = ta.vwma(srcVWMA20, VWMAlen20)
  153. //offset = input.int(0, "Offset", minval = -500, maxval = 500)
  154. plot(showVWMA20 ? vwma20 : na, title='VWMA20', offset = offset,color=color.new(color.orange, 0))
  155. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  156. /////////////////////////////////////////////////// VWMA50 /////////////////////////////////////////////////////////
  157. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  158. VWMAlen50 = input.int(50, "Length", minval=1,group = 'VWMA50')
  159. srcVWMA50 = input(close, title='VWMA50_Source', group = 'VWMA50')
  160. vwma50 = ta.vwma(srcVWMA50, VWMAlen50)
  161. //offset = input.int(0, "Offset", minval = -500, maxval = 500)
  162. plot(showVWMA50 ? vwma50 : na, title='VWMA50', offset = offset,color=color.new(color.green, 0))
  163.  
  164. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  165. ///////////////////////////////////////////// PARABOLIC SAR //////////////////////////////////////////////////////
  166. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  167. start1 = input.float(0.02,"Start",minval=0.001, group = 'PSAR')
  168. increment = input.float(0.02,"Increament",minval=0.001, group = 'PSAR')
  169. maximum = 0.2
  170. psar_out = ta.sar(start1, increment, maximum)
  171. plot(showPSAR ? psar_out : na, 'ParabolicSAR', style=plot.style_cross, color=color.new(#2196f3, 0))
  172.  
  173. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  174. ///////////////////////////////////////////// PARABOLIC SAR2 //////////////////////////////////////////////////////
  175. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  176. start2 = input.float(0.01,"Start",minval=0.001, group = 'PSAR2')
  177. increment2 = input.float(0.01,"Increament",minval=0.001, group = 'PSAR2')
  178. maximum2 = 0.1
  179. psar_out2 = ta.sar(start2, increment2, maximum2)
  180. plot(showPSAR2 ? psar_out2 : na, 'ParabolicSAR2', style=plot.style_cross, color=color.new(#8c0707, 0))
  181.  
  182.  
  183. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  184.  
  185. // Input variables
  186.  
  187. ShowTrendCandles = input(false, title='Trend Candles', group = 'TREND')
  188.  
  189. ShowSupResZones = input(false, title='Support / Resistance Zones', group = 'TREND')
  190.  
  191. InvertColors = input(true, title='Support / Resistance Zones - Invert Colors', group = 'TREND')
  192.  
  193.  
  194. a_Color_Type = input.string(title='---------------------Trendlines - 1 & 2 - Color Scheme-------------', defval='Colored', options=['Colored', 'Monochrome'], group = 'TREND')
  195.  
  196.  
  197. a_Show_Primary = input(true, title='1 - Primary - Trendlines ---------------------------------------------------------------', group = 'TREND')
  198.  
  199. a_Rising_Upper_Falling_Lower = input(false, '1 - Primary - Rising Upper and Falling Lower Trendlines', group = 'TREND')
  200.  
  201.  
  202. a_len = input(20, title='1 - Primary - Lookback Length', group = 'TREND')
  203.  
  204. a_Wicks = input.string(title='1 - Primary - Draw lines from', defval='Wicks', options=['Wicks', 'Real Bodies'], group = 'TREND')
  205.  
  206. a_Extensions = input.string(title='1 - Primary - Trendline Extensions', defval=' 150', options=['Infinate', ' 25', ' 50', ' 75', ' 100', ' 150', ' 200', ' 300', ' 400', ' 500', ' 750', '1000'])
  207.  
  208. a_width = input.int(1, title='1 - Primary - Line Width', minval=0, maxval=10)
  209.  
  210.  
  211. a_Line_Type_In = input.string(title='1 - Primary - Line Type', defval='Dashed', options=['Dashed', 'Dotted', 'Solid'])
  212.  
  213. a_Line_Type = a_Line_Type_In == 'Dashed' ? line.style_dashed : a_Line_Type_In == 'Dotted' ? line.style_dotted : line.style_solid
  214.  
  215.  
  216. a_Show_Breaks = input.string(title='1 - Primary - Trendline Breaks;', defval='n/a', options=['Barcolor', 'Triangles + Barcolor', 'Triangles', 'n/a'])
  217.  
  218. a_trendline_nr = input.int(3, title='1 - Primary - Trendline Breaks - Number of Past Trendlines to Check for Breaks', minval=0, maxval=10)
  219.  
  220. a_select_breaks = input(true, title='1 - Primary - Trendline Breaks - Display Only - \'Long\' Breaks on Trendlines Connecting \'Highs\' and \'Short\' for \'Lows\'')
  221.  
  222.  
  223. b_Show_Secondary = input(true, title='2 - Secondary - Trendlines ------------------------------------------------------------')
  224.  
  225. b_Rising_Upper_Falling_Lower = input(false, '2 - Secondary - Rising Upper and Falling Lower Trendlines')
  226.  
  227.  
  228. b_len = input(7, title='2 - Secondary - Lookback Length')
  229.  
  230. b_Wicks = input.string(title='2 - Secondary - Draw lines from', defval='Wicks', options=['Wicks', 'Real Bodies'])
  231.  
  232. b_Extensions = input.string(title='2 - Secondary - Trendline Extensions', defval=' 25', options=['Infinate', ' 25', ' 50', ' 75', ' 100', ' 150', ' 200', ' 300', ' 400', ' 500', ' 750', '1000'])
  233.  
  234. b_width = input.int(1, title='2 - Secondary - Line Width', minval=0, maxval=10)
  235.  
  236.  
  237. b_Line_Type_In = input.string(title='2 - Secondary - Line Type', defval='Dotted', options=['Dashed', 'Dotted', 'Solid'])
  238.  
  239. b_Line_Type = b_Line_Type_In == 'Dashed' ? line.style_dashed : b_Line_Type_In == 'Dotted' ? line.style_dotted : line.style_solid
  240.  
  241.  
  242. b_Show_Breaks = input.string(title='2 - Secondary - Trendline Breaks;', defval='n/a', options=['Barcolor', 'Triangles + Barcolor', 'Triangles', 'n/a'])
  243.  
  244. b_trendline_nr = input.int(5, title='2 - Secondary - Trendline Breaks - Number of Past Trendlines to Check for Breaks', minval=0, maxval=10)
  245.  
  246. b_select_breaks = input(true, title='2 - Secondary - Trendline Breaks - Display Only - \'Long\' Breaks on Trendlines Connecting \'Highs\' and \'Short\' for \'Lows\'')
  247.  
  248.  
  249. log_chart = input(false, title='Log Chart?')
  250.  
  251. a_bar_time = time - time[1]
  252.  
  253. b_bar_time = time - time[1]
  254.  
  255.  
  256. ///// Primary Trendlines /////
  257.  
  258. // Trendline Extensions
  259.  
  260. a_Extension_Multiplier = a_Extensions == ' 25' ? 1 : a_Extensions == ' 50' ? 2 : a_Extensions == ' 75' ? 3 : a_Extensions == ' 100' ? 4 : a_Extensions == ' 150' ? 6 : a_Extensions == ' 200' ? 8 : a_Extensions == ' 300' ? 12 : a_Extensions == ' 400' ? 16 : a_Extensions == ' 500' ? 20 : a_Extensions == ' 750' ? 30 : a_Extensions == '1000' ? 40 : a_Extensions == 'Infinate' ? 0 : na
  261.  
  262.  
  263. // Declaration of trendline function
  264. a_f_trendline(a__input_function, a__delay, a__only_up, a__extend) =>
  265. // Calculate line coordinates (Ax,Ay) - (Bx,By)
  266. var int a_Ax = 1
  267. var int a_Bx = 1
  268. var float a_By = 0
  269. var float a_slope = 0
  270. a_Ay = fixnan(a__input_function)
  271. if ta.change(a_Ay) != 0
  272. a_Ax := time[a__delay]
  273. a_By := a_Ay[1]
  274. a_Bx := a_Ax[1]
  275. a_slope := log_chart ? (math.log(a_Ay) - math.log(a_By)) / (a_Ax - a_Bx) : (a_Ay - a_By) / (a_Ax - a_Bx)
  276. a_slope
  277. else
  278. a_Ax := a_Ax[1]
  279. a_Bx := a_Bx[1]
  280. a_By := a_By[1]
  281. a_By
  282. // Draw trendlines
  283. var line a_trendline = na
  284. var int a_Axbis = 0
  285. var float a_Aybis = 0
  286. var bool a__xtend = true
  287. a_extension_time = a_Extension_Multiplier * a_bar_time * 25
  288. a_Axbis := a_Ax + a_extension_time
  289. a_Aybis := log_chart ? a_Ay * math.exp(a_extension_time * a_slope) : a_Ay + a_extension_time * a_slope
  290. if a_Extension_Multiplier != 0
  291. a__xtend := false
  292. a__xtend
  293. if ta.change(a_Ay) != 0
  294.  
  295. a_line_color_Rising_Falling = a_slope * time < 0 ? a__only_up ? a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? color.green : color.teal : a__only_up ? a_Color_Type == 'Colored' ? color.red : color.teal : a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na
  296. a_line_color_Not_Rising_Falling = a_slope * time < 0 ? a__only_up ? na : a_Color_Type == 'Colored' ? color.green : color.teal : a__only_up ? a_Color_Type == 'Colored' ? color.red : color.teal : na
  297.  
  298. a_line_color = a_Show_Primary and not a_Rising_Upper_Falling_Lower ? a_line_color_Not_Rising_Falling : a_Show_Primary and a_Rising_Upper_Falling_Lower ? a_line_color_Rising_Falling : na
  299.  
  300. if not na(a_line_color)
  301. a_trendline := line.new(a_Bx, a_By, a_Axbis, a_Aybis, xloc.bar_time, extend=a__xtend ? extend.right : extend.none, color=a_line_color, style=a_Line_Type, width=a_width)
  302. a_trendline
  303. [a_Bx, a_By, a_Axbis, a_Aybis, a_slope]
  304.  
  305.  
  306. // Function to get trendline price for X bars ago ("0" = current value)
  307. a_line_get_price(a__start_time, a__start_price, a__slope, a__lookback_period, a__log_chart) =>
  308. var float a_current_price = 0.0
  309. a_elapsed_time = time - a__start_time
  310. a_current_price := a__log_chart ? a__start_price * math.exp((a_elapsed_time - a__lookback_period * a_bar_time) * a__slope) : a__start_price + (a_elapsed_time - a__lookback_period * a_bar_time) * a__slope
  311. a_current_price
  312.  
  313.  
  314. // Function to check for trendline crosses
  315. a_line_cross(a__check_value, a__start_time, a__start_price, a__slope, a__log_chart) =>
  316. var float a_current_value = 0.0
  317. var float a_previous_value = 0.0
  318. // Get current and previous price for the trendline
  319. a_current_value := a_line_get_price(a__start_time, a__start_price, a__slope, 0, a__log_chart) // 0, a__log_chart)
  320. a_previous_value := a_line_get_price(a__start_time, a__start_price, a__slope, 1, a__log_chart) //1, a__log_chart)
  321. // Return 1 for crossover, -1 for crossunder and 0 for no cross detected
  322. a_cross = a__check_value[1] < a_previous_value and a__check_value > a_current_value ? 1 : a__check_value[1] > a_previous_value and a__check_value < a_current_value ? -1 : 0
  323. a_cross
  324.  
  325.  
  326. // Calculate pivot points
  327. a_high_point = ta.pivothigh(a_Wicks == 'Wicks' ? high : close > open ? close : open, a_len, a_len / 2)
  328. a_low_point = ta.pivotlow(a_Wicks == 'Wicks' ? low : close > open ? open : close, a_len, a_len / 2)
  329.  
  330. // Call trendline function for high and low pivot points
  331. [a_phx1, a_phy1, a_phx2, a_phy2, a_slope_high] = a_f_trendline(a_high_point, a_len / 2, false, true)
  332. [a_plx1, a_ply1, a_plx2, a_ply2, a_slope_low] = a_f_trendline(a_low_point, a_len / 2, true, true)
  333.  
  334.  
  335. // Initialition of pseudo array to keep track of last 10 high and 10 low trendline values
  336. var int a_high_x0 = 0
  337. var float a_high_y0 = 0.0
  338. var float a_high_sl0 = 0.0
  339. var int a_high_x1 = 0
  340. var float a_high_y1 = 0.0
  341. var float a_high_sl1 = 0.0
  342. var int a_high_x2 = 0
  343. var float a_high_y2 = 0.0
  344. var float a_high_sl2 = 0.0
  345. var int a_high_x3 = 0
  346. var float a_high_y3 = 0.0
  347. var float a_high_sl3 = 0.0
  348. var int a_high_x4 = 0
  349. var float a_high_y4 = 0.0
  350. var float a_high_sl4 = 0.0
  351. var int a_high_x5 = 0
  352. var float a_high_y5 = 0.0
  353. var float a_high_sl5 = 0.0
  354. var int a_high_x6 = 0
  355. var float a_high_y6 = 0.0
  356. var float a_high_sl6 = 0.0
  357. var int a_high_x7 = 0
  358. var float a_high_y7 = 0.0
  359. var float a_high_sl7 = 0.0
  360. var int a_high_x8 = 0
  361. var float a_high_y8 = 0.0
  362. var float a_high_sl8 = 0.0
  363. var int a_high_x9 = 0
  364. var float a_high_y9 = 0.0
  365. var float a_high_sl9 = 0.0
  366.  
  367. var int a_low_x0 = 0
  368. var float a_low_y0 = 0.0
  369. var float a_low_sl0 = 0.0
  370. var int a_low_x1 = 0
  371. var float a_low_y1 = 0.0
  372. var float a_low_sl1 = 0.0
  373. var int a_low_x2 = 0
  374. var float a_low_y2 = 0.0
  375. var float a_low_sl2 = 0.0
  376. var int a_low_x3 = 0
  377. var float a_low_y3 = 0.0
  378. var float a_low_sl3 = 0.0
  379. var int a_low_x4 = 0
  380. var float a_low_y4 = 0.0
  381. var float a_low_sl4 = 0.0
  382. var int a_low_x5 = 0
  383. var float a_low_y5 = 0.0
  384. var float a_low_sl5 = 0.0
  385. var int a_low_x6 = 0
  386. var float a_low_y6 = 0.0
  387. var float a_low_sl6 = 0.0
  388. var int a_low_x7 = 0
  389. var float a_low_y7 = 0.0
  390. var float a_low_sl7 = 0.0
  391. var int a_low_x8 = 0
  392. var float a_low_y8 = 0.0
  393. var float a_low_sl8 = 0.0
  394. var int a_low_x9 = 0
  395. var float a_low_y9 = 0.0
  396. var float a_low_sl9 = 0.0
  397.  
  398.  
  399. // If a new trendline is formed, shift all values in the array one place up and forget the last values
  400. if ta.change(fixnan(a_high_point)) != 0
  401. a_high_x9 := a_high_x8
  402. a_high_y9 := a_high_y8
  403. a_high_sl9 := a_high_sl8
  404. a_high_x8 := a_high_x7
  405. a_high_y8 := a_high_y7
  406. a_high_sl8 := a_high_sl7
  407. a_high_x7 := a_high_x6
  408. a_high_y7 := a_high_y6
  409. a_high_sl7 := a_high_sl6
  410. a_high_x6 := a_high_x5
  411. a_high_y6 := a_high_y5
  412. a_high_sl6 := a_high_sl5
  413. a_high_x5 := a_high_x4
  414. a_high_y5 := a_high_y4
  415. a_high_sl5 := a_high_sl4
  416. a_high_x4 := a_high_x3
  417. a_high_y4 := a_high_y3
  418. a_high_sl4 := a_high_sl3
  419. a_high_x3 := a_high_x2
  420. a_high_y3 := a_high_y2
  421. a_high_sl3 := a_high_sl2
  422. a_high_x2 := a_high_x1
  423. a_high_y2 := a_high_y1
  424. a_high_sl2 := a_high_sl1
  425. a_high_x1 := a_high_x0
  426. a_high_y1 := a_high_y0
  427. a_high_sl1 := a_high_sl0
  428. a_high_x0 := a_phx1
  429. a_high_y0 := a_phy1
  430. a_high_sl0 := a_slope_high
  431. a_high_sl0
  432.  
  433. if ta.change(fixnan(a_low_point)) != 0
  434. a_low_x9 := a_low_x8
  435. a_low_y9 := a_low_y8
  436. a_low_sl9 := a_low_sl8
  437. a_low_x8 := a_low_x7
  438. a_low_y8 := a_low_y7
  439. a_low_sl8 := a_low_sl7
  440. a_low_x7 := a_low_x6
  441. a_low_y7 := a_low_y6
  442. a_low_sl7 := a_low_sl6
  443. a_low_x6 := a_low_x5
  444. a_low_y6 := a_low_y5
  445. a_low_sl6 := a_low_sl5
  446. a_low_x5 := a_low_x4
  447. a_low_y5 := a_low_y4
  448. a_low_sl5 := a_low_sl4
  449. a_low_x4 := a_low_x3
  450. a_low_y4 := a_low_y3
  451. a_low_sl4 := a_low_sl3
  452. a_low_x3 := a_low_x2
  453. a_low_y3 := a_low_y2
  454. a_low_sl3 := a_low_sl2
  455. a_low_x2 := a_low_x1
  456. a_low_y2 := a_low_y1
  457. a_low_sl2 := a_low_sl1
  458. a_low_x1 := a_low_x0
  459. a_low_y1 := a_low_y0
  460. a_low_sl1 := a_low_sl0
  461. a_low_x0 := a_plx1
  462. a_low_y0 := a_ply1
  463. a_low_sl0 := a_slope_low
  464. a_low_sl0
  465.  
  466.  
  467. // Check Trendline crosses for last X nr. of trendlines
  468. a_cross_high0 = not a_Rising_Upper_Falling_Lower and a_high_sl0 * time > 0 ? 0 : a_line_cross(close, a_high_x0, a_high_y0, a_high_sl0, log_chart)
  469. a_cross_low0 = not a_Rising_Upper_Falling_Lower and a_low_sl0 * time < 0 ? 0 : a_line_cross(close, a_low_x0, a_low_y0, a_low_sl0, log_chart)
  470.  
  471. a_cross_high1 = not a_Rising_Upper_Falling_Lower and a_high_sl1 * time > 0 ? 0 : a_line_cross(close, a_high_x1, a_high_y1, a_high_sl1, log_chart)
  472. a_cross_low1 = not a_Rising_Upper_Falling_Lower and a_low_sl1 * time < 0 ? 0 : a_line_cross(close, a_low_x1, a_low_y1, a_low_sl1, log_chart)
  473.  
  474. a_cross_high2 = not a_Rising_Upper_Falling_Lower and a_high_sl2 * time > 0 ? 0 : a_line_cross(close, a_high_x2, a_high_y2, a_high_sl2, log_chart)
  475. a_cross_low2 = not a_Rising_Upper_Falling_Lower and a_low_sl2 * time < 0 ? 0 : a_line_cross(close, a_low_x2, a_low_y2, a_low_sl2, log_chart)
  476.  
  477. a_cross_high3 = not a_Rising_Upper_Falling_Lower and a_high_sl3 * time > 0 ? 0 : a_line_cross(close, a_high_x3, a_high_y3, a_high_sl3, log_chart)
  478. a_cross_low3 = not a_Rising_Upper_Falling_Lower and a_low_sl3 * time < 0 ? 0 : a_line_cross(close, a_low_x3, a_low_y3, a_low_sl3, log_chart)
  479.  
  480. a_cross_high4 = not a_Rising_Upper_Falling_Lower and a_high_sl4 * time > 0 ? 0 : a_line_cross(close, a_high_x4, a_high_y4, a_high_sl4, log_chart)
  481. a_cross_low4 = not a_Rising_Upper_Falling_Lower and a_low_sl4 * time < 0 ? 0 : a_line_cross(close, a_low_x4, a_low_y4, a_low_sl4, log_chart)
  482.  
  483. a_cross_high5 = not a_Rising_Upper_Falling_Lower and a_high_sl5 * time > 0 ? 0 : a_line_cross(close, a_high_x5, a_high_y5, a_high_sl5, log_chart)
  484. a_cross_low5 = not a_Rising_Upper_Falling_Lower and a_low_sl5 * time < 0 ? 0 : a_line_cross(close, a_low_x5, a_low_y5, a_low_sl5, log_chart)
  485.  
  486. a_cross_high6 = not a_Rising_Upper_Falling_Lower and a_high_sl6 * time > 0 ? 0 : a_line_cross(close, a_high_x6, a_high_y6, a_high_sl6, log_chart)
  487. a_cross_low6 = not a_Rising_Upper_Falling_Lower and a_low_sl6 * time < 0 ? 0 : a_line_cross(close, a_low_x6, a_low_y6, a_low_sl6, log_chart)
  488.  
  489. a_cross_high7 = not a_Rising_Upper_Falling_Lower and a_high_sl7 * time > 0 ? 0 : a_line_cross(close, a_high_x7, a_high_y7, a_high_sl7, log_chart)
  490. a_cross_low7 = not a_Rising_Upper_Falling_Lower and a_low_sl7 * time < 0 ? 0 : a_line_cross(close, a_low_x7, a_low_y7, a_low_sl7, log_chart)
  491.  
  492. a_cross_high8 = not a_Rising_Upper_Falling_Lower and a_high_sl8 * time > 0 ? 0 : a_line_cross(close, a_high_x8, a_high_y8, a_high_sl8, log_chart)
  493. a_cross_low8 = not a_Rising_Upper_Falling_Lower and a_low_sl8 * time < 0 ? 0 : a_line_cross(close, a_low_x8, a_low_y8, a_low_sl8, log_chart)
  494.  
  495. a_cross_high9 = not a_Rising_Upper_Falling_Lower and a_high_sl9 * time > 0 ? 0 : a_line_cross(close, a_high_x9, a_high_y9, a_high_sl9, log_chart)
  496. a_cross_low9 = not a_Rising_Upper_Falling_Lower and a_low_sl9 * time < 0 ? 0 : a_line_cross(close, a_low_x9, a_low_y9, a_low_sl9, log_chart)
  497.  
  498.  
  499. a_long_break = (a_trendline_nr > 9 ? a_cross_high9 == 1 or (a_select_breaks ? false : a_cross_low9 == 1) : false) or (a_trendline_nr > 8 ? a_cross_high8 == 1 or (a_select_breaks ? false : a_cross_low8 == 1) : false) or (a_trendline_nr > 7 ? a_cross_high7 == 1 or (a_select_breaks ? false : a_cross_low7 == 1) : false) or (a_trendline_nr > 6 ? a_cross_high6 == 1 or (a_select_breaks ? false : a_cross_low6 == 1) : false) or (a_trendline_nr > 5 ? a_cross_high5 == 1 or (a_select_breaks ? false : a_cross_low5 == 1) : false) or (a_trendline_nr > 4 ? a_cross_high4 == 1 or (a_select_breaks ? false : a_cross_low4 == 1) : false) or (a_trendline_nr > 3 ? a_cross_high3 == 1 or (a_select_breaks ? false : a_cross_low3 == 1) : false) or (a_trendline_nr > 2 ? a_cross_high2 == 1 or (a_select_breaks ? false : a_cross_low2 == 1) : false) or (a_trendline_nr > 1 ? a_cross_high1 == 1 or (a_select_breaks ? false : a_cross_low1 == 1) : false) or a_cross_high0 == 1 or (a_select_breaks ? false : a_cross_low0 == 1)
  500.  
  501.  
  502. a_short_break = (a_trendline_nr > 9 ? (a_select_breaks ? false : a_cross_high9 == -1) or a_cross_low9 == -1 : false) or (a_trendline_nr > 8 ? (a_select_breaks ? false : a_cross_high8 == -1) or a_cross_low8 == -1 : false) or (a_trendline_nr > 7 ? (a_select_breaks ? false : a_cross_high7 == -1) or a_cross_low7 == -1 : false) or (a_trendline_nr > 6 ? (a_select_breaks ? false : a_cross_high6 == -1) or a_cross_low6 == -1 : false) or (a_trendline_nr > 5 ? (a_select_breaks ? false : a_cross_high5 == -1) or a_cross_low5 == -1 : false) or (a_trendline_nr > 4 ? (a_select_breaks ? false : a_cross_high4 == -1) or a_cross_low4 == -1 : false) or (a_trendline_nr > 3 ? (a_select_breaks ? false : a_cross_high3 == -1) or a_cross_low3 == -1 : false) or (a_trendline_nr > 2 ? (a_select_breaks ? false : a_cross_high2 == -1) or a_cross_low2 == -1 : false) or (a_trendline_nr > 1 ? (a_select_breaks ? false : a_cross_high1 == -1) or a_cross_low1 == -1 : false) or (a_select_breaks ? false : a_cross_high0 == -1) or a_cross_low0 == -1
  503.  
  504.  
  505. // // Plot and connect pivot points
  506. a_color_high = a_slope_high * time < 0 ? a_Color_Type == 'Colored' ? color.green : color.teal : na
  507. a_color_low = a_slope_low * time > 0 ? a_Color_Type == 'Colored' ? color.red : color.teal : na
  508.  
  509.  
  510. // plot(a_Show_Primary? a_high_point : na, title = "Primary - Upper Trendline", color = a_color_high, offset = -a_len / 2)
  511. // plot(a_Show_Primary? a_low_point : na, title = "Primary - Lower Trendline", color = a_color_low, offset = -a_len / 2)
  512.  
  513.  
  514. // Signal Triangles Trendline breaks
  515. plotshape(a_Show_Breaks == 'Triangles' or a_Show_Breaks == 'Triangles + Barcolor' ? a_long_break ? close : na : na, title='cross_high', style=shape.triangleup, size=size.small, location=location.belowbar, color=color.new(#c6e163, 0))
  516. plotshape(a_Show_Breaks == 'Triangles' or a_Show_Breaks == 'Triangles + Barcolor' ? a_short_break ? close : na : na, title='cross_low', style=shape.triangledown, size=size.small, location=location.abovebar, color=color.new(color.fuchsia, 0))
  517.  
  518. plotBreakup = a_Show_Breaks == 'Triangles' or a_Show_Breaks == 'Triangles + Barcolor' ? a_long_break ? close : na : na
  519. plotBreakdown = a_Show_Breaks == 'Triangles' or a_Show_Breaks == 'Triangles + Barcolor' ? a_short_break ? close : na : na
  520. // Color bars on breaks
  521. barcolor(a_Show_Breaks == 'Barcolor' or a_Show_Breaks == 'Triangles + Barcolor' ? a_long_break ? ShowTrendCandles ? #c6e163 : #c6e163 : a_short_break ? color.fuchsia : na : na, title='Primary')
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528. alertcondition(a_long_break or a_short_break, title='Alert - Primary Trendline - Break')
  529.  
  530. alertcondition(a_long_break, title='Alert - Primary Trendline - Break Up')
  531.  
  532.  
  533.  
  534. alertcondition(a_short_break, title='Alert - Primary Trendline - Break Down')
  535.  
  536.  
  537. // ///// Secondary Trendlines /////
  538.  
  539. // // Trendline Extensions
  540.  
  541. b_Extension_Multiplier = b_Extensions == ' 25' ? 1 : b_Extensions == ' 50' ? 2 : b_Extensions == ' 75' ? 3 : b_Extensions == ' 100' ? 4 : b_Extensions == ' 150' ? 6 : b_Extensions == ' 200' ? 8 : b_Extensions == ' 300' ? 12 : b_Extensions == ' 400' ? 16 : b_Extensions == ' 500' ? 20 : b_Extensions == ' 750' ? 30 : b_Extensions == '1000' ? 40 : b_Extensions == 'Infinate' ? 0 : na
  542.  
  543.  
  544. // Declaration of trendline function
  545. b_f_trendline(b__input_function, b__delay, b__only_up, b__extend) =>
  546. // Calculate line coordinates (Ax,Ay) - (Bx,By)
  547. var int b_Ax = 1
  548. var int b_Bx = 1
  549. var float b_By = 0
  550. var float b_slope = 0
  551. b_Ay = fixnan(b__input_function)
  552. if ta.change(b_Ay) != 0
  553. b_Ax := time[b__delay]
  554. b_By := b_Ay[1]
  555. b_Bx := b_Ax[1]
  556. b_slope := log_chart ? (math.log(b_Ay) - math.log(b_By)) / (b_Ax - b_Bx) : (b_Ay - b_By) / (b_Ax - b_Bx)
  557. b_slope
  558. else
  559. b_Ax := b_Ax[1]
  560. b_Bx := b_Bx[1]
  561. b_By := b_By[1]
  562. b_By
  563. // Draw trendlines
  564. var line b_trendline = na
  565. var int b_Axbis = 0
  566. var float b_Aybis = 0
  567. var bool b__xtend = true
  568. b_extension_time = b_Extension_Multiplier * b_bar_time * 25
  569. b_Axbis := b_Ax + b_extension_time
  570. b_Aybis := log_chart ? b_Ay * math.exp(b_extension_time * b_slope) : b_Ay + b_extension_time * b_slope
  571. if b_Extension_Multiplier != 0
  572. b__xtend := false
  573. b__xtend
  574. if ta.change(b_Ay) != 0
  575.  
  576. b_line_color_Rising_Falling = b_slope * time < 0 ? b__only_up ? b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? color.green : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.red : color.teal : b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na
  577. b_line_color_Not_Rising_Falling = b_slope * time < 0 ? b__only_up ? na : a_Color_Type == 'Colored' ? color.green : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.red : color.teal : na
  578.  
  579. b_line_color = b_Show_Secondary and not b_Rising_Upper_Falling_Lower ? b_line_color_Not_Rising_Falling : b_Show_Secondary and b_Rising_Upper_Falling_Lower ? b_line_color_Rising_Falling : na
  580.  
  581. if not na(b_line_color)
  582. b_trendline := line.new(b_Bx, b_By, b_Axbis, b_Aybis, xloc.bar_time, extend=b__xtend ? extend.right : extend.none, color=b_line_color, style=b_Line_Type, width=b_width)
  583. b_trendline
  584. [b_Bx, b_By, b_Axbis, b_Aybis, b_slope]
  585.  
  586.  
  587. // Function to get trendline price for X bars ago ("0" = current value)
  588. b_line_get_price(b__start_time, b__start_price, b__slope, b__lookback_period, b__log_chart) =>
  589. var float b_current_price = 0.0
  590. b_elapsed_time = time - b__start_time // (time-b__start_time) // Original v312
  591. b_current_price := b__log_chart ? b__start_price * math.exp((b_elapsed_time - b__lookback_period * b_bar_time) * b__slope) : b__start_price + (b_elapsed_time - b__lookback_period * b_bar_time) * b__slope
  592. b_current_price
  593.  
  594.  
  595. // Function to check for trendline crosses
  596. b_line_cross(b__check_value, b__start_time, b__start_price, b__slope, b__log_chart) =>
  597. var float b_current_value = 0.0
  598. var float b_previous_value = 0.0
  599. // Get current and previous price for the trendline
  600. b_current_value := b_line_get_price(b__start_time, b__start_price, b__slope, 0, b__log_chart) // 0, b__log_chart)
  601. b_previous_value := b_line_get_price(b__start_time, b__start_price, b__slope, 1, b__log_chart) //1, b__log_chart)
  602. // Return 1 for crossover, -1 for crossunder and 0 for no cross detected
  603. b_cross = b__check_value[1] < b_previous_value and b__check_value > b_current_value ? 1 : b__check_value[1] > b_previous_value and b__check_value < b_current_value ? -1 : 0
  604. b_cross
  605.  
  606. // Calculate pivot points
  607. b_high_point = ta.pivothigh(b_Wicks == 'Wicks' ? high : close > open ? close : open, b_len, b_len / 2)
  608. b_low_point = ta.pivotlow(b_Wicks == 'Wicks' ? low : close > open ? open : close, b_len, b_len / 2)
  609.  
  610. // Call trendline function for high and low pivot points
  611. [b_phx1, b_phy1, b_phx2, b_phy2, b_slope_high] = b_f_trendline(b_high_point, b_len / 2, false, true)
  612. [b_plx1, b_ply1, b_plx2, b_ply2, b_slope_low] = b_f_trendline(b_low_point, b_len / 2, true, true)
  613.  
  614. // Plot and connect pivot points
  615. b_color_high = b_slope_high * time < 0 ? color.green : na
  616. b_color_low = b_slope_low * time > 0 ? color.red : na
  617.  
  618. // plot(b_Show_Secondary? b_high_point : na, title = "Secondary - Upper Trendline", color = b_color_high, offset = -b_len / 2)
  619. // plot(b_Show_Secondary? b_low_point : na, title = "Secondary - Lower Trendline", color = b_color_low, offset = -b_len / 2)
  620.  
  621.  
  622. // Initialition of pseudo array to keep track of last 10 high and 10 low trendline values
  623. var int b_high_x0 = 0
  624. var float b_high_y0 = 0.0
  625. var float b_high_sl0 = 0.0
  626. var int b_high_x1 = 0
  627. var float b_high_y1 = 0.0
  628. var float b_high_sl1 = 0.0
  629. var int b_high_x2 = 0
  630. var float b_high_y2 = 0.0
  631. var float b_high_sl2 = 0.0
  632. var int b_high_x3 = 0
  633. var float b_high_y3 = 0.0
  634. var float b_high_sl3 = 0.0
  635. var int b_high_x4 = 0
  636. var float b_high_y4 = 0.0
  637. var float b_high_sl4 = 0.0
  638. var int b_high_x5 = 0
  639. var float b_high_y5 = 0.0
  640. var float b_high_sl5 = 0.0
  641. var int b_high_x6 = 0
  642. var float b_high_y6 = 0.0
  643. var float b_high_sl6 = 0.0
  644. var int b_high_x7 = 0
  645. var float b_high_y7 = 0.0
  646. var float b_high_sl7 = 0.0
  647. var int b_high_x8 = 0
  648. var float b_high_y8 = 0.0
  649. var float b_high_sl8 = 0.0
  650. var int b_high_x9 = 0
  651. var float b_high_y9 = 0.0
  652. var float b_high_sl9 = 0.0
  653.  
  654. var int b_low_x0 = 0
  655. var float b_low_y0 = 0.0
  656. var float b_low_sl0 = 0.0
  657. var int b_low_x1 = 0
  658. var float b_low_y1 = 0.0
  659. var float b_low_sl1 = 0.0
  660. var int b_low_x2 = 0
  661. var float b_low_y2 = 0.0
  662. var float b_low_sl2 = 0.0
  663. var int b_low_x3 = 0
  664. var float b_low_y3 = 0.0
  665. var float b_low_sl3 = 0.0
  666. var int b_low_x4 = 0
  667. var float b_low_y4 = 0.0
  668. var float b_low_sl4 = 0.0
  669. var int b_low_x5 = 0
  670. var float b_low_y5 = 0.0
  671. var float b_low_sl5 = 0.0
  672. var int b_low_x6 = 0
  673. var float b_low_y6 = 0.0
  674. var float b_low_sl6 = 0.0
  675. var int b_low_x7 = 0
  676. var float b_low_y7 = 0.0
  677. var float b_low_sl7 = 0.0
  678. var int b_low_x8 = 0
  679. var float b_low_y8 = 0.0
  680. var float b_low_sl8 = 0.0
  681. var int b_low_x9 = 0
  682. var float b_low_y9 = 0.0
  683. var float b_low_sl9 = 0.0
  684.  
  685.  
  686. // If a new trendline is formed, shift all values in the array one place up and forget the last values
  687. if ta.change(fixnan(b_high_point)) != 0
  688. b_high_x9 := b_high_x8
  689. b_high_y9 := b_high_y8
  690. b_high_sl9 := b_high_sl8
  691. b_high_x8 := b_high_x7
  692. b_high_y8 := b_high_y7
  693. b_high_sl8 := b_high_sl7
  694. b_high_x7 := b_high_x6
  695. b_high_y7 := b_high_y6
  696. b_high_sl7 := b_high_sl6
  697. b_high_x6 := b_high_x5
  698. b_high_y6 := b_high_y5
  699. b_high_sl6 := b_high_sl5
  700. b_high_x5 := b_high_x4
  701. b_high_y5 := b_high_y4
  702. b_high_sl5 := b_high_sl4
  703. b_high_x4 := b_high_x3
  704. b_high_y4 := b_high_y3
  705. b_high_sl4 := b_high_sl3
  706. b_high_x3 := b_high_x2
  707. b_high_y3 := b_high_y2
  708. b_high_sl3 := b_high_sl2
  709. b_high_x2 := b_high_x1
  710. b_high_y2 := b_high_y1
  711. b_high_sl2 := b_high_sl1
  712. b_high_x1 := b_high_x0
  713. b_high_y1 := b_high_y0
  714. b_high_sl1 := b_high_sl0
  715. b_high_x0 := b_phx1
  716. b_high_y0 := b_phy1
  717. b_high_sl0 := b_slope_high
  718. b_high_sl0
  719.  
  720. if ta.change(fixnan(b_low_point)) != 0
  721. b_low_x9 := b_low_x8
  722. b_low_y9 := b_low_y8
  723. b_low_sl9 := b_low_sl8
  724. b_low_x8 := b_low_x7
  725. b_low_y8 := b_low_y7
  726. b_low_sl8 := b_low_sl7
  727. b_low_x7 := b_low_x6
  728. b_low_y7 := b_low_y6
  729. b_low_sl7 := b_low_sl6
  730. b_low_x6 := b_low_x5
  731. b_low_y6 := b_low_y5
  732. b_low_sl6 := b_low_sl5
  733. b_low_x5 := b_low_x4
  734. b_low_y5 := b_low_y4
  735. b_low_sl5 := b_low_sl4
  736. b_low_x4 := b_low_x3
  737. b_low_y4 := b_low_y3
  738. b_low_sl4 := b_low_sl3
  739. b_low_x3 := b_low_x2
  740. b_low_y3 := b_low_y2
  741. b_low_sl3 := b_low_sl2
  742. b_low_x2 := b_low_x1
  743. b_low_y2 := b_low_y1
  744. b_low_sl2 := b_low_sl1
  745. b_low_x1 := b_low_x0
  746. b_low_y1 := b_low_y0
  747. b_low_sl1 := b_low_sl0
  748. b_low_x0 := b_plx1
  749. b_low_y0 := b_ply1
  750. b_low_sl0 := b_slope_low
  751. b_low_sl0
  752.  
  753.  
  754. // Check Trendline crosses for last X nr. of trendlines
  755. b_cross_high0 = not b_Rising_Upper_Falling_Lower and b_high_sl0 * time > 0 ? 0 : b_line_cross(close, b_high_x0, b_high_y0, b_high_sl0, log_chart)
  756. b_cross_low0 = not b_Rising_Upper_Falling_Lower and b_low_sl0 * time < 0 ? 0 : b_line_cross(close, b_low_x0, b_low_y0, b_low_sl0, log_chart)
  757.  
  758. b_cross_high1 = not b_Rising_Upper_Falling_Lower and b_high_sl1 * time > 0 ? 0 : b_line_cross(close, b_high_x1, b_high_y1, b_high_sl1, log_chart)
  759. b_cross_low1 = not b_Rising_Upper_Falling_Lower and b_low_sl1 * time < 0 ? 0 : b_line_cross(close, b_low_x1, b_low_y1, b_low_sl1, log_chart)
  760.  
  761. b_cross_high2 = not b_Rising_Upper_Falling_Lower and b_high_sl2 * time > 0 ? 0 : b_line_cross(close, b_high_x2, b_high_y2, b_high_sl2, log_chart)
  762. b_cross_low2 = not b_Rising_Upper_Falling_Lower and b_low_sl2 * time < 0 ? 0 : b_line_cross(close, b_low_x2, b_low_y2, b_low_sl2, log_chart)
  763.  
  764. b_cross_high3 = not b_Rising_Upper_Falling_Lower and b_high_sl3 * time > 0 ? 0 : b_line_cross(close, b_high_x3, b_high_y3, b_high_sl3, log_chart)
  765. b_cross_low3 = not b_Rising_Upper_Falling_Lower and b_low_sl3 * time < 0 ? 0 : b_line_cross(close, b_low_x3, b_low_y3, b_low_sl3, log_chart)
  766.  
  767. b_cross_high4 = not b_Rising_Upper_Falling_Lower and b_high_sl4 * time > 0 ? 0 : b_line_cross(close, b_high_x4, b_high_y4, b_high_sl4, log_chart)
  768. b_cross_low4 = not b_Rising_Upper_Falling_Lower and b_low_sl4 * time < 0 ? 0 : b_line_cross(close, b_low_x4, b_low_y4, b_low_sl4, log_chart)
  769.  
  770. b_cross_high5 = not b_Rising_Upper_Falling_Lower and b_high_sl5 * time > 0 ? 0 : b_line_cross(close, b_high_x5, b_high_y5, b_high_sl5, log_chart)
  771. b_cross_low5 = not b_Rising_Upper_Falling_Lower and b_low_sl5 * time < 0 ? 0 : b_line_cross(close, b_low_x5, b_low_y5, b_low_sl5, log_chart)
  772.  
  773. b_cross_high6 = not b_Rising_Upper_Falling_Lower and b_high_sl6 * time > 0 ? 0 : b_line_cross(close, b_high_x6, b_high_y6, b_high_sl6, log_chart)
  774. b_cross_low6 = not b_Rising_Upper_Falling_Lower and b_low_sl6 * time < 0 ? 0 : b_line_cross(close, b_low_x6, b_low_y6, b_low_sl6, log_chart)
  775.  
  776. b_cross_high7 = not b_Rising_Upper_Falling_Lower and b_high_sl7 * time > 0 ? 0 : b_line_cross(close, b_high_x7, b_high_y7, b_high_sl7, log_chart)
  777. b_cross_low7 = not b_Rising_Upper_Falling_Lower and b_low_sl7 * time < 0 ? 0 : b_line_cross(close, b_low_x7, b_low_y7, b_low_sl7, log_chart)
  778.  
  779. b_cross_high8 = not b_Rising_Upper_Falling_Lower and b_high_sl8 * time > 0 ? 0 : b_line_cross(close, b_high_x8, b_high_y8, b_high_sl8, log_chart)
  780. b_cross_low8 = not b_Rising_Upper_Falling_Lower and b_low_sl8 * time < 0 ? 0 : b_line_cross(close, b_low_x8, b_low_y8, b_low_sl8, log_chart)
  781.  
  782. b_cross_high9 = not b_Rising_Upper_Falling_Lower and b_high_sl9 * time > 0 ? 0 : b_line_cross(close, b_high_x9, b_high_y9, b_high_sl9, log_chart)
  783. b_cross_low9 = not b_Rising_Upper_Falling_Lower and b_low_sl9 * time < 0 ? 0 : b_line_cross(close, b_low_x9, b_low_y9, b_low_sl9, log_chart)
  784.  
  785.  
  786. b_long_break = (b_trendline_nr > 9 ? b_cross_high9 == 1 or (b_select_breaks ? false : b_cross_low9 == 1) : false) or (b_trendline_nr > 8 ? b_cross_high8 == 1 or (b_select_breaks ? false : b_cross_low8 == 1) : false) or (b_trendline_nr > 7 ? b_cross_high7 == 1 or (b_select_breaks ? false : b_cross_low7 == 1) : false) or (b_trendline_nr > 6 ? b_cross_high6 == 1 or (b_select_breaks ? false : b_cross_low6 == 1) : false) or (b_trendline_nr > 5 ? b_cross_high5 == 1 or (b_select_breaks ? false : b_cross_low5 == 1) : false) or (b_trendline_nr > 4 ? b_cross_high4 == 1 or (b_select_breaks ? false : b_cross_low4 == 1) : false) or (b_trendline_nr > 3 ? b_cross_high3 == 1 or (b_select_breaks ? false : b_cross_low3 == 1) : false) or (b_trendline_nr > 2 ? b_cross_high2 == 1 or (b_select_breaks ? false : b_cross_low2 == 1) : false) or (b_trendline_nr > 1 ? b_cross_high1 == 1 or (b_select_breaks ? false : b_cross_low1 == 1) : false) or b_cross_high0 == 1 or (b_select_breaks ? false : b_cross_low0 == 1)
  787.  
  788.  
  789. b_short_break = (b_trendline_nr > 9 ? (b_select_breaks ? false : b_cross_high9 == -1) or b_cross_low9 == -1 : false) or (b_trendline_nr > 8 ? (b_select_breaks ? false : b_cross_high8 == -1) or b_cross_low8 == -1 : false) or (b_trendline_nr > 7 ? (b_select_breaks ? false : b_cross_high7 == -1) or b_cross_low7 == -1 : false) or (b_trendline_nr > 6 ? (b_select_breaks ? false : b_cross_high6 == -1) or b_cross_low6 == -1 : false) or (b_trendline_nr > 5 ? (b_select_breaks ? false : b_cross_high5 == -1) or b_cross_low5 == -1 : false) or (b_trendline_nr > 4 ? (b_select_breaks ? false : b_cross_high4 == -1) or b_cross_low4 == -1 : false) or (b_trendline_nr > 3 ? (b_select_breaks ? false : b_cross_high3 == -1) or b_cross_low3 == -1 : false) or (b_trendline_nr > 2 ? (b_select_breaks ? false : b_cross_high2 == -1) or b_cross_low2 == -1 : false) or (b_trendline_nr > 1 ? (b_select_breaks ? false : b_cross_high1 == -1) or b_cross_low1 == -1 : false) or (b_select_breaks ? false : b_cross_high0 == -1) or b_cross_low0 == -1
  790.  
  791.  
  792. // Signal Triangles Trendline breaks
  793. plotshape(b_Show_Breaks == 'Triangles' or b_Show_Breaks == 'Triangles + Barcolor' ? b_long_break ? close : na : na, title='cross_high', style=shape.triangleup, size=size.small, location=location.belowbar, color=color.new(#c6e163, 0))
  794. plotshape(b_Show_Breaks == 'Triangles' or b_Show_Breaks == 'Triangles + Barcolor' ? b_short_break ? close : na : na, title='cross_low', style=shape.triangledown, size=size.small, location=location.abovebar, color=color.new(color.fuchsia, 0))
  795.  
  796. // Color bars on breaks
  797. barcolor(b_Show_Breaks == 'Barcolor' or b_Show_Breaks == 'Triangles + Barcolor' ? b_long_break ? ShowTrendCandles ? #c6e163 : #c6e163 : b_short_break ? color.fuchsia : na : na, title='Secondary')
  798.  
  799.  
  800. /////// Alerts ///////
  801.  
  802. alertcondition(b_long_break or b_short_break, title='Alert - Secondary Trendline - Break')
  803.  
  804. alertcondition(b_long_break, title='Alert - Secondary Trendline - Break Up')
  805.  
  806. if a_short_break
  807. alert ('Secondary Breakup on ' + timeframe.period + ' chart. Price is ' + str.tostring(close), alertMode)
  808.  
  809.  
  810. alertcondition(b_short_break, title='Alert - Secondary Trendline - Break Down')
  811.  
  812. if a_short_break
  813. alert ('Secondary Breakdown on ' + timeframe.period + ' chart. Price is ' + str.tostring(close), alertMode)
  814.  
  815.  
  816. // Trend Candles //
  817. //UCS_Trend by ucsgears copy Trend Candles
  818. //Interpretation of TTM Trend bars. It is really close to the actual.
  819.  
  820. haclose = ohlc4
  821. haopen = 0.0
  822. haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2
  823. //hahigh = max(high, max(haopen, haclose))
  824. //halow = min(low, min(haopen, haclose))
  825.  
  826. ccolor = haclose - haopen > 0 ? 1 : 0
  827.  
  828. inside6 = haopen <= math.max(haopen[6], haclose[6]) and haopen >= math.min(haopen[6], haclose[6]) and haclose <= math.max(haopen[6], haclose[6]) and haclose >= math.min(haopen[6], haclose[6]) ? 1 : 0
  829.  
  830. inside5 = haopen <= math.max(haopen[5], haclose[5]) and haopen >= math.min(haopen[5], haclose[5]) and haclose <= math.max(haopen[5], haclose[5]) and haclose >= math.min(haopen[5], haclose[5]) ? 1 : 0
  831.  
  832. inside4 = haopen <= math.max(haopen[4], haclose[4]) and haopen >= math.min(haopen[4], haclose[4]) and haclose <= math.max(haopen[4], haclose[4]) and haclose >= math.min(haopen[4], haclose[4]) ? 1 : 0
  833.  
  834. inside3 = haopen <= math.max(haopen[3], haclose[3]) and haopen >= math.min(haopen[3], haclose[3]) and haclose <= math.max(haopen[3], haclose[3]) and haclose >= math.min(haopen[3], haclose[3]) ? 1 : 0
  835.  
  836. inside2 = haopen <= math.max(haopen[2], haclose[2]) and haopen >= math.min(haopen[2], haclose[2]) and haclose <= math.max(haopen[2], haclose[2]) and haclose >= math.min(haopen[2], haclose[2]) ? 1 : 0
  837.  
  838. inside1 = haopen <= math.max(haopen[1], haclose[1]) and haopen >= math.min(haopen[1], haclose[1]) and haclose <= math.max(haopen[1], haclose[1]) and haclose >= math.min(haopen[1], haclose[1]) ? 1 : 0
  839.  
  840.  
  841. colorvalue = inside6 ? ccolor[6] : inside5 ? ccolor[5] : inside4 ? ccolor[4] : inside3 ? ccolor[3] : inside2 ? ccolor[2] : inside1 ? ccolor[1] : ccolor
  842.  
  843. Trend_Candle_Color = colorvalue ? color.lime : color.red
  844.  
  845.  
  846. // Bar Color according to Trend Candles
  847.  
  848. barcolor(ShowTrendCandles ? Trend_Candle_Color : na, title='Trend Candles')
  849.  
  850.  
  851. // Alerts for Trend Candle Color Changes
  852.  
  853. Trend_Candle_Change_Green = colorvalue ? 1 : 0
  854.  
  855. Trend_Candle_Change_Red = colorvalue ? 0 : 1
  856.  
  857.  
  858. alertcondition(Trend_Candle_Change_Green, title='Alert - Trend Candle Color Change - GREEN', message='GREEN Trend Candles - Color Change')
  859.  
  860. alertcondition(Trend_Candle_Change_Red, title='Alert - Trend Candle Color Change - RED', message='RED Trend Candles - Color Change')
  861.  
  862. if Trend_Candle_Change_Green
  863. alert ('Trend Color change to Green on ' + timeframe.period + ' chart. Price is ' + str.tostring(close), alertMode)
  864.  
  865. if Trend_Candle_Change_Red
  866. alert ('Trend Color change to Red on ' + timeframe.period + ' chart. Price is ' + str.tostring(close), alertMode)
  867.  
  868.  
  869. /////////
  870.  
  871. TF1 = timeframe.period
  872. TF1_Menu = 'S/R Zones'
  873. TF1_VolMA1Input = 6
  874.  
  875.  
  876. // S/R - Current Time Frame = Time Frame 1 = TF1
  877.  
  878. TF1_Vol = request.security(syminfo.tickerid, TF1, volume)
  879. TF1_VolMA = ta.sma(TF1_Vol, TF1_VolMA1Input)
  880. TF1_High = request.security(syminfo.tickerid, TF1, high)
  881. TF1_Low = request.security(syminfo.tickerid, TF1, low)
  882. TF1_Open = request.security(syminfo.tickerid, TF1, open)
  883. TF1_Close = request.security(syminfo.tickerid, TF1, close)
  884.  
  885. TF1_Up = TF1_High[3] > TF1_High[4] and TF1_High[4] > TF1_High[5] and TF1_High[2] < TF1_High[3] and TF1_High[1] < TF1_High[2] and TF1_Vol[3] > TF1_VolMA[3] // or volume[3] > VolMA2Current[3])
  886. TF1_Down = TF1_Low[3] < TF1_Low[4] and TF1_Low[4] < TF1_Low[5] and TF1_Low[2] > TF1_Low[3] and TF1_Low[1] > TF1_Low[2] and TF1_Vol[3] > TF1_VolMA[3] // or volume[3] > VolMA2Current[3])
  887.  
  888.  
  889. TF1_CalcFractalUp() =>
  890. TF1_FractalUp = 0.0
  891. TF1_FractalUp := TF1_Up ? TF1_High[3] : TF1_FractalUp[1]
  892. TF1_FractalUp
  893.  
  894. TF1_CalcFractalDown() =>
  895. TF1_FractalDown = 0.0
  896. TF1_FractalDown := TF1_Down ? TF1_Low[3] : TF1_FractalDown[1]
  897. TF1_FractalDown
  898.  
  899.  
  900. TF1_FractalUp = request.security(syminfo.tickerid, TF1, TF1_CalcFractalUp())
  901. TF1_FractalDown = request.security(syminfo.tickerid, TF1, TF1_CalcFractalDown())
  902.  
  903.  
  904. // Zones - Current Time Frame = Time Frame 1 = TF1
  905.  
  906. // Fractal Up Zones
  907.  
  908. TF1_CalcFractalUpLowerZone() =>
  909. TF1_FractalUpLowerZone = 0.0
  910. TF1_FractalUpLowerZone := TF1_Up and TF1_Close[3] > TF1_Open[3] ? TF1_Close[3] : TF1_Up and TF1_Close[3] < TF1_Open[3] ? TF1_Open[3] : TF1_FractalUpLowerZone[1]
  911. TF1_FractalUpLowerZone
  912.  
  913. TF1_CalcFractalUpUpperZone() =>
  914. TF1_FractalUpUpperZone = 0.0
  915. TF1_FractalUpUpperZone := TF1_Up and TF1_Close[3] > TF1_Open[3] ? TF1_High[3] - TF1_Close[3] + TF1_High[3] : TF1_Up and TF1_Close[3] < TF1_Open[3] ? TF1_High[3] - TF1_Open[3] + TF1_High[3] : TF1_FractalUpUpperZone[1]
  916. TF1_FractalUpUpperZone
  917.  
  918.  
  919. TF1_FractalUpLowerZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalUpLowerZone())
  920. TF1_FractalUpUpperZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalUpUpperZone())
  921.  
  922. TF1_ResistanceUpperZone = TF1_FractalUpUpperZone
  923. TF1_ResistanceLowerZone = TF1_FractalUpLowerZone
  924.  
  925.  
  926. // Fractal Down Zones
  927.  
  928.  
  929. TF1_CalcFractalDownUpperZone() =>
  930. TF1_FractalDownUpperZone = 0.0
  931. TF1_FractalDownUpperZone := TF1_Down and TF1_Close[3] > TF1_Open[3] ? TF1_Open[3] : TF1_Down and TF1_Close[3] < TF1_Open[3] ? TF1_Close[3] : TF1_FractalDownUpperZone[1]
  932. TF1_FractalDownUpperZone
  933.  
  934.  
  935. TF1_CalcFractalDownLowerZone() =>
  936. TF1_FractalDownLowerZone = 0.0
  937. TF1_FractalDownLowerZone := TF1_Down and TF1_Close[3] > TF1_Open[3] ? TF1_Low[3] + TF1_Low[3] - TF1_Open[3] : TF1_Down and TF1_Close[3] < TF1_Open[3] ? TF1_Low[3] + TF1_Low[3] - TF1_Close[3] : TF1_FractalDownLowerZone[1]
  938. TF1_FractalDownLowerZone
  939.  
  940.  
  941. TF1_FractalDownLowerZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalDownLowerZone())
  942. TF1_FractalDownUpperZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalDownUpperZone())
  943.  
  944.  
  945. TF1_SupportUpperZone = TF1_FractalDownUpperZone
  946. TF1_SupportLowerZone = TF1_FractalDownLowerZone
  947.  
  948. // Colors - Current Time Frame = Time Frame 1 = TF1
  949.  
  950.  
  951. TF1_ResistanceColor = not InvertColors ? #FF00008C : #00FF00E6 // red : lime
  952. TF1_SupportColor = not InvertColors ? #00FF00E6 : #FF00008C // lime : red
  953.  
  954.  
  955. TF1_ResZoneColor = TF1_FractalUp != TF1_FractalUp[1] ? na : color.red
  956. TF1_ResZoneColorInverted = TF1_FractalUp != TF1_FractalUp[1] ? na : color.lime
  957.  
  958.  
  959. TF1_SupZoneColor = TF1_FractalDown != TF1_FractalDown[1] ? na : color.lime
  960. TF1_SupZoneColorInverted = TF1_FractalDown != TF1_FractalDown[1] ? na : color.red,
  961.  
  962.  
  963. TF1_ResistanceZonesColor = not InvertColors and TF1_Menu == 'S/R Zones' ? TF1_ResZoneColor : InvertColors and TF1_Menu == 'S/R Zones' ? TF1_ResZoneColorInverted : na // red : lime
  964. TF1_SupportZonesColor = not InvertColors and TF1_Menu == 'S/R Zones' ? TF1_SupZoneColor : InvertColors and TF1_Menu == 'S/R Zones' ? TF1_SupZoneColorInverted : na // lime : red
  965.  
  966.  
  967. // S/R & S/R Zone Plots - Current Time Frame = Time Frame 1 = TF1
  968.  
  969. TF1_ResistanceUpZone = plot(ShowSupResZones ? TF1_ResistanceUpperZone : na, 'Current Timeframe - Resistance - Upper Zone', color=TF1_ResistanceZonesColor, linewidth=1, style=plot.style_line, offset=-3, join=false, transp=45) // offset=-2
  970. TF1_ResistanceDownZone = plot(ShowSupResZones ? TF1_ResistanceLowerZone : na, 'Current Timeframe - Resistance - Lower Zone', color=TF1_ResistanceZonesColor, linewidth=1, style=plot.style_line, offset=-3, join=false, transp=45) // offset=-2
  971. fill(TF1_ResistanceUpZone, TF1_ResistanceDownZone, color=TF1_ResistanceZonesColor, title='Current Timeframe - Resistance Zone Shading', transp=93)
  972.  
  973.  
  974. plot(ShowSupResZones ? TF1_FractalUp : na, 'Current Timeframe - Resistance', color=TF1_ResistanceColor, linewidth=1, style=plot.style_circles, offset=-3, join=false, transp=5)
  975. plot(ShowSupResZones ? TF1_FractalDown : na, 'Current Timeframe - Support', color=TF1_SupportColor, linewidth=1, style=plot.style_circles, offset=-3, join=false, transp=5)
  976.  
  977.  
  978. TF1_SupportUpZone = plot(ShowSupResZones ? TF1_SupportUpperZone : na, 'Current Timeframe - Support - Uper Zone', color=TF1_SupportZonesColor, linewidth=1, style=plot.style_line, offset=-3, join=false, transp=45)
  979. TF1_SupportDownZone = plot(ShowSupResZones ? TF1_SupportLowerZone : na, 'Current Timeframe - Support - Lower Zone', color=TF1_SupportZonesColor, linewidth=1, style=plot.style_line, offset=-3, join=false, transp=45)
  980. fill(TF1_SupportUpZone, TF1_SupportDownZone, color=TF1_SupportZonesColor, title='Current Timeframe - Support Zone Shading', transp=93)
  981.  
  982.  
  983. // Alerts for Support / Resistance
  984.  
  985. SellAtResistance = low < TF1_FractalUp and open < TF1_FractalUp and high >= TF1_FractalUp and close < TF1_FractalUp ? 1 : 0
  986.  
  987. BuyAtSupport = high > TF1_FractalDown and open > TF1_FractalDown and low <= TF1_FractalDown and close > TF1_FractalDown ? 1 : 0
  988.  
  989.  
  990. alertcondition(SellAtResistance, title='Alert - Sell at Resistance', message='Alert - Sell at Resistance')
  991.  
  992. alertcondition(BuyAtSupport, title='Alert - Buy at Support', message='Alert - Buy at Support')
  993.  
  994. if SellAtResistance
  995. alert ('Alert - Sell at Resistance on ' + timeframe.period + ' chart. Price is ' + str.tostring(close), alertMode)
  996.  
  997. if BuyAtSupport
  998. alert ('Alert - Buy at Support ' + timeframe.period + ' chart. Price is ' + str.tostring(close), alertMode)
  999.  
  1000. /////////////////////////////////////////////////////
  1001.  
  1002. ///////////////////////////////////////////////////////
  1003.  
  1004. // User inputs
  1005. showTomorrowCPR = input(title='Show tomorrow\'s CPR', defval=true, group = 'CPR')
  1006. showHistoricalCPR = input(title='Show historical CPR', defval=false, group = 'CPR')
  1007. showR3S3 = input(title='Show R3 & S3', defval=false, group = 'CPR')
  1008.  
  1009.  
  1010. // Defaults
  1011. // CPR Colors
  1012. cprColor = color.yellow
  1013. rColor = color.fuchsia
  1014. sColor = color.aqua
  1015.  
  1016. // Line style & Transparency
  1017. lStyle = plot.style_line
  1018. lTransp = 35
  1019.  
  1020. //Fill Transparency
  1021. fTransp = 95
  1022.  
  1023.  
  1024. // Global Variables & Flags
  1025. // TODO : Update the No of Holidays
  1026. noOfHolidays = 12
  1027.  
  1028.  
  1029. // Global Functions
  1030. // TODO : Update the list of Holiday here in format YYYY, MM, DD, 09, 15
  1031. // **09, 15 are session start hour & minutes
  1032. IsHoliday(_date) =>
  1033. iff_1 = _date == timestamp(2020, 12, 25, 09, 15) ? true : false
  1034. iff_2 = _date == timestamp(2020, 11, 30, 09, 15) ? true : iff_1
  1035. iff_3 = _date == timestamp(2020, 11, 16, 09, 15) ? true : iff_2
  1036. iff_4 = _date == timestamp(2020, 10, 02, 09, 15) ? true : iff_3
  1037. iff_5 = _date == timestamp(2020, 05, 25, 09, 15) ? true : iff_4
  1038. iff_6 = _date == timestamp(2020, 05, 01, 09, 15) ? true : iff_5
  1039. iff_7 = _date == timestamp(2020, 04, 14, 09, 15) ? true : iff_6
  1040. iff_8 = _date == timestamp(2020, 04, 10, 09, 15) ? true : iff_7
  1041. iff_9 = _date == timestamp(2020, 04, 06, 09, 15) ? true : iff_8
  1042. iff_10 = _date == timestamp(2020, 04, 02, 09, 15) ? true : iff_9
  1043. iff_11 = _date == timestamp(2020, 03, 10, 09, 15) ? true : iff_10
  1044. _date == timestamp(2020, 02, 21, 09, 15) ? true : iff_11
  1045.  
  1046. // Note: Week of Sunday=1...Saturday=7
  1047. IsWeekend(_date) =>
  1048. dayofweek(_date) == 7 or dayofweek(_date) == 1
  1049.  
  1050. // Skip Weekend
  1051. SkipWeekend(_date) =>
  1052. _d = dayofweek(_date)
  1053. _mul = _d == 6 ? 3 : _d == 7 ? 2 : 1
  1054.  
  1055. _date + _mul * 86400000
  1056.  
  1057.  
  1058. // Get Next Working Day
  1059. GetNextWorkingDay(_date) =>
  1060. _dt = SkipWeekend(_date)
  1061.  
  1062. for i = 1 to noOfHolidays by 1
  1063. if IsHoliday(_dt)
  1064. _dt := SkipWeekend(_dt)
  1065. continue
  1066. else
  1067. break
  1068.  
  1069. _dt
  1070.  
  1071.  
  1072. // Today's Session Start timestamp
  1073. y = year(timenow)
  1074. m = month(timenow)
  1075. d = dayofmonth(timenow)
  1076.  
  1077. // Start & End time for Today's CPR
  1078. start = timestamp(y, m, d, 09, 15)
  1079. end = start + 86400000
  1080.  
  1081. // Plot Today's CPR
  1082. shouldPlotToday = timenow > start
  1083.  
  1084. tom_start = start
  1085. tom_end = end
  1086.  
  1087. // Start & End time for Tomorrow's CPR
  1088. if shouldPlotToday
  1089. tom_start := GetNextWorkingDay(start)
  1090. tom_end := tom_start + 86400000
  1091. tom_end
  1092.  
  1093.  
  1094. // Get series
  1095. getSeries(e, timeFrame) =>
  1096. request.security(syminfo.tickerid, 'D', e, lookahead=barmerge.lookahead_on)
  1097.  
  1098. // Calculate Today's CPR
  1099. //Get High, Low and Close
  1100. H = getSeries(high[1], 'D')
  1101. L = getSeries(low[1], 'D')
  1102. C = getSeries(close[1], 'D')
  1103.  
  1104. // Pivot Range
  1105. P = (H + L + C) / 3
  1106. TC = (H + L) / 2
  1107. BC = P - TC + P
  1108.  
  1109. // Resistance Levels
  1110. R3 = H + 2 * (P - L)
  1111. R2 = P + H - L
  1112. R1 = P * 2 - L
  1113.  
  1114. // Support Levels
  1115. S1 = P * 2 - H
  1116. S2 = P - (H - L)
  1117. S3 = L - 2 * (H - P)
  1118.  
  1119.  
  1120. // Plot Today's CPR
  1121. if not IsHoliday(start) and not IsWeekend(start) and shouldPlotToday
  1122. if showR3S3
  1123. _r3 = line.new(start, R3, end, R3, xloc.bar_time, color=color.new(rColor, lTransp))
  1124. line.delete(_r3[1])
  1125. _r2 = line.new(start, R2, end, R2, xloc.bar_time, color=color.new(rColor, lTransp))
  1126. line.delete(_r2[1])
  1127. _r1 = line.new(start, R1, end, R1, xloc.bar_time, color=color.new(rColor, lTransp))
  1128. line.delete(_r1[1])
  1129.  
  1130. _tc = line.new(start, TC, end, TC, xloc.bar_time, color=color.new(cprColor, lTransp))
  1131. line.delete(_tc[1])
  1132. _p = line.new(start, P, end, P, xloc.bar_time, color=color.new(cprColor, lTransp))
  1133. line.delete(_p[1])
  1134. _bc = line.new(start, BC, end, BC, xloc.bar_time, color=color.new(cprColor, lTransp))
  1135. line.delete(_bc[1])
  1136.  
  1137. _s1 = line.new(start, S1, end, S1, xloc.bar_time, color=color.new(sColor, lTransp))
  1138. line.delete(_s1[1])
  1139. _s2 = line.new(start, S2, end, S2, xloc.bar_time, color=color.new(sColor, lTransp))
  1140. line.delete(_s2[1])
  1141. if showR3S3
  1142. _s3 = line.new(start, S3, end, S3, xloc.bar_time, color=color.new(sColor, lTransp))
  1143. line.delete(_s3[1])
  1144.  
  1145. // Plot Today's Labels
  1146. if not IsHoliday(start) and not IsWeekend(start) and shouldPlotToday
  1147. if showR3S3
  1148. l_r3 = label.new(start, R3, text='CR3', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
  1149. label.delete(l_r3[1])
  1150. l_r2 = label.new(start, R2, text='CR2', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
  1151. label.delete(l_r2[1])
  1152. l_r1 = label.new(start, R1, text='CR1', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
  1153. label.delete(l_r1[1])
  1154.  
  1155. l_tc = label.new(start, TC, text='CTC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
  1156. label.delete(l_tc[1])
  1157. l_p = label.new(start, P, text='CP', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
  1158. label.delete(l_p[1])
  1159. l_bc = label.new(start, BC, text='CBC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
  1160. label.delete(l_bc[1])
  1161.  
  1162. l_s1 = label.new(start, S1, text='CS1', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
  1163. label.delete(l_s1[1])
  1164. l_s2 = label.new(start, S2, text='CS2', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
  1165. label.delete(l_s2[1])
  1166. if showR3S3
  1167. l_s3 = label.new(start, S3, text='CS3', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
  1168. label.delete(l_s3[1])
  1169.  
  1170.  
  1171. // Calculate Tomorrow's CPR
  1172. // Get High, Low and Close
  1173. tH = getSeries(high, 'D')
  1174. tL = getSeries(low, 'D')
  1175. tC = getSeries(close, 'D')
  1176.  
  1177. // Pivot Range
  1178. tP = (tH + tL + tC) / 3
  1179. tTC = (tH + tL) / 2
  1180. tBC = tP - tTC + tP
  1181.  
  1182. // Resistance Levels
  1183. tR3 = tH + 2 * (tP - tL)
  1184. tR2 = tP + tH - tL
  1185. tR1 = tP * 2 - tL
  1186.  
  1187. // Support Levels
  1188. tS1 = tP * 2 - tH
  1189. tS2 = tP - (tH - tL)
  1190. tS3 = tL - 2 * (tH - tP)
  1191.  
  1192. // Plot Tomorrow's CPR
  1193. if showTomorrowCPR
  1194. if showR3S3
  1195. _t_r3 = line.new(tom_start, tR3, tom_end, tR3, xloc.bar_time, color=color.new(rColor, lTransp))
  1196. line.delete(_t_r3[1])
  1197. _t_r2 = line.new(tom_start, tR2, tom_end, tR2, xloc.bar_time, color=color.new(rColor, lTransp))
  1198. line.delete(_t_r2[1])
  1199. _t_r1 = line.new(tom_start, tR1, tom_end, tR1, xloc.bar_time, color=color.new(rColor, lTransp))
  1200. line.delete(_t_r1[1])
  1201.  
  1202. _t_tc = line.new(tom_start, tTC, tom_end, tTC, xloc.bar_time, color=color.new(cprColor, lTransp))
  1203. line.delete(_t_tc[1])
  1204. _t_p = line.new(tom_start, tP, tom_end, tP, xloc.bar_time, color=color.new(cprColor, lTransp))
  1205. line.delete(_t_p[1])
  1206. _t_bc = line.new(tom_start, tBC, tom_end, tBC, xloc.bar_time, color=color.new(cprColor, lTransp))
  1207. line.delete(_t_bc[1])
  1208.  
  1209. _t_s1 = line.new(tom_start, tS1, tom_end, tS1, xloc.bar_time, color=color.new(sColor, lTransp))
  1210. line.delete(_t_s1[1])
  1211. _t_s2 = line.new(tom_start, tS2, tom_end, tS2, xloc.bar_time, color=color.new(sColor, lTransp))
  1212. line.delete(_t_s2[1])
  1213. if showR3S3
  1214. _t_s3 = line.new(tom_start, tS3, tom_end, tS3, xloc.bar_time, color=color.new(sColor, lTransp))
  1215. line.delete(_t_s3[1])
  1216.  
  1217. // Plot Tomorrow's Labels
  1218. if showTomorrowCPR
  1219. if showR3S3
  1220. l_t_r3 = label.new(tom_start, tR3, text='CR3', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
  1221. label.delete(l_t_r3[1])
  1222. l_t_r2 = label.new(tom_start, tR2, text='CR2', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
  1223. label.delete(l_t_r2[1])
  1224. l_t_r1 = label.new(tom_start, tR1, text='CR1', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
  1225. label.delete(l_t_r1[1])
  1226.  
  1227. l_t_tc = label.new(tom_start, tTC, text='CTC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
  1228. label.delete(l_t_tc[1])
  1229. l_t_p = label.new(tom_start, tP, text='CP', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
  1230. label.delete(l_t_p[1])
  1231. l_t_bc = label.new(tom_start, tBC, text='CBC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
  1232. label.delete(l_t_bc[1])
  1233.  
  1234. l_t_s1 = label.new(tom_start, tS1, text='CS1', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
  1235. label.delete(l_t_s1[1])
  1236. l_t_s2 = label.new(tom_start, tS2, text='CS2', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
  1237. label.delete(l_t_s2[1])
  1238. if showR3S3
  1239. l_t_s3 = label.new(tom_start, tS3, text='CS3', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
  1240. label.delete(l_t_s3[1])
  1241.  
  1242.  
  1243. //Plot Historical CPR
  1244. p_r3 = plot(showHistoricalCPR ? showR3S3 ? R3 : na : na, title=' CR3', color=rColor, style=lStyle, transp=lTransp)
  1245. p_r2 = plot(showHistoricalCPR ? R2 : na, title=' CR2', color=rColor, style=lStyle, transp=lTransp)
  1246. p_r1 = plot(showHistoricalCPR ? R1 : na, title=' CR1', color=rColor, style=lStyle, transp=lTransp)
  1247.  
  1248. p_cprTC = plot(showHistoricalCPR ? TC : na, title=' CTC', color=cprColor, style=lStyle, transp=lTransp)
  1249. p_cprP = plot(showHistoricalCPR ? P : na, title=' CP', color=cprColor, style=lStyle, transp=lTransp)
  1250. p_cprBC = plot(showHistoricalCPR ? BC : na, title=' CBC', color=cprColor, style=lStyle, transp=lTransp)
  1251.  
  1252. s1 = plot(showHistoricalCPR ? S1 : na, title=' CS1', color=sColor, style=lStyle, transp=lTransp)
  1253. s2 = plot(showHistoricalCPR ? S2 : na, title=' CS2', color=sColor, style=lStyle, transp=lTransp)
  1254. s3 = plot(showHistoricalCPR ? showR3S3 ? S3 : na : na, title=' CS3', color=sColor, style=lStyle, transp=lTransp)
  1255.  
  1256. fill(p_cprTC, p_cprBC, color=color.purple, transp=fTransp)
  1257.  
  1258. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1259.  
  1260. // RSI Settings for user
  1261. rsiSource = input(title='RSI Source', defval=close, group = 'Pivot High Low')
  1262. rsiLength = input(title='RSI Length', defval=7, group = 'Pivot High Low')
  1263. rsiOverbought = input.int(title='RSI Overbought', defval=70, minval=51, maxval=100)
  1264. rsiOvesold = input.int(title='RSI Oversold', defval=30, minval=1, maxval=49)
  1265.  
  1266. // RSI value based on inbuilt RSI H
  1267. rsiValue = ta.rsi(rsiSource, rsiLength)
  1268.  
  1269. // Get the current state
  1270. isOverbought = rsiValue >= rsiOverbought
  1271. isOversold = rsiValue <= rsiOvesold
  1272.  
  1273. // State of the last extreme 0 for initialization, 1 = overbought, 2 = oversold
  1274. var laststate = 0
  1275.  
  1276. // Highest and Lowest prices since the last state change
  1277. var hh = low
  1278. var ll = high
  1279.  
  1280. // Labels
  1281. var label labelll = na
  1282. var label labelhh = na
  1283.  
  1284. // Swing lines
  1285. var line line_up = na
  1286. var line line_down = na
  1287.  
  1288. var last_actual_label_hh_price = 0.0
  1289. var last_actual_label_ll_price = 0.0
  1290.  
  1291.  
  1292. // FUNCTIONS
  1293. obLabelText() =>
  1294. if last_actual_label_hh_price < high
  1295. 'HH'
  1296. else
  1297. 'LH'
  1298. //plot(last_actual_label_hh_price)
  1299. osLabelText() =>
  1300. if last_actual_label_ll_price < low
  1301. 'HL'
  1302. else
  1303. 'LL'
  1304.  
  1305. // Create oversold or overbought label
  1306. createOverBoughtLabel(isIt) =>
  1307. if isIt
  1308. label.new(x=bar_index, y=na, yloc=yloc.abovebar, style=label.style_label_down, color=color.red, size=size.tiny, text=obLabelText())
  1309. else
  1310. label.new(x=bar_index, y=na, yloc=yloc.belowbar, style=label.style_label_up, color=color.green, size=size.tiny, text=osLabelText())
  1311.  
  1312.  
  1313. // Move the oversold swing and label
  1314. moveOversoldLabel() =>
  1315. label.set_x(labelll, bar_index)
  1316. label.set_y(labelll, low)
  1317. label.set_text(labelll, osLabelText())
  1318. line.set_x1(line_down, bar_index)
  1319. line.set_y1(line_down, low)
  1320.  
  1321. moveOverBoughtLabel() =>
  1322. label.set_x(labelhh, bar_index)
  1323. label.set_y(labelhh, high)
  1324. label.set_text(labelhh, obLabelText())
  1325. line.set_x1(line_up, bar_index)
  1326. line.set_y1(line_up, high)
  1327.  
  1328. // We go from oversold straight to overbought NEW DRAWINGS CREATED HERE
  1329. if laststate == 2 and isOverbought
  1330. hh := high
  1331. labelhh := createOverBoughtLabel(true)
  1332. last_actual_label_ll_price := label.get_y(labelll)
  1333. labelll_ts = label.get_x(labelll)
  1334. labelll_price = label.get_y(labelll)
  1335. line_up := line.new(x1=bar_index, y1=high, x2=labelll_ts, y2=labelll_price, width=1)
  1336. line_up
  1337.  
  1338. // We go from overbought straight to oversold NEW DRAWINGS CREATED HERE
  1339. if laststate == 1 and isOversold
  1340. ll := low
  1341. labelll := createOverBoughtLabel(false)
  1342. last_actual_label_hh_price := label.get_y(labelhh)
  1343. labelhh_ts = label.get_x(labelhh)
  1344. labelhh_price = label.get_y(labelhh)
  1345. line_down := line.new(x1=bar_index, y1=high, x2=labelhh_ts, y2=labelhh_price, width=1)
  1346. line_down
  1347.  
  1348.  
  1349. // If we are overbought
  1350. if isOverbought
  1351. if high >= hh
  1352. hh := high
  1353. moveOverBoughtLabel()
  1354. laststate := 1
  1355. laststate
  1356.  
  1357. // If we are oversold
  1358. if isOversold
  1359. if low <= ll
  1360. ll := low
  1361. moveOversoldLabel()
  1362. laststate := 2
  1363. laststate
  1364.  
  1365.  
  1366. // If last state was overbought and we are overbought
  1367. if laststate == 1 and isOverbought
  1368. if hh <= high
  1369. hh := high
  1370. moveOverBoughtLabel()
  1371.  
  1372. //If we are oversold and the last state was oversold, move the drawings to the lowest price
  1373. if laststate == 2 and isOversold
  1374. if low <= ll
  1375. ll := low
  1376. moveOversoldLabel()
  1377.  
  1378.  
  1379. // If last state was overbought
  1380. if laststate == 1
  1381. if hh <= high
  1382. hh := high
  1383. moveOverBoughtLabel()
  1384.  
  1385. // If last stare was oversold
  1386. if laststate == 2
  1387. if ll >= low
  1388. ll := low
  1389. moveOversoldLabel()
  1390.  
  1391. //////////////////////////////////////////////////////FIB Retracement///////////////////////////////////////////////////////////
  1392. max_bars_back=5000
  1393.  
  1394.  
  1395. Fibs = input.string('OFF Fibs', options=['Plot Fibs based on Lookback', 'Plot Fibs based on Price Input', 'OFF Fibs'], title='Fibonacci Plot Type', group = 'Fib Retracement')
  1396.  
  1397. FIBS = Fibs == 'Plot Fibs based on Lookback' ? 1 : Fibs == 'Plot Fibs based on Price Input' ? 2 : Fibs== 'OFF Fibs' ? 3: na
  1398.  
  1399. Foption = input.string(defval='1. Candles', title='Fibonacci Plot Lookback Type', options=['2. Days', '1. Candles'], group = 'Fib Retracement')
  1400. FP = input(defval=100, title='Days/Candles to Lookback', group = 'Fib Retracement')
  1401. Reverse = input(defval=false, title='Reverse Fibonacci Levels?', group = 'Fib Retracement')
  1402. ExtraFibs = input(false, 'Show 0.886 and 1.113 Fibs')
  1403. Display= display.none
  1404.  
  1405. Note = input(true, '════ 𝗙𝗶𝗯𝘀 𝗯𝗮𝘀𝗲𝗱 𝗼𝗻 𝗣𝗿𝗶𝗰𝗲 𝗜𝗻𝗽𝘂𝘁 ════')
  1406. High = input.float(0., minval=0, title='High - Enter Value')
  1407. Low = input.float(-1., minval=-1, title='Low - Enter Value')
  1408.  
  1409.  
  1410. Note2 = input(true, '══════ 𝗙𝗶𝗯 𝗟𝗶𝗻𝗲/𝗟𝗮𝗯𝗲𝗹 𝗦𝘁𝘆𝗹𝗲 ══════')
  1411. Bull_Color = input(#008000, title='Support Fibs Color')
  1412. Bear_Color = input(#ff0000, title='Resistance Fibs Color')
  1413. CurrentFib = input(false, 'Show Fib Level of Current Price')
  1414. Current_Color = input(color.orange, title='Current Fib Label Color')
  1415. LineStyle = input.string('Dotted', options=['Dotted', 'Solid'], title='Fib Line Style')
  1416. LineWidth = input.int(1, minval=1, maxval=3, title='Fib Line Width')
  1417. Ext = input(false, 'Extend Lines Left')
  1418.  
  1419.  
  1420. // Transparency = input("Low", options = ["High", "Medium", "Low"], title="Fib Line Transparency")
  1421.  
  1422.  
  1423.  
  1424. BullColor = Bull_Color //Transparency == "High"?color.new(#008000,75):Transparency == "Medium"?color.new(#008000,50):Bull_Color
  1425. BearColor = Bear_Color //Transparency == "High"?color.new(#ff0000,75):Transparency == "Medium"?color.new(#ff0000,50):Bear_Color
  1426.  
  1427.  
  1428. FPeriod = timeframe.isintraday and Foption == '2. Days' ? 1440 / timeframe.multiplier * FP : timeframe.isdaily and Foption == '2. Days' ? FP / timeframe.multiplier : timeframe.isweekly and Foption == '2. Days' ? FP / (7 * timeframe.multiplier) : timeframe.ismonthly and Foption == '2. Days' ? FP / (28 * timeframe.multiplier) : Foption == '1. Candles' ? FP : 100
  1429.  
  1430.  
  1431. Fhigh = FIBS == 1 ? ta.highest(FPeriod) : FIBS == 2 and High == 0 ? ta.highest(high, 100) : FIBS == 2 and High != 0 ? High : na
  1432. Flow = FIBS == 1 ? ta.lowest(FPeriod) : FIBS == 2 and Low == -1 ? ta.lowest(low, 100) : FIBS == 2 and High != -1 ? Low : na
  1433. FH = FIBS == 1 ? ta.highestbars(high, FPeriod) : 1
  1434. FL = FIBS == 1 ? ta.lowestbars(low, FPeriod) : 2
  1435. revfibs = not Reverse ? FL > FH : FL < FH
  1436.  
  1437.  
  1438.  
  1439. Fib_x(n) =>
  1440. revfibs ? (Fhigh - Flow) * n + Flow : Fhigh - (Fhigh - Flow) * n
  1441.  
  1442. Current = revfibs ? (close - Flow) / (Fhigh - Flow) : (Fhigh - close) / (Fhigh - Flow)
  1443.  
  1444. var label Current_Fib_Label = na
  1445. label.delete(Current_Fib_Label)
  1446.  
  1447. if CurrentFib and barstate.islast
  1448. Current_Fib_Label := label.new(bar_index, close, str.tostring(Current, '##.##'), textcolor=Current_Color, color=color.new(#000000, 100), style=label.style_label_left, yloc=yloc.price)
  1449. Current_Fib_Label
  1450.  
  1451.  
  1452.  
  1453.  
  1454. EXTEND = Ext ? extend.left : extend.none
  1455. STYLE = LineStyle == 'Dotted' ? line.style_dotted : line.style_solid
  1456. WIDTH = LineWidth
  1457.  
  1458. BB = FIBS == 1 ? FL < FH ? bar_index[-FL] : bar_index[-FH] : FIBS == 2 ? bar_index[50] : bar_index[50]
  1459.  
  1460. Fib_line(x) =>
  1461. var line ln = na
  1462. line.delete(ln)
  1463. ln := line.new(BB, x, bar_index, x, color=close > x ? BullColor : BearColor, extend=EXTEND, style=STYLE, width=WIDTH)
  1464. ln
  1465.  
  1466.  
  1467.  
  1468. Fib_label(x, _txt) =>
  1469. var label lbl = na
  1470. label.delete(lbl)
  1471. lbl := label.new(bar_index, x, _txt + str.tostring(x, '##.########') + ' )', textcolor=close > x ? BullColor : BearColor, color=color.new(#000000, 100), style=label.style_label_left, yloc=yloc.price)
  1472. lbl
  1473.  
  1474.  
  1475.  
  1476. Fib0 = Fib_line(Fib_x(0))
  1477. Fib236 = Fib_line(Fib_x(0.236))
  1478. Fib382 = Fib_line(Fib_x(0.382))
  1479. Fib500 = Fib_line(Fib_x(0.500))
  1480. Fib618 = Fib_line(Fib_x(0.618))
  1481. Fib786 = Fib_line(Fib_x(0.786))
  1482. Fib1000 = Fib_line(Fib_x(1.000))
  1483.  
  1484. Fib886 = ExtraFibs ? Fib_line(Fib_x(0.886)) : na
  1485.  
  1486. if FIBS == 2
  1487.  
  1488. Fib1113 = ExtraFibs ? Fib_line(Fib_x(1.113)) : na
  1489.  
  1490. Fib1272 = Fib_line(Fib_x(1.272))
  1491. Fib1618 = Fib_line(Fib_x(1.618))
  1492. Fib2000 = Fib_line(Fib_x(2.000))
  1493. Fib2236 = Fib_line(Fib_x(2.236))
  1494. Fib2618 = Fib_line(Fib_x(2.618))
  1495. Fib3236 = Fib_line(Fib_x(3.236))
  1496. Fib3618 = Fib_line(Fib_x(3.618))
  1497. Fib4236 = Fib_line(Fib_x(4.236))
  1498. Fib4618 = Fib_line(Fib_x(4.618))
  1499. Fib4618
  1500.  
  1501.  
  1502. LFib0 = Fib_label(Fib_x(0), '0 ( ')
  1503. LFib236 = Fib_label(Fib_x(0.236), '0.236 ( ')
  1504. LFib382 = Fib_label(Fib_x(0.382), '0.382 ( ')
  1505. LFib500 = Fib_label(Fib_x(0.500), '0.500 ( ')
  1506. LFib618 = Fib_label(Fib_x(0.618), '0.618 ( ')
  1507. LFib786 = Fib_label(Fib_x(0.786), '0.786 ( ')
  1508. LFib1000 = Fib_label(Fib_x(1.000), '1.000 ( ')
  1509.  
  1510. LFib886 = ExtraFibs ? Fib_label(Fib_x(0.886), '0.886 ( ') : na
  1511.  
  1512.  
  1513. if FIBS == 2
  1514.  
  1515. LFib1113 = ExtraFibs ? Fib_label(Fib_x(1.113), '1.113 ( ') : na
  1516.  
  1517. LFib1272 = Fib_label(Fib_x(1.272), '1.272 ( ')
  1518. LFib1618 = Fib_label(Fib_x(1.618), '1.618 ( ')
  1519. LFib2000 = Fib_label(Fib_x(2.000), '2.000 ( ')
  1520. LFib2236 = Fib_label(Fib_x(2.236), '2.236 ( ')
  1521. LFib2618 = Fib_label(Fib_x(2.618), '2.618 ( ')
  1522. LFib3236 = Fib_label(Fib_x(3.236), '3.236 ( ')
  1523. LFib3618 = Fib_label(Fib_x(3.618), '3.618 ( ')
  1524. LFib4236 = Fib_label(Fib_x(4.236), '4.236 ( ')
  1525. LFib4618 = Fib_label(Fib_x(4.618), '4.618 ( ')
  1526. LFib4618
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
Advertisement
Comments
  • # text 0.12 KB | 0 0
    1. download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment