I am trying to build a scan friendly code (e.g. it cannot use [-offset]) which detects a highest/lowest in n bars from the last bar.
In study i can do something like this
but not gonna work in scan/custom quote. How to fix that?
In study i can do something like this
Code:
input n=30;
def isLastBar = !IsNaN(close) and IsNaN(close[-1]);
def lastbarrange= if islastbar[-n] then 1 else lastbarrange[1];
def HHrange= if islastbar[-n] then highest(high,n)[-n] else HHRange[1];
def HH= if high==HHRange then 1 else 0;
addChartBubble( HH,high, "HH");
but not gonna work in scan/custom quote. How to fix that?