Advertisement
xmd79

SKB/KASPAROVABI Multi Indicator

May 18th, 2021
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.29 KB | None | 0 0
  1. // Multi Indicator by SKB & Kasparovabi
  2. // RSI Label by scarf
  3. // Pivot Prices by BacktestRookies
  4. // Volume-based S/R Levels by wugamlo
  5. // Monthly & Weekly Levels by scarf
  6. // ZigZag with Fibonacci Levels by LonesomeTheBlue
  7. // Engulfing Scanner v1 by TsanYouJun
  8. // Pivots High Low (HH/HL/LH/LL)/Trend by Mohamed3nan
  9.  
  10. //@version=4
  11. study(title="SKB/KASPAROVABI Multi Indicator", overlay=true)
  12.  
  13. srcrsi = close
  14. len = input(15, minval=1, title="RSI Length")
  15. show_ext = input(title="Show RSI Extremes", type=input.bool, defval=true)
  16. show_mid = input(title="Show RSI Mid Range", type=input.bool, defval=true)
  17. show_low = input(title="Show RSI Low Range", type=input.bool, defval=true)
  18. up = rma(max(change(srcrsi), 0), len)
  19. down = rma(-min(change(srcrsi), 0), len)
  20. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
  21.  
  22. //plotchar(rsi, char="", location=location.bottom)
  23.  
  24. rsi_high = rsi >= 70 or rsi[1] >= 70
  25. rsi_mid = rsi < 50 and rsi > 30
  26. rsi_low = rsi <= 30 or rsi[1] <= 30
  27.  
  28. plotshape(show_ext and rsi_high ? close : na, style=shape.triangledown, location=location.top, color=color.red, textcolor=color.new(color.gray, 0), text="H", transp=10, title="RSI High")
  29. plotshape(show_mid and rsi_mid ? close : na, style=shape.flag, location=location.absolute, color=color.red, textcolor=color.new(color.gray, 0), show_last=1, text="RSI Mid", offset=5, transp=80, title="RSI Mid")
  30. plotshape(show_low and rsi_low ? close : na, style=shape.triangleup, location=location.bottom, color=color.red, textcolor=color.new(color.gray, 0), text="L", offset=0, transp=80, title="RSI Low")
  31.  
  32.  
  33.  
  34.  
  35. offset_val = input(title="Monthly/Weekly Offset", type=input.integer, defval=25)
  36. showlabels = input(title="Monthly/Weekly", type=input.bool, defval=true)
  37.  
  38. monthH = security(syminfo.tickerid, 'M', high)[1]
  39. monthL = security(syminfo.tickerid, 'M', low)[1]
  40.  
  41. weekH = security(syminfo.tickerid, 'W', high)[1]
  42. weekL = security(syminfo.tickerid, 'W', low)[1]
  43.  
  44. plot(monthH, title="Monthly High Line", style=plot.style_line, linewidth=1, color=color.red, show_last=1, trackprice=true, offset=offset_val)
  45. plot(monthL, title="Monthly Low Line", style=plot.style_line, linewidth=1, color=color.red, show_last=1, trackprice=true, offset=offset_val)
  46.  
  47. plotshape(showlabels ? monthH : na, style=shape.labeldown, title="Monthly High", location=location.absolute, color=color.red, textcolor=color.new(color.white, 0), show_last=1, text="Month High", offset=offset_val, transp=20)
  48. plotshape(showlabels ? monthL : na, style=shape.labelup, title="Monthly Low", location=location.absolute, color=color.red, textcolor=color.new(color.white, 0), show_last=1, text="Month Low", offset=offset_val, transp=20)
  49.  
  50. plot(weekH, title="Weekly High Line", style=plot.style_line, linewidth=1, color=color.blue, show_last=1, trackprice=true, offset=offset_val)
  51. plot(weekL, title="Weekly Low Line", style=plot.style_line, linewidth=1, color=color.blue, show_last=1, trackprice=true, offset=offset_val)
  52.  
  53. plotshape(showlabels ? weekH : na, style=shape.labeldown, title="Weekly High", location=location.absolute, color=color.blue, textcolor=color.new(color.white, 0), show_last=1, text="Week High", offset=offset_val, transp=20)
  54. plotshape(showlabels ? weekL : na, style=shape.labelup, title="Weekly High", location=location.absolute, color=color.blue, textcolor=color.new(color.white, 0), show_last=1, text="Week Low", offset=offset_val, transp=20)
  55.  
  56. //support
  57.  
  58. volMALength = input(20, title = "STDDEV: Volume MA Length")
  59. stdevLength = input(20, title = "STDDEV: Length")
  60. stdevHigh = input(2.50, title = "STDDEV: Threshold High")
  61. stdevExtreme = input(3.00, title = "STDDEV: Threshold Extreme")
  62. wickminimum = input(75.00, title = "Minimum Wick Length [% of Body]")
  63. linelength = input(200, title = "Length of Lines (No of Candles)")
  64. colorstrength = input(title = "Line Color Intensity", defval="STRONG", options=["STRONG", "WEAK"])
  65. display = input(title = "Display Support/Resistance", defval="ALL", options=["RESISTANCE", "SUPPORT", "ALL"])
  66. display2 = input(title = "Display High/Extreme Volume", defval="ALL", options=["HIGH", "EXTREME", "ALL"])
  67. display3 = input(title = "Display WICK / WICK Range", defval="WICK", options=["RANGE", "WICK"])
  68. //signals = input(false, title = "Show Signal Triangles?")
  69.  
  70.  
  71. // Calculation
  72. volumeVal = volume
  73. volumeMA = sma(volumeVal, volMALength)
  74. stdevValue = stdev(volumeVal, stdevLength)
  75.  
  76. extremeVol = volumeMA + (stdevExtreme * stdevValue) // Extreme Volume Threshold
  77. highVol = volumeMA + (stdevHigh * stdevValue) // High Volume Threshold
  78.  
  79. bullcandle = close >= open
  80. bearcandle = close < open
  81.  
  82. bodylength = abs(open-close)
  83. wicklength = bearcandle? abs(low-close) : abs(high-close)
  84. wickratio = (wicklength / bodylength) * 100
  85.  
  86. rel_wick = wickratio >= wickminimum // Relevant Wick?
  87.  
  88. vol_above_limit1 = volumeVal > highVol and volumeVal < extremeVol and rel_wick
  89. vol_above_limit2 = volumeVal >= extremeVol and rel_wick
  90.  
  91. // Strong Colors
  92. Scol_green1 = color.new(color.green, 40) // Weak Green
  93. Scol_green2 = color.new(color.green, 10) // Strong Green
  94. Scol_red1 = color.new(color.red, 40) // Weak Red
  95. Scol_red2 = color.new(color.red, 10) // Strong Red
  96.  
  97. // Weak Colors
  98. Wcol_green1 = color.new(color.green, 80) // Weak Green
  99. Wcol_green2 = color.new(color.green, 50) // Strong Green
  100. Wcol_red1 = color.new(color.red, 80) // Weak Red
  101. Wcol_red2 = color.new(color.red, 50) // Strong Red
  102.  
  103. col_green1 = colorstrength == "STRONG"? Scol_green1 : Wcol_green1
  104. col_green2 = colorstrength == "STRONG"? Scol_green2 : Wcol_green2
  105. col_red1 = colorstrength == "STRONG"? Scol_red1 : Wcol_red1
  106. col_red2 = colorstrength == "STRONG"? Scol_red2 : Wcol_red2
  107.  
  108.  
  109. plotshape(vol_above_limit1 and bullcandle? close : na, title="Resistance - Volume above Threshold", style = shape.triangledown, location=location.abovebar, color=col_red2, size = size.tiny)
  110. plotshape(vol_above_limit2 and bullcandle? close : na, title="Resistance - Volume above Threshold x 2", style = shape.triangledown, location=location.abovebar, color=col_red1, size = size.tiny)
  111. plotshape(vol_above_limit1 and bearcandle? close : na, title="Support - Volume above Threshold", style = shape.triangleup, location=location.belowbar, color=col_green2, size = size.tiny)
  112. plotshape(vol_above_limit2 and bearcandle? close : na, title="Support - Volume above Threshold x 2", style = shape.triangleup, location=location.belowbar, color=col_green1, size = size.tiny)
  113.  
  114.  
  115. chper = time - time[1]
  116. chper := change(chper) > 0 ? chper[1] : chper
  117.  
  118.  
  119. if vol_above_limit1 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "HIGH") and display3 == "RANGE"
  120. bull1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 1)
  121. bull2 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 1)
  122. bull3 = line.new(time, (high+close)/2, time + chper * linelength, (high+close)/2, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 2)
  123. if vol_above_limit1 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "HIGH") and display3 == "WICK"
  124. bull4 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 2)
  125.  
  126.  
  127. if vol_above_limit2 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "RANGE"
  128. bull1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 1)
  129. bull2 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 1)
  130. bull3 = line.new(time, (high+close)/2, time + chper * linelength, (high+close)/2, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 2)
  131. if vol_above_limit2 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "WICK"
  132. bull4 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 2)
  133.  
  134.  
  135. if vol_above_limit1 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "HIGH") and display3 == "RANGE"
  136. bear1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 1)
  137. bear2 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 1)
  138. bear3 = line.new(time, (low+close)/2, time + chper * linelength, (low+close)/2, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 2)
  139. if vol_above_limit1 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "HIGH") and display3 == "WICK"
  140. bear4 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 2)
  141.  
  142. if vol_above_limit2 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "RANGE"
  143. bear1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 1)
  144. bear2 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 1)
  145. bear3 = line.new(time, (low+close)/2, time + chper * linelength, (low+close)/2, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 2)
  146. if vol_above_limit2 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "WICK"
  147. bear4 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 2)
  148.  
  149.  
  150.  
  151.  
  152.  
  153. //------------------------------------------------------------------------------||
  154.  
  155.  
  156.  
  157. leftbars = input(50, minval=1, title='High Price')
  158. rightbars = input(25, minval=1, title='Low Price')
  159.  
  160. phigh = pivothigh(high, leftbars, rightbars)
  161. plow = pivotlow(low, leftbars, rightbars)
  162.  
  163. if phigh
  164. label1 = label.new(bar_index[rightbars], high[rightbars], text=tostring(high[rightbars]), style=label.style_labeldown, color=color.orange)
  165.  
  166. if plow
  167. label2 = label.new(bar_index[rightbars], low[rightbars], text=tostring(low[rightbars]), style=label.style_labelup, color=color.green)
  168.  
  169. //////////////////
  170.  
  171.  
  172.  
  173.  
  174. prd = input(defval = 15, title="ZigZag Period", minval = 2, maxval = 50)
  175. showzigzag = input(defval = false, title = "Show Zig Zag")
  176. showfibo = input(defval = false, title = "Show Fibonacci Ratios")
  177. labelcol = input(defval = color.blue, title = "Fibonacci Text Color")
  178. fibolinecol = input(defval = color.lime, title = "Fibonacci Line Color")
  179. upcol = input(defval = color.lime, title = "Zigzag Up Color")
  180. dncol = input(defval = color.red, title = "Zigzag Down Color")
  181. labelloc = input(defval = "Right", title = "Fibonacci Location", options = ["Left", "Right"])
  182. enable14 = input(defval = true, title = "Enable Level 0.14")
  183. enable236 = input(defval = true, title = "Enable Level 0.236")
  184. enable382 = input(defval = true, title = "Enable Level 0.382")
  185. enable500 = input(defval = true, title = "Enable Level 0.500")
  186. enable618 = input(defval = true, title = "Enable Level 0.618")
  187. enable786 = input(defval = true, title = "Enable Level 0.786")
  188.  
  189. var fibo_ratios = array.new_float(0)
  190. var shownlevels = 1
  191. if barstate.isfirst
  192. array.push(fibo_ratios, 0.000)
  193. if enable14
  194. array.push(fibo_ratios, 0.14)
  195. shownlevels := shownlevels + 1
  196. if enable236
  197. array.push(fibo_ratios, 0.236)
  198. shownlevels := shownlevels + 1
  199. if enable382
  200. array.push(fibo_ratios, 0.382)
  201. shownlevels := shownlevels + 1
  202. if enable500
  203. array.push(fibo_ratios, 0.500)
  204. shownlevels := shownlevels + 1
  205. if enable618
  206. array.push(fibo_ratios, 0.618)
  207. shownlevels := shownlevels + 1
  208. if enable786
  209. array.push(fibo_ratios, 0.786)
  210. shownlevels := shownlevels + 1
  211. for x = 1 to 5
  212. array.push(fibo_ratios, x)
  213. array.push(fibo_ratios, x + 0.272)
  214. array.push(fibo_ratios, x + 0.414)
  215. array.push(fibo_ratios, x + 0.618)
  216.  
  217. float ph = highestbars(high, prd) == 0 ? high : na
  218. float pl = lowestbars(low, prd) == 0 ? low : na
  219. var dir = 0
  220. dir := iff(ph and na(pl), 1, iff(pl and na(ph), -1, dir))
  221. var max_array_size = 10
  222. var zigzag = array.new_float(0)
  223.  
  224. add_to_zigzag(value, bindex)=>
  225. array.unshift(zigzag, bindex)
  226. array.unshift(zigzag, value)
  227. if array.size(zigzag) > max_array_size
  228. array.pop(zigzag)
  229. array.pop(zigzag)
  230.  
  231. update_zigzag(value, bindex)=>
  232. if array.size(zigzag) == 0
  233. add_to_zigzag(value, bindex)
  234. else
  235. if (dir == 1 and value > array.get(zigzag, 0)) or (dir == -1 and value < array.get(zigzag, 0))
  236. array.set(zigzag, 0, value)
  237. array.set(zigzag, 1, bindex)
  238. 0.
  239. Round_it(value)=> round(value / syminfo.mintick) * syminfo.mintick
  240.  
  241. dirchanged = change(dir)
  242. if ph or pl
  243. if dirchanged
  244. add_to_zigzag(dir == 1 ? ph : pl, bar_index)
  245. else
  246. update_zigzag(dir == 1 ? ph : pl, bar_index)
  247.  
  248. if showzigzag and array.size(zigzag) >= 4
  249. var line zzline = na
  250. float val = array.get(zigzag, 0)
  251. int point = round(array.get(zigzag, 1))
  252. if change(val) or change(point)
  253. float val1 = array.get(zigzag, 2)
  254. int point1 = round(array.get(zigzag, 3))
  255. if change(val1) == 0 and change(point1) == 0
  256. line.delete(zzline)
  257. zzline := line.new(x1 = point, y1 = val, x2 = point1, y2 = val1, color = dir == 1 ? upcol : dncol, width = 2)
  258.  
  259. var fibolines = array.new_line(0)
  260. var fibolabels = array.new_label(0)
  261. if showfibo and array.size(zigzag) >= 6 and barstate.islast
  262. if array.size(fibolines) > 0
  263. for x = 0 to array.size(fibolines) - 1
  264. line.delete(array.get(fibolines, x))
  265. label.delete(array.get(fibolabels, x))
  266.  
  267. diff = array.get(zigzag, 4) - array.get(zigzag, 2)
  268. stopit = false
  269. for x = 0 to array.size(fibo_ratios) - 1
  270. if stopit and x > shownlevels
  271. break
  272. array.unshift(fibolines,
  273. line.new(x1 = round(array.get(zigzag, 5)),
  274. y1 = array.get(zigzag, 2) + diff * array.get(fibo_ratios, x),
  275. x2 = bar_index,
  276. y2 = array.get(zigzag, 2) + diff * array.get(fibo_ratios, x),
  277. color = fibolinecol,
  278. extend = extend.right))
  279. label_x_loc = labelloc == "Left" ? time[bar_index - (round(array.get(zigzag, 5)) - 1)] : time + 15 * (time - time[1])
  280. array.unshift(fibolabels,
  281. label.new( x = label_x_loc,
  282. y = array.get(zigzag, 2) + diff * array.get(fibo_ratios, x),
  283. text = tostring(array.get(fibo_ratios, x), '#.###') + "(" + tostring(Round_it(array.get(zigzag, 2) + diff * array.get(fibo_ratios, x))) + ")",
  284. xloc = xloc.bar_time,
  285. textcolor = labelcol,
  286. style = label.style_none))
  287. if (dir == 1 and array.get(zigzag, 2) + diff * array.get(fibo_ratios, x) > array.get(zigzag, 0)) or
  288. (dir == -1 and array.get(zigzag, 2) + diff * array.get(fibo_ratios, x) < array.get(zigzag, 0))
  289. stopit := true
  290.  
  291.  
  292.  
  293. bullEnHeight = input(title="BullEn, Height (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=10, confirm=false)
  294. bullEnAbove = input(title="BullEn Above (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=3, confirm=false)
  295. bullEnBelow = input(title="BullEn, Below (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=1, confirm=false)
  296.  
  297. bearEnHeight = input(title="BearEn, Height (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=10, confirm=false)
  298. bearEnAbove = input(title="BearEn Above (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=3, confirm=false)
  299. bearEnBelow = input(title="BearEn, Below (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=1, confirm=false)
  300.  
  301. //bullish engulfing
  302. bullEngulfing = (open[1] - close[1]) / syminfo.mintick >= bullEnHeight and close > open and
  303. (close - open[1]) / syminfo.mintick >= bullEnAbove and
  304. (close[1] - open) / syminfo.mintick >= bullEnBelow
  305.  
  306. //bearish candle
  307. bearEngulfing = (close[1] - open[1]) / syminfo.mintick >= bearEnHeight and close < open and
  308. (open - close[1]) / syminfo.mintick >= bearEnAbove and
  309. (open[1] - close) / syminfo.mintick >= bearEnBelow
  310.  
  311. //add long here
  312. plotshape(bullEngulfing, style=shape.cross, location=location.abovebar, color=color.green, text='', title="bullEngulfing", offset=-1)
  313.  
  314. //close all longs
  315. plotshape(bearEngulfing, style=shape.xcross, location=location.belowbar, color=color.red, text='', title="bearEngulfing", offset=-1)
  316.  
  317.  
  318. //HH/HL/LH/LL
  319.  
  320.  
  321.  
  322. // - INPUTS
  323. ShowPivots = input(true, title="Show Pivot Points")
  324. ShowHHLL = input(true, title="Show HH,LL,LH,HL markers on Pivots Points")
  325. lefthh = input(5, minval=1, title="Pivot Length lefthh Hand Side")
  326. righthh = input(5, minval=1, title="Pivot Length righthh Hand Side")
  327. ShowSRLevels = input(true, title="Show S/R Level Extensions")
  328. maxLvlLen = input(0, minval=0, title="Maximum S/R Level Extension Length (0 = Max)")
  329.  
  330. //
  331. ShowFB = input(true, title="Show Buy/Sell Signal")
  332.  
  333.  
  334. // Determine pivots
  335. pvtLenL = lefthh
  336. pvtLenR = righthh
  337.  
  338. // Get High and Low Pivot Points
  339. pvthi_ = pivothigh(high, pvtLenL, pvtLenR)
  340. pvtlo_ = pivotlow(low, pvtLenL, pvtLenR)
  341.  
  342. // Force Pivot completion before plotting.
  343. pvthi = pvthi_
  344. pvtlo = pvtlo_
  345.  
  346. // ||-----------------------------------------------------------------------------------------------------||
  347. // ||--- Higher Highs, Lower Highs, Higher Lows, Lower Lows -------------------------------------------||
  348. valuewhen_1 = valuewhen(pvthi, high[pvtLenR], 1)
  349. valuewhen_2 = valuewhen(pvthi, high[pvtLenR], 0)
  350. higherhigh = na(pvthi) ? na : valuewhen_1 < valuewhen_2 ? pvthi : na
  351. valuewhen_3 = valuewhen(pvthi, high[pvtLenR], 1)
  352. valuewhen_4 = valuewhen(pvthi, high[pvtLenR], 0)
  353. lowerhigh = na(pvthi) ? na : valuewhen_3 > valuewhen_4 ? pvthi : na
  354. valuewhen_5 = valuewhen(pvtlo, low[pvtLenR], 1)
  355. valuewhen_6 = valuewhen(pvtlo, low[pvtLenR ], 0)
  356. higherlow = na(pvtlo) ? na : valuewhen_5 < valuewhen_6 ? pvtlo : na
  357. valuewhen_7 = valuewhen(pvtlo, low[pvtLenR], 1)
  358. valuewhen_8 = valuewhen(pvtlo, low[pvtLenR ], 0)
  359. lowerlow = na(pvtlo) ? na : valuewhen_7 > valuewhen_8 ? pvtlo : na
  360.  
  361.  
  362. // If selected Display the HH/LL above/below candle.
  363. plotshape(ShowHHLL ? higherhigh : na, title='HH', style=shape.triangledown, location=location.abovebar, color=color.new(color.green,50), text="HH", offset=-pvtLenR)
  364. plotshape(ShowHHLL ? higherlow : na, title='HL', style=shape.triangleup, location=location.belowbar, color=color.new(color.green,50), text="HL", offset=-pvtLenR)
  365. plotshape(ShowHHLL ? lowerhigh : na, title='LH', style=shape.triangledown, location=location.abovebar, color=color.new(color.red,50), text="LH", offset=-pvtLenR)
  366. plotshape(ShowHHLL ? lowerlow : na, title='LL', style=shape.triangleup, location=location.belowbar, color=color.new(color.red,50), text="LL", offset=-pvtLenR)
  367.  
  368.  
  369. plot(ShowPivots and not ShowHHLL ? pvthi : na, title='High Pivot', style=plot.style_circles, join=false, color=color.green, offset=-pvtLenR, linewidth=3)
  370. plot(ShowPivots and not ShowHHLL ? pvtlo : na, title='Low Pivot', style=plot.style_circles, join=false, color=color.red, offset=-pvtLenR, linewidth=3)
  371.  
  372. //Count How many candles for current Pivot Level, If new reset.
  373. counthi = 0
  374. countlo = 0
  375. counthi := na(pvthi) ? nz(counthi[1]) + 1 : 0
  376. countlo := na(pvtlo) ? nz(countlo[1]) + 1 : 0
  377.  
  378. pvthis = 0.0
  379. pvtlos = 0.0
  380. pvthis := na(pvthi) ? pvthis[1] : high[pvtLenR]
  381. pvtlos := na(pvtlo) ? pvtlos[1] : low[pvtLenR]
  382.  
  383. hipc = pvthis != pvthis[1] ? na : color.new(color.red,50)
  384. lopc = pvtlos != pvtlos[1] ? na : color.new(color.green,50)
  385.  
  386.  
  387. // // Add Optional Fractal Break Alerts
  388. buy = false
  389. sell = false
  390. buy := close>pvthis and open<=pvthis
  391. sell := close<pvtlos and open>=pvtlos
  392.  
  393. // //
  394. plotshape(ShowFB and buy?1:na, title="BUY Signal", color=color.green, style=shape.diamond,location =location.belowbar)
  395. plotshape(ShowFB and sell?-1:na, title="SELL Signal", color=color.red, style=shape.diamond,location =location.abovebar)
  396. // Alerts//
  397.  
  398. alertcondition(buy or sell,title="Fractal Break Arrow",message="Alert")
  399. alertcondition(buy,title="Fractal Break Long",message="Long")
  400. alertcondition(sell,title="Fractal Break Short",message="Short")
  401.  
  402.  
  403.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement