How to make an EA place a single order per signal, and keep placing another order once there is a new signal even if the previous orders are still in the market
- Only check for a cross on a new bar
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 2014.04.04I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum 2011.05.06 -
or, check for a change in signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 2017.12.12
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello my people.
I am currently building an EA that place order once 5 & 20 exponential moving averages crosses each other, the issue is once the fast moving average crosses the slow moving avearge to the upside, the bot will immediately place multiple buy order and stop out will occur.
So i managed to stop that behavior by checking if(ordersTotal() == 0){ ordersend() }, but i want the bot to be able to place multiple other even there are still active market other in the market, but it should place only one single order per signal.
Since i did not use stop loss in designing the bot, so it is possible to have a buy signal while there is a sell signal in loss.
For example if there is a buy signal place one buy order, if there is a sell signal place one sell order, either the initial buy order hit take profit or not keep placing another other once there is a crossover.
See my code below, it is not working. if there is a sell order in the market, if buy signal occur it will not place any trade.
Please show me a better way to do this.