I am trying to figure out how to write a piece of code to detect whether the last, say, 50 bars were in a range of less than 20 pips. In this case I would not enter any trade even if conditions are met.
I wrote:
IF range[50] < 20 THEN
……
ENDIF
But it seems not to work.
Can anyone help me? Thank you.
What you need here is to determine the highest high and the lowest low of the last 50 bars, then test if their difference is more or less 20 pips.
hh = highest[50](high)
ll = lowest[50](low)
test = (hh-ll)<20*pipsize
Thank you very much Nicolas, that’s exactly what I wanted.
So what does RANGE[50] do?
Thanks.
Range returns the range of the selected bar only.