Hello. I am trying to code a time-out stop loss.
Suppose a system generates a buy signal after price crossover a specific moving average.
If after that buy signal, the higher of next x days is lower than the high of the day of the buy signal, then close position at close of that day (x).
Is it possible using N-bar stop loss function? Can you help me with coding?
You wanna exit at profit target I guess for example x-ticks above high of entry bar. And in addition you want to add a time stop. So for example it's one Applystop with stoptypeprofit and another one with stoptypenbar. Or you can create stops via looping.
Hello. I am trying to add an additional exit rule to the classic MA cross over price system. Maybe an example can clarify this exit rule (I've chosen 3 days, but the idea should be adaptable to x days):
day 0 (signal): high 11, low 8.5, close 9.5, MA 9 open long (because close>MA)
day 1: high 10.5, low 7.5, close 8.8, MA 8.5 keep long position (because close>MA)
day 2: high 10.7, low 8, close 9, MA 8.8 keep long position (because close>MA)
day 3: high 10.2, low 7.8, close 9.5, MA 9 close position (because higher from day 1 to day 3 is lower than high of day 0).
On day 3, altough close is ABOVE MA, I would like to EXIT position (sell), because higher from day 1 to day 3 (10.7) is LOWER than high of day 0 (11).
I only need help on coding the lower higher exit rule (time out exit rule).