Swing High/Reversal Scan

M

mwizards

New member
VIP
Hi team, I'm looking to code up an indicator that tells me if the current high takes out a previous swing high.

Wo far I've got this with my poor thinkscript skills.

#returns a list of local tops - aka highest pivot high with 10 bars to the left and 10 to the right
def isMinorHigh = fold i = -10 to 10 with isHigh = high do (if GetValue(high, i) > high then 0 else isHigh);

#returns the last value of the high that's not NaN
def getPreviousHigh = fold j = 0 to 99 while GetValue(isMinorHigh, j)<0.1 do GetValue(isMinorHigh, j+1);

#this should return if the current high of the bar is higher than the previous high
plot scan = high > getPreviousHigh[1];

For some reason, this code works as a label on a chart quite well (ex: high>getPreviousHigh[1]) but it doesn't work in the scanner - i think the scan query kinda defaults to 'true' and I am not sure how to debug what causes it and the limitations of the scanner etc.

Anybody got any ideas?

Thanks!
 

Similar threads

Top