check the below
CSS:input plotPVT = yes;#(defval=true, title='Plot Pivots', group='Pivots') input pivotLookup = 1;#(defval=1, minval=1, maxval=5,title='Pivot Lookup', group='Pivots', tooltip='Minimum = 1, Maximum = 5') def na = Double.NaN; #valuewhen (cond, source, occurrence) => script valuewhen { input cond = 0; input source = 0; input occurrence = 0; def n = occurrence + 1; # start at 0 so it looks at current bar def offset2 = fold j = 0 to 200 with p while p < n + 1 do p + ( if p == n then j - n else if GetValue(cond, j) then 1 else 0 ); # def bnz = bn - offset2 + 1; plot price = GetValue(source, offset2 - 1); plot offset = offset2; } #//////////////////// Pivots //////////////////// script FindPivots { input dat = close; # default data or study being evaluated input HL = 0; # default high or low pivot designation, -1 low, +1 high input lbL = 5; # default Pivot Lookback Left input lbR = 1; # default Pivot Lookback Right ############## def _nan; # used for non-number returns def _BN; # the current barnumber def _VStop; # confirms that the lookforward period continues the pivot trend def _V; # the Value at the actual pivot point ############## _BN = BarNumber(); _nan = Double.NaN; _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then fold a = 1 to lbR + 1 with b=1 while b do if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan; if (HL > 0) { _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop then dat else _nan; } else { _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop then dat else _nan; } plot result = if !IsNaN(_V) and _VStop then _V else _nan; } def hih = findpivots(high, 1, pivotLookup, pivotLookup); def lol = findpivots(low , -1, pivotLookup, pivotLookup); def top = if !isNaN(hih) then hih else if isNaN(top[1]) then high[pivotLookup] else top[1]; def bottom = if !isNaN(lol) then lol else if isNaN(bottom[1]) then low[pivotLookup] else bottom[1]; plot PvtTop = if isNaN(close) or !top then na else top;#, offset=-pivotLookup, linewidth=1, color=(top != top[1] ? na : (plotPVT ? pvtTopColor : na)), title="Pivot Top") PvtTop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); plot PvtBit = if isNaN(close) or !bottom then na else bottom;#, offset=-pivotLookup, linewidth=1, color=(bottom != bottom[1] ? na : (plotPVT ? pvtBottomColor : na)), title="Pivot Bottom") PvtBit.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Hi Samer800,
Can you please help to improvise it by adding an arrow head pointer (or a caret similar to fractal pattern) to the candle that framed structure break, like shown below?
Hi Samer800,
Never mind my request.
I see you have done something similar and more in this post: https://usethinkscript.com/threads/order-block-finder-for-thinkorswim.12162/
There is a bit of complexity and excess functionality there in the code. I turned off some of the plots and was able to get what I needed. I was just after the candle marker
Thank you!
Last edited by a moderator: