This code is working fine. Tested on MT4 build 1170.
You should just check the value returned by OrderSend(), but that's not related to your issue I suppose.
Always 1 order at a time :
This code is working fine. Tested on MT4 build 1170.
You should just check the value returned by OrderSend(), but that's not related to your issue I suppose.
Always 1 order at a time :
Hello. Thanks for the help. I figured it out. It seems my stop loss is too small. That's why it was always hit. I made my stop loss 1000, and now I can confirm that there is really nothing wrong with the code but with the stoploss that I had set.
This is what I see in the visual mode of strategy tester before I had set the stoploss to 1000.
if(OrdersTotal()==0)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone. I am trying to create a simple moving average cross-over EA. I have a little bit of a problem. What I want to do is to first check the total number of orders before opening a buy/sell order. If the total number of orders is zero, only then will the EA opens a buy/sell order depending on the signal provided by the moving averages. I am using the OrdersTotal() Function for counting the total number of opened orders. The problem is whenever I try to test the EA in the strategy tester, the EA continually opens buy orders simultaneously even though the total number of orders returned by the OrdersTotal() Function is already greater than zero. Will someone please help.
Here is my code