Hello,
Im trying to fix my EA for 12 hours until now, Every thing going smooth and my orders open as I want to,
But I cant get them close if my pair change direction...
Bearing in mind this code which returns from start() if the OrderSelect() works and the order selected is for the chart symbol . . .
for (int i = OrdersTotal() - 1; i>=0; i--) if ( OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() ) return;
. . . what Order is selected when you call OrderTicket() and OrderLots() ? Don't you want to know when your calls to OrderXxxxx() fail ? for example, wouldn't you like to know the error code if your OrderClose() fails ? Read this: What are Function return values ? How do I use them ?
Your not working section is never reached by your code.
You return at the beginning of the start() function if OrderSelect() does not fail.
for (int i = OrdersTotal() - 1; i>=0; i--) if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() ) return;
Add some print() statements to find errors like that one.
Bearing in mind this code which returns from start() if the OrderSelect() works and the order selected is for the chart symbol . . .
. . . what Order is selected when you call OrderTicket() and OrderLots() ? Don't you want to know when your calls to OrderXxxxx() fail ? for example, wouldn't you like to know the error code if your OrderClose() fails ? Read this: What are Function return values ? How do I use them ?
Well, I cant fix it, when ever I adjust something , I get a lot of trades per second, or my order wont close ...
I had to write this code to get no more than 1 trade per second while testing ..
Could you help me with it and getting the order to close if iOpen>...... happens? I would appreciate your help a lot..
Thanks
So , this is what I got so far:
for (int i = OrdersTotal() - 1; i>=0; i--) if (OrderSelect(i, SELECT_BY_POS == true) ) return; else if( iOpen("GBPJPY",PERIOD_M30,1)<iClose("GBPJPY",PERIOD_M30,1)&&iOpen("GBPUSD",PERIOD_M30,1)<iClose("GBPUSD",PERIOD_M30,1)&&iOpen("AUDJPY",PERIOD_M30,1)>iClose("AUDJPY",PERIOD_M30,1)) { OrderClose(OrderTicket(),OrderLots(),Bid,100); } if( iOpen("GBPJPY",PERIOD_M30,1)>iClose("GBPJPY",PERIOD_M30,1)&&iOpen("GBPUSD",PERIOD_M30,1)>iClose("GBPUSD",PERIOD_M30,1)&&iOpen("AUDJPY",PERIOD_M30,1)<iClose("AUDJPY",PERIOD_M30,1)) { OrderClose(OrderTicket(),OrderLots(),Ask,100); }
I just cant get it and im frustrated after 12 hours of trying ...
Just how to make it, if true then return BUT to my Close order script and not to open a new one..
Thanks again
Just how to make it, if true then return BUT to my Close order script and not to open a new one..
Why do you not use your defined variables AllowBuy and AllowSell? Set AllowBuy to false when you opened a buy order, reset it to true when you close it. The same for AllowSell? Do I miss something... ?
OrderModify(openbuy,OrderOpenPrice(),Bid-99999*Point,Ask+99999*Point,0,Blue);What are Function return values ? How do I use them ? - MQL4 forum

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
Im trying to fix my EA for 12 hours until now, Every thing going smooth and my orders open as I want to,
But I cant get them close if my pair change direction...
Here is it :
I would appreciate your help,
Thanks