Set Position Exit to Low/High before Entry Bar?


Active member
Did my DD in scouring the search/google, and couldn't find the answer to this...

How do you set a stop loss to be the low (in the case of long entry) of the bar just prior to entry?


Staff member
You would need to use recursion to maintain the low of the candlestick bar that is the same as your EntryPrice()... Then you would add something like "or price <= stopLoss" to your closing conditional clause... There are several trailing stoploss scripts here in the forums that can be adapted to your needs... Using ATR or a fixed amount or percentage is far easier than low prior to entry, but it is possible...


Active member
Appreciate the help. That is disappointing but I will look through other scripts. Might have to settle on a ATR %. Except it needs to be based on the ATR % at the time of entry. Is there a way to know what time an entry is at, and then know what bar is at that time?

Similar threads