Advertisement
mody21221

Untitled

Apr 1st, 2024
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TypeScript 20.62 KB | Source Code | 0 0
  1. //@version=5
  2.  
  3. // Chandelier Exit script may be freely distributed under the terms of the GPL-3.0 license.
  4. indicator('Chandelier Exit', shorttitle='CE', overlay=true, max_bars_back=500, max_lines_count=400, precision=4, max_labels_count=500)
  5.  
  6. length1 = input(title='ATR Period', defval=22)
  7. mult = input.float(title='ATR Multiplier', step=0.1, defval=3.0)
  8. showLabels = input(title='Show Buy/Sell Labels ?', defval=true)
  9. useClose = input(title='Use Close Price for Extremums ?', defval=true)
  10. highlightState = input(title='Highlight State ?', defval=true)
  11.  
  12. atr = mult * ta.atr(length1)
  13.  
  14. longStop = (useClose ? ta.highest(close, length1) : ta.highest(length1)) - atr
  15. longStopPrev = nz(longStop[1], longStop)
  16. longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop
  17.  
  18. shortStop = (useClose ? ta.lowest(close, length1) : ta.lowest(length1)) + atr
  19. shortStopPrev = nz(shortStop[1], shortStop)
  20. shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
  21.  
  22. var int dir = 1
  23. dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir
  24.  
  25. var color longColor = color.green
  26. var color shortColor = color.red
  27.  
  28. longStopPlot = plot(dir == 1 ? longStop : na, title='Long Stop', style=plot.style_linebr, linewidth=2, color=color.new(longColor, 0))
  29. buySignal = dir == 1 and dir[1] == -1
  30. plotshape(buySignal ? longStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(longColor, 0))
  31. plotshape(buySignal and showLabels ? longStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=color.new(color.white, 0))
  32.  
  33. shortStopPlot = plot(dir == 1 ? na : shortStop, title='Short Stop', style=plot.style_linebr, linewidth=2, color=color.new(shortColor, 0))
  34. sellSignal = dir == -1 and dir[1] == 1
  35. plotshape(sellSignal ? shortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(shortColor, 0))
  36. plotshape(sellSignal and showLabels ? shortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=color.new(color.white, 0))
  37.  
  38. midPricePlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false)
  39.  
  40. longFillColor = highlightState ? dir == 1 ? longColor : na : na
  41. shortFillColor = highlightState ? dir == -1 ? shortColor : na : na
  42. fill(midPricePlot, longStopPlot, title='Long State Filling', color=longFillColor, transp=90)
  43. fill(midPricePlot, shortStopPlot, title='Short State Filling', color=shortFillColor, transp=90)
  44.  
  45. changeCond = dir != dir[1]
  46. alertcondition(changeCond, title='Alert: CE Direction Change', message='Chandelier Exit has changed direction!')
  47. alertcondition(buySignal, title='Alert: CE Buy', message='Chandelier Exit Buy!')
  48. alertcondition(sellSignal, title='Alert: CE Sell', message='Chandelier Exit Sell!')
  49. //*****************************************************************************************************************************************************
  50. //ema
  51. //********
  52. shortest = ta.ema(close, 20)
  53. short = ta.ema(close, 50)
  54. longer = ta.ema(close, 100)
  55. longest = ta.ema(close, 200)
  56.  
  57. plot(shortest, color=color.new(color.red, 0))
  58. plot(short, color=color.new(color.orange, 0))
  59. plot(longer, color=color.new(color.aqua, 0))
  60. plot(longest, color=color.new(color.white, 0))
  61.  
  62. //**************************************************************************************
  63. //dynamic risistance and support
  64. //***********************************
  65. prd = input.int(defval=10, title='Pivot Period', minval=4, maxval=30, group='Setup')
  66. ppsrc = input.string(defval='High/Low', title='Source', options=['High/Low', 'Close/Open'], group='Setup')
  67. maxnumpp = input.int(defval=20, title=' Maximum Number of Pivot', minval=5, maxval=100, group='Setup')
  68. ChannelW = input.int(defval=10, title='Maximum Channel Width %', minval=1, group='Setup')
  69. maxnumsr = input.int(defval=5, title=' Maximum Number of S/R', minval=1, maxval=10, group='Setup')
  70. min_strength = input.int(defval=2, title=' Minimum Strength', minval=1, maxval=10, group='Setup')
  71. labelloc = input.int(defval=20, title='Label Location', group='Colors', tooltip='Positive numbers reference future bars, negative numbers reference histical bars')
  72. linestyle = input.string(defval='Dashed', title='Line Style', options=['Solid', 'Dotted', 'Dashed'], group='Colors')
  73. linewidth = input.int(defval=2, title='Line Width', minval=1, maxval=4, group='Colors')
  74. resistancecolor = input.color(defval=color.red, title='Resistance Color', group='Colors')
  75. supportcolor = input.color(defval=color.lime, title='Support Color', group='Colors')
  76. showpp = input(false, title='Show Point Points')
  77.  
  78. float src1 = ppsrc == 'High/Low' ? high : math.max(close, open)
  79. float src2 = ppsrc == 'High/Low' ? low : math.min(close, open)
  80. float ph2 = ta.pivothigh(src1, prd, prd)
  81. float pl2 = ta.pivotlow(src2, prd, prd)
  82.  
  83. plotshape(ph2 and showpp, text='H', style=shape.labeldown, color=na, textcolor=color.new(color.red, 0), location=location.abovebar, offset=-prd)
  84. plotshape(pl2 and showpp, text='L', style=shape.labelup, color=na, textcolor=color.new(color.lime, 0), location=location.belowbar, offset=-prd)
  85.  
  86. Lstyle = linestyle == 'Dashed' ? line.style_dashed : linestyle == 'Solid' ? line.style_solid : line.style_dotted
  87.  
  88. //calculate maximum S/R channel zone width
  89. prdhighest = ta.highest(300)
  90. prdlowest = ta.lowest(300)
  91. cwidth = (prdhighest - prdlowest) * ChannelW / 100
  92.  
  93. var pivotvals = array.new_float(0)
  94.  
  95. if ph2 or pl2
  96.     array.unshift(pivotvals, ph2 ? ph2 : pl2)
  97.     if array.size(pivotvals) > maxnumpp  // limit the array size
  98.         array.pop(pivotvals)
  99.  
  100. get_sr_vals(ind) =>
  101.     float lo = array.get(pivotvals, ind)
  102.     float hi = lo
  103.     int numpp = 0
  104.     for y = 0 to array.size(pivotvals) - 1 by 1
  105.         float cpp = array.get(pivotvals, y)
  106.         float wdth = cpp <= lo ? hi - cpp : cpp - lo
  107.         if wdth <= cwidth  // fits the max channel width?
  108.             lo := cpp <= lo ? cpp : lo
  109.             hi := cpp > lo ? cpp : hi
  110.             numpp += 1
  111.             numpp
  112.     [hi, lo, numpp]
  113.  
  114. var sr_up_level = array.new_float(0)
  115. var sr_dn_level = array.new_float(0)
  116. sr_strength = array.new_float(0)
  117.  
  118. find_loc(strength) =>
  119.     ret = array.size(sr_strength)
  120.     for i = ret > 0 ? array.size(sr_strength) - 1 : na to 0 by 1
  121.         if strength <= array.get(sr_strength, i)
  122.             break
  123.         ret := i
  124.         ret
  125.     ret
  126.  
  127. check_sr(hi, lo, strength) =>
  128.     ret = true
  129.     for i = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
  130.         //included?
  131.         if array.get(sr_up_level, i) >= lo and array.get(sr_up_level, i) <= hi or array.get(sr_dn_level, i) >= lo and array.get(sr_dn_level, i) <= hi
  132.             if strength >= array.get(sr_strength, i)
  133.                 array.remove(sr_strength, i)
  134.                 array.remove(sr_up_level, i)
  135.                 array.remove(sr_dn_level, i)
  136.                 ret
  137.             else
  138.                 ret := false
  139.                 ret
  140.             break
  141.     ret
  142.  
  143. var sr_lines = array.new_line(11, na)
  144. var sr_labels = array.new_label(11, na)
  145.  
  146. for x = 1 to 10 by 1
  147.     rate = 100 * (label.get_y(array.get(sr_labels, x)) - close) / close
  148.     label.set_text(array.get(sr_labels, x), text=str.tostring(label.get_y(array.get(sr_labels, x))) + '(' + str.tostring(rate, '#.##') + '%)')
  149.     label.set_x(array.get(sr_labels, x), x=bar_index + labelloc)
  150.     label.set_color(array.get(sr_labels, x), color=label.get_y(array.get(sr_labels, x)) >= close ? color.red : color.lime)
  151.     label.set_textcolor(array.get(sr_labels, x), textcolor=label.get_y(array.get(sr_labels, x)) >= close ? color.white : color.black)
  152.     label.set_style(array.get(sr_labels, x), style=label.get_y(array.get(sr_labels, x)) >= close ? label.style_label_down : label.style_label_up)
  153.     line.set_color(array.get(sr_lines, x), color=line.get_y1(array.get(sr_lines, x)) >= close ? resistancecolor : supportcolor)
  154.  
  155. if ph2 or pl2
  156.     //because of new calculation, remove old S/R levels
  157.     array.clear(sr_up_level)
  158.     array.clear(sr_dn_level)
  159.     array.clear(sr_strength)
  160.     //find S/R zones
  161.     for x = 0 to array.size(pivotvals) - 1 by 1
  162.         [hi, lo, strength] = get_sr_vals(x)
  163.         if check_sr(hi, lo, strength)
  164.             loc = find_loc(strength)
  165.             // if strength is in first maxnumsr sr then insert it to the arrays
  166.             if loc < maxnumsr and strength >= min_strength
  167.                 array.insert(sr_strength, loc, strength)
  168.                 array.insert(sr_up_level, loc, hi)
  169.                 array.insert(sr_dn_level, loc, lo)
  170.                 // keep size of the arrays = 5
  171.                 if array.size(sr_strength) > maxnumsr
  172.                     array.pop(sr_strength)
  173.                     array.pop(sr_up_level)
  174.                     array.pop(sr_dn_level)
  175.  
  176.     for x = 1 to 10 by 1
  177.         line.delete(array.get(sr_lines, x))
  178.         label.delete(array.get(sr_labels, x))
  179.  
  180.     for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
  181.         float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
  182.         rate = 100 * (mid - close) / close
  183.         array.set(sr_labels, x + 1, label.new(x=bar_index + labelloc, y=mid, text=str.tostring(mid) + '(' + str.tostring(rate, '#.##') + '%)', color=mid >= close ? color.red : color.lime, textcolor=mid >= close ? color.white : color.black, style=mid >= close ? label.style_label_down : label.style_label_up))
  184.  
  185.         array.set(sr_lines, x + 1, line.new(x1=bar_index, y1=mid, x2=bar_index - 1, y2=mid, extend=extend.both, color=mid >= close ? resistancecolor : supportcolor, style=Lstyle, width=linewidth))
  186.  
  187. f_crossed_over() =>
  188.     ret = false
  189.     for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
  190.         float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
  191.         if close[1] <= mid and close > mid
  192.             ret := true
  193.             ret
  194.     ret
  195.  
  196. f_crossed_under() =>
  197.     ret = false
  198.     for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
  199.         float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
  200.         if close[1] >= mid and close < mid
  201.             ret := true
  202.             ret
  203.     ret
  204.  
  205. alertcondition(f_crossed_over(), title='Resistance Broken', message='Resistance Broken')
  206. alertcondition(f_crossed_under(), title='Support Broken', message='Support Broken')
  207.  
  208. //**************************************************************************************************
  209.  
  210. length = input.int(14)
  211. k      = input.float(1.,'Slope',minval=0,step=.1)
  212. method = input.string('Atr','Slope Calculation Method',
  213.   options=['Atr','Stdev','Linreg'])
  214. show   = input(false,'Show Only Confirmed Breakouts')
  215. //----
  216. upper = 0.,lower = 0.
  217. slope_ph = 0.,slope_pl = 0.
  218. src = close
  219. n = bar_index
  220. //----
  221. ph = ta.pivothigh(length,length)
  222. pl = ta.pivotlow(length,length)
  223. slope = switch method
  224.     'Atr'      => ta.atr(length)/length*k
  225.     'Stdev'    => ta.stdev(src,length)/length*k
  226.     'Linreg'   => math.abs(ta.sma(src*bar_index,length)-ta.sma(src,length)*ta.sma(bar_index,length))/ta.variance(n,length)/2*k
  227.  
  228. slope_ph := ph ? slope : slope_ph[1]
  229. slope_pl := pl ? slope : slope_pl[1]
  230.  
  231. upper := ph ? ph : upper[1] - slope_ph
  232. lower := pl ? pl : lower[1] + slope_pl
  233. //----
  234. single_upper = 0
  235. single_lower = 0
  236. single_upper := src[length] > upper ? 0 : ph ? 1 : single_upper[1]
  237. single_lower := src[length] < lower ? 0 : pl ? 1 : single_lower[1]
  238. upper_breakout = single_upper[1] and src[length] > upper and (show ? src > src[length] : 1)
  239. lower_breakout = single_lower[1] and src[length] < lower and (show ? src < src[length] : 1)
  240. plotshape(upper_breakout ? low[length] : na,"Upper Break",shape.labelup,location.absolute,#26a69a,-length,text="B",textcolor=color.white,size=size.tiny)
  241. plotshape(lower_breakout ? high[length] : na,"Lower Break",shape.labeldown,location.absolute,#ef5350,-length,text="B",textcolor=color.white,size=size.tiny)
  242. //----
  243. var line up_l = na
  244. var line dn_l = na
  245. var label recent_up_break = na
  246. var label recent_dn_break = na
  247.  
  248. if ph[1]
  249.     line.delete(up_l[1])
  250.     label.delete(recent_up_break[1])
  251.    
  252.     up_l := line.new(n-length-1,ph[1],n-length,upper,color=#26a69a,
  253.       extend=extend.right,style=line.style_dashed)
  254. if pl[1]
  255.     line.delete(dn_l[1])
  256.     label.delete(recent_dn_break[1])
  257.    
  258.     dn_l := line.new(n-length-1,pl[1],n-length,lower,color=#ef5350,
  259.       extend=extend.right,style=line.style_dashed)
  260.  
  261. if ta.crossover(src,upper-slope_ph*length)
  262.     label.delete(recent_up_break[1])
  263.     recent_up_break := label.new(n,low,'B',color=#26a69a,
  264.       textcolor=color.white,style=label.style_label_up,size=size.small)
  265.  
  266. if ta.crossunder(src,lower+slope_pl*length)
  267.     label.delete(recent_dn_break[1])
  268.     recent_dn_break := label.new(n,high,'B',color=#ef5350,
  269.       textcolor=color.white,style=label.style_label_down,size=size.small)
  270.    
  271. //----
  272. plot(upper,'Upper',color = ph ? na : #26a69a,offset=-length)
  273. plot(lower,'Lower',color = pl ? na : #ef5350,offset=-length)
  274.  
  275. alertcondition(ta.crossover(src,upper-slope_ph*length),'Upper Breakout','Price broke upper trendline')
  276. alertcondition(ta.crossunder(src,lower+slope_pl*length),'Lower Breakout','Price broke lower trendline')
  277.  
  278. //***********************************************************************************************************************
  279. //hull suit
  280. //***********
  281.  
  282. //Basic Hull Ma Pack tinkered by InSilico
  283.  
  284. //INPUT
  285. src3 = input(close, title='Source')
  286. modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma', 'Ehma'])
  287. length3 = input(55, title='Length(180-200 for floating S/R , 55 for swing entry)')
  288. lengthMult = input(1.0, title='Length multiplier (Used to view higher timeframes with straight band)')
  289.  
  290. useHtf = input(false, title='Show Hull MA from X timeframe? (good for scalping)')
  291. htf = input.timeframe('240', title='Higher timeframe')
  292.  
  293. switchColor = input(true, 'Color Hull according to trend?')
  294. candleCol = input(false, title='Color candles based on Hull\'s Trend?')
  295. visualSwitch = input(true, title='Show as a Band?')
  296. thicknesSwitch = input(1, title='Line Thickness')
  297. transpSwitch = input.int(40, title='Band Transparency', step=5)
  298.  
  299. //FUNCTIONS
  300. //HMA
  301. HMA(_src3, _length3) =>
  302.     ta.wma(2 * ta.wma(_src3, _length3 / 2) - ta.wma(_src3, _length3), math.round(math.sqrt(_length3)))
  303. //EHMA    
  304. EHMA(_src3, _length3) =>
  305.     ta.ema(2 * ta.ema(_src3, _length3 / 2) - ta.ema(_src3, _length3), math.round(math.sqrt(_length3)))
  306. //THMA    
  307. THMA(_src3, _length3) =>
  308.     ta.wma(ta.wma(_src3, _length3 / 3) * 3 - ta.wma(_src3, _length3 / 2) - ta.wma(_src3, _length3), _length3)
  309.  
  310. //SWITCH
  311. Mode(modeSwitch, src3, len) =>
  312.     modeSwitch == 'Hma' ? HMA(src3, len) : modeSwitch == 'Ehma' ? EHMA(src3, len) : modeSwitch == 'Thma' ? THMA(src3, len / 2) : na
  313.  
  314. //OUT
  315. _hull = Mode(modeSwitch, src3, int(length3 * lengthMult))
  316. HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull
  317. MHULL = HULL[0]
  318. SHULL = HULL[2]
  319.  
  320. //COLOR
  321. hullColor = switchColor ? HULL > HULL[2] ? #00ff00 : #ff0000 : #ff9800
  322.  
  323. //PLOT
  324. ///< Frame
  325. Fi1 = plot(MHULL, title='MHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)
  326. Fi2 = plot(visualSwitch ? SHULL : na, title='SHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)
  327. alertcondition(ta.crossover(MHULL, SHULL), title='Hull trending up.', message='Hull trending up.')
  328. alertcondition(ta.crossover(SHULL, MHULL), title='Hull trending down.', message='Hull trending down.')
  329. ///< Ending Filler
  330. fill(Fi1, Fi2, title='Band Filler', color=hullColor, transp=transpSwitch)
  331. ///BARCOLOR
  332. barcolor(color=candleCol ? switchColor ? hullColor : na : na)
  333.  
  334. //***********************************************************************************************************************
  335. //breakout finder
  336. //*****************
  337.  
  338. prd21221 = input.int(defval=5, title='Period', minval=2)
  339. bo_len = input.int(defval=200, title='Max Breakout Length', minval=30, maxval=300)
  340. cwidthu = input.float(defval=3., title='Threshold Rate %', minval=1., maxval=10) / 100
  341. mintest = input.int(defval=2, title='Minimum Number of Tests', minval=1)
  342. bocolorup = input.color(defval=color.blue, title='Breakout Colors', inline='bocol')
  343. bocolordown = input.color(defval=color.red, title='', inline='bocol')
  344. lstyle = input.string(defval=line.style_solid, title='Line Style', options=[line.style_solid, line.style_dashed, line.style_dotted])
  345.  
  346. //width
  347. lll = math.max(math.min(bar_index, 300), 1)
  348. float h_ = ta.highest(lll)
  349. float l_ = ta.lowest(lll)
  350. float chwidth = (h_ - l_) * cwidthu
  351.  
  352. // check if PH/PL
  353. ph21221 = ta.pivothigh(prd21221, prd21221)
  354. pl21221 = ta.pivotlow(prd21221, prd21221)
  355.  
  356. //keep Pivot Points and their locations in the arrays
  357. var phval = array.new_float(0)
  358. var phloc = array.new_int(0)
  359. var plval = array.new_float(0)
  360. var plloc = array.new_int(0)
  361.  
  362. // keep PH/PL levels and locations
  363. if ph21221
  364.     array.unshift(phval, ph21221)
  365.     array.unshift(phloc, bar_index - prd21221)
  366.     if array.size(phval) > 1  // cleanup old ones
  367.         for x = array.size(phloc) - 1 to 1 by 1
  368.             if bar_index - array.get(phloc, x) > bo_len
  369.                 array.pop(phloc)
  370.                 array.pop(phval)
  371.  
  372. if pl21221
  373.     array.unshift(plval, pl21221)
  374.     array.unshift(plloc, bar_index - prd21221)
  375.     if array.size(plval) > 1  // cleanup old ones
  376.         for x = array.size(plloc) - 1 to 1 by 1
  377.             if bar_index - array.get(plloc, x) > bo_len
  378.                 array.pop(plloc)
  379.                 array.pop(plval)
  380.  
  381. // check bullish cup
  382. float bomax = na
  383. int bostart = bar_index
  384. num = 0
  385. hgst = ta.highest(prd21221)[1]
  386. if array.size(phval) >= mintest and close > open and close > hgst
  387.     bomax := array.get(phval, 0)
  388.     xx = 0
  389.     for x = 0 to array.size(phval) - 1 by 1
  390.         if array.get(phval, x) >= close
  391.             break
  392.         xx := x
  393.         bomax := math.max(bomax, array.get(phval, x))
  394.         bomax
  395.     if xx >= mintest and open <= bomax
  396.         for x = 0 to xx by 1
  397.             if array.get(phval, x) <= bomax and array.get(phval, x) >= bomax - chwidth
  398.                 num += 1
  399.                 bostart := array.get(phloc, x)
  400.                 bostart
  401.         if num < mintest or hgst >= bomax
  402.             bomax := na
  403.             bomax
  404.  
  405. if not na(bomax) and num >= mintest
  406.     line.new(x1=bar_index, y1=bomax, x2=bostart, y2=bomax, color=bocolorup, style=lstyle)
  407.     line.new(x1=bar_index, y1=bomax - chwidth, x2=bostart, y2=bomax - chwidth, color=bocolorup, style=lstyle)
  408.     line.new(x1=bostart, y1=bomax - chwidth, x2=bostart, y2=bomax, color=bocolorup, style=lstyle)
  409.     line.new(x1=bar_index, y1=bomax - chwidth, x2=bar_index, y2=bomax, color=bocolorup, style=lstyle)
  410.  
  411. plotshape(not na(bomax) and num >= mintest, location=location.belowbar, style=shape.triangleup, color=bocolorup, size=size.small)
  412. alertcondition(not na(bomax) and num >= mintest, title='Breakout', message='Breakout')
  413.  
  414. // check bearish cup
  415. float bomin = na
  416. bostart := bar_index
  417. num1 = 0
  418. lwst = ta.lowest(prd21221)[1]
  419. if array.size(plval) >= mintest and close < open and close < lwst
  420.     bomin := array.get(plval, 0)
  421.     xx = 0
  422.     for x = 0 to array.size(plval) - 1 by 1
  423.         if array.get(plval, x) <= close
  424.             break
  425.         xx := x
  426.         bomin := math.min(bomin, array.get(plval, x))
  427.         bomin
  428.     if xx >= mintest and open >= bomin
  429.         for x = 0 to xx by 1
  430.             if array.get(plval, x) >= bomin and array.get(plval, x) <= bomin + chwidth
  431.                 num1 += 1
  432.                 bostart := array.get(plloc, x)
  433.                 bostart
  434.         if num1 < mintest or lwst <= bomin
  435.             bomin := na
  436.             bomin
  437.  
  438. if not na(bomin) and num1 >= mintest
  439.     line.new(x1=bar_index, y1=bomin, x2=bostart, y2=bomin, color=bocolordown, style=lstyle)
  440.     line.new(x1=bar_index, y1=bomin + chwidth, x2=bostart, y2=bomin + chwidth, color=bocolordown, style=lstyle)
  441.     line.new(x1=bostart, y1=bomin + chwidth, x2=bostart, y2=bomin, color=bocolordown, style=lstyle)
  442.     line.new(x1=bar_index, y1=bomin + chwidth, x2=bar_index, y2=bomin, color=bocolordown, style=lstyle)
  443.  
  444. plotshape(not na(bomin) and num1 >= mintest, location=location.abovebar, style=shape.triangledown, color=bocolordown, size=size.small)
  445.  
  446. alertcondition(not na(bomin) and num1 >= mintest, title='Breakdown', message='Breakdown')
  447. alertcondition(not na(bomax) and num >= mintest or not na(bomin) and num1 >= mintest, title='Breakout or Breakdown', message='Breakout or Breakdown')
  448.  
  449. //************************************************************************************************************************
  450.  
  451.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement