Hi
Apologies as I’m sure this is a simple piece of code but I can’t seem to work it out.
I would like to code for the previous low, but not over a particular number of bars. just however long that previous low is before current price. I’ll then use that to create a signal at 20$% above that. I’ve tried to use:
LOWEST [n] (low) but I can’t work out how to allow the flexibility of the time parameter.
Thank you for your help.
n can be 254 bars maximum, be it on a 1-minute or a 1-week TF.
Hi
Many thanks. I do understand that, but is there a way I can code for a previous low rather than set a ‘LOWEST’ point determined by a number of bars. Depending on how many bars you set, these 2 methods can give different results. The previous low could be only a few bars before the current bar or it could be 200 bars before, so I don’t want to restrict to a set number of bars. It sounds simple but I’m not sure how to do it.
Many thanks
Once you have used
MyLow = LOWEST[254](low)
to know what price that LOW is, you need an iteration (loop) to scan bars beackwards till you find the right one, which can be 4 or 253 bars away:
MyLow = lowest[254](low)
FOR i = 0 TO 253
IF low[i] = MyLow THEN
BREAK
ENDIF
NEXT
at the end of the FOR…NEXT loop variable i (counter) will retain the index value of the bar retaining that low, can be 0 if it’s the current bar (LOW[0] or LOW) or any other value up to 253.
That’s great Roberto, many thanks for your time and help.