renen:
In a loop where you select the orders one by one count up the number of open Buy orders and the number of open Sell orders, then outside the loop . . . if you already have > 0 Buy orders don't open another Buy, if you already have > 0 Sell orders don't open another Sell. Bear in mind within the loop you can/should check if the orders you are counting are for the correct symbol and Magic number.Hello,
I'm trying to code a EA that allows to open buy and sell orders simultaneously, but only one order per type. (open only one BUY order, and open only one SELL order). Could somebody please explain me how I can do this?
At the moment I am using if(OrdersTotal()<1) to block the EA form opening the second buy order. This method will also block the ea when I would like to open a sell. This is my code:
Don't forget to check your Trade Function return values and report all errors and relevant variables when they fail . . . What are Function return values ? How do I use them ?
renen: I'm trying to code a EA that
allows to open buy and sell orders simultaneously,
- Can't be done. You can open a buy and THEN a sell, or the other way around. But not simultaneously.
- OrderSends take time, you need to refreshRates between the calls
- Hedging is not allowed in the US.
- Why, one wins, one looses and you pay the spread on both.
- Simplify your bools
// bool doji; // if(closeperc >= -0.0005 && closeperc <=0.0005) // doji = true; // bool doji = (closeperc >= -0.0005 && closeperc <=0.0005); bool doji = MathAbs(closeperc) <=0.0005);
WHRoeder:
I have a way of doing it, and saving commission/spread costs ^_^
- Can't be done.

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,
I'm trying to code a EA that allows to open buy and sell orders simultaneously, but only one order per type. (open only one BUY order, and open only one SELL order). Could somebody please explain me how I can do this?
At the moment I am using if(OrdersTotal()<1) to block the EA form opening the second buy order. This method will also block the ea when I would like to open a sell. This is my code: