username1 wrote >>
...I'm using the fact that each bar opening price is different to differentiate one bar from another
Use the opening time of the bar to be the <last order time>
Something like this OTTOMH
extern int TP = 30; extern int SL = 20; static LastOrderTime datetime; init () { LastOrderTime = Time[1]; // initialise variable return(0); } start() { if (LastOrderTime < Time[0]) // A new bar has started since last order { // Do order stuff LastOrderTime = Time[0]; // reset variable } return(0); }
FWIW
-BB-
Moving Average EA
Logic:
- Always in market and holding trade based on prevailing trend.
- Check for signal once per new bar. ** I think this is not working. (See attached picture of backtest)
- Signal triggered if Closing Price of Previous Bar crosses the 5 EMA in the opposite direction.
- Action taken upon signal:
The EA:
My Problem:
1. EA opening multiple positions (too many) in the same bar.
Can someone please point out my mistake ?
I'm using the fact that each bar opening price is different to differentiate one bar from another.
Thanks.