#Double bottom # finds double bottoms within the bar ranges specified by the farpivot and nearpivot values. to use as chart plot insert # at the line below ' scan_ok ' and remove the # at the plot code lines below that line input farpivot=49; # bars back to start farthest bottom search input nearpivot = 4; # bars back to start nearest bottom search input near_far_prct=.03; #max delta between the 2 lows input hi_low_diff = 1.07; # min delta between first low and high def bar =barnumber(); def Hprice =low; def lastbar=highestall(barnumber()); def min =lastbar-farpivot; def max = lastbar-nearpivot; def na=double.nan; script rangelow { def price =low; def bars=barnumber(); input mins =0; input maxs = 0; def nas=double.nan; def lastbars=highestall(barnumber()); def val = if bars>=mins then if bars==mins then price else if bars >mins and bars <= maxs then if price=maxs then val else val[1]; } # code to find intervening high script rangehigh { input mins =0; input maxs = 0; def price =close; def bars=barnumber(); def nas=double.nan; def lastbars=highestall(barnumber()); def val = if bars>=mins then if bars==mins then price else if bars >=mins and bars <= maxs then if price>val[1] then price else val[1] else val[1] else nas; plot condition= if bars>=maxs then val else val[1]; } #end rangehigh script #==========plots plot firstlow = (rangelow(min,max-13)); firstlow.setDefaultColor(color.lime); def Flowbars=if firstlow== lowestall(rangelow(min,max)) and bar >=min then BarNumber() else Flowbars[1]; def Flowbar= lowestall(Flowbars); plot MidHigh = rangehigh(Flowbar,max); MidHigh.setDefaultColor(color.cyan); def highbars=if Midhigh== highestall(rangehigh(Flowbar,max)) and bar >=min then BarNumber() else highbars[1]; def Highbar= lowestall(Highbars); def lastlow = rangelow(max,lastbar); Def Low_diff = firstlow-lastlow; def inrnge= if absValue( low_diff)<=firstlow*near_far_prct then yes else no; plot lastlow_L = if inrnge then rangelow(max,lastbar) else na; lastlow_L.setDefaultColor(color.white); AddVerticalLine(if BarNumber() == highest(Flowbar) and (bar>=min) then yes else no, "", Color.LIME, curve.FIRM); AddVerticalLine(if bar == fLowbar and (barnumber()>=max) then yes else no, "", Color.white, curve.short_dash); AddVerticalLine(if bar == Highbar and (barnumber()>=Flowbar) then yes else no, "", Color.cyan, curve.short_dash); AddLabel(yes,"farpiv "+firstlow+ " nearpivot " +lastlow+ " diff " + low_diff + " inrge " +inrnge + " Flowbar " + Flowbar + " Highbar " + highbar,color.white); # end code