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.
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.
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:
1
2
3
4
5
6
MyLow=lowest[254](low)
FORi=0TO253
IFlow[i]=MyLowTHEN
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.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue