Can you please provide me with the line of code that once a condition is satisfied say for eg Close is above MA what code would you use to then find a confirmation ie being 2 bars where each bar was a higher price than the price that triggered the condition (ie crossover of the MA). The the calculation needs to be from the last time the condition (ie crossover of the MA) was triggered, so for eg if the price then dipped below the MA and then triggered the condition again it should only be calculating the show bar confirmation once there are 2 bars where each bar was a higher price than the price that triggered the last condition. I hope that makes sense.
Hello Karen, You can use the show bar feature and use this script. I use this on a 15-minute chart when 9 crosses above 20 EMA and it triggers a signal.
You can use any moving average based on your trading style. I hope it helps.
S1=GANNSWING();
V1 = MA(BARS=9, STYLE=Exponential) ;
V2 = MA(BARS=20, STYLE=Exponential) ;
V3=V1 CrossesAbove V2;
V4=S1 TurnsUp;
V5=SIGNALAFTER(V3,V4);
V5
Thanks,
Mo
Hi Mo
Thanks for your message. That isn’t solving for the problem I am after.
I need to be able to pinpoint the bar which is the second time/bar that there is a higher price than the original trigger bar (where the original trigger bar is for eg where price has crossed over a Moving Average).
Thanks,
Karen
Hi Karen,
I’m not exactly sure I understand the last part, but this will trigger 2 bars after the close crossed above a 20MA if those 2 bars closed higher:
//Define MA cross;
S1=Close() CrossesAbove MA(BARS=20, CALC=Close);
//Define 2 higher closes;
S2=CLOSE()>CLOSE()[1] and CLOSE()[1]>CLOSE()[2];
//Signal when cross occurred 2 days ago and 2 closes higher;
S1[2] and S2
In this example the green arrows show the cross above the MA, with the blue showing when the 2 following bars are higher:
Thanks. I will try that and see if it works.