I put in your code, it doesn't compile. What is the error, I can't understand. But the main thing, I still asked, there must be some kind of logical error, orders are opened on every tick, most likely this part does not work.
Please advise what is wrong in the code. The robot is supposed to close a sell order, if it is not there, it should buy. Error 4105 appears, which I try to handle, but there is no result. Maybe there are other ways to process it?
PRICECURRENTPPROFIT is the buy level.
// ROBOT SELLS // determine if there are sell orders if (Bid>=PRICECURRENTPPROFIT && PRICECURRENTMPROFIT>0) { for(cnt=OrdersTotal();cnt>=0;cnt--) {OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode = OrderType(); if(OrderSymbol() == "EURUSD") {if(mode == OP_BUY) {go=OrderClose(OrderTicket(), Lots, Bid, slippage, Green);
} } } // if open, close } if(go != true) {Print("Failed to open SELL order. Error N", GetLastError()); switch(GetLastError()) {case 4105: OrderSend("EURUSD",OP_SELL,Lots,Bid,2*Point,0,0, "robot sells",MagicNumber,0,Red);break;} }
I want to add some functions to it to make it open for buy and sell but for sell and buy need a separate magicnumber
If a Take Profit order triggers, the robot closes all pending orders. I want it to close all pending orders OP_SELLLIMIT and leave them unchanged OP_BUYLIMIT, OP_BUY
Dimka-novitsek: I put in your code, it doesn't compile. What is the error, I can't understand. But most importantly, I still asked, there must be some kind of logical error, orders are opened on every tick, most likely this part is not working, and I can't understand it either?
Either the code is not all shown or the closing curly bracket is missing at the very bottom.
Yes, if you set it as x=0, it will go to zero if you just set it as x:, it won't go to zero, it will go up.
This is the right way to go!!!!!
I'm sure it'll reset. Thank you all, it's a bit hilarious.
Guys a more complicated question......
How to make an EA close all orders when a given profit is reached .... Close only orders on one symbol ...
Example : EA works on 3 pairs amount to close all orders on one symbol 100p ...
If the EUR has more than 100p it will only close orders on EUR while others may have 200p ...
If I take accountbalanse(), then EA will close only when the sum of three pairs is more than 100p. This option does not work for me !!!!
Help please.........
Probably with
Please advise what is wrong in the code. The robot is supposed to close a sell order, if it is not there, it should buy. Error 4105 appears, which I try to handle, but there is no result. Maybe there are other ways to process it?
PRICECURRENTPPROFIT is the buy level.
// ROBOT SELLS
// determine if there are sell orders
if (Bid>=PRICECURRENTPPROFIT && PRICECURRENTMPROFIT>0)
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode = OrderType(); if(OrderSymbol() == "EURUSD")
{if(mode == OP_BUY)
{go=OrderClose(OrderTicket(), Lots, Bid, slippage, Green);
}
}
} // if open, close
} if(go != true) {Print("Failed to open SELL order. Error N", GetLastError());
switch(GetLastError()) {case 4105: OrderSend("EURUSD",OP_SELL,Lots,Bid,2*Point,0,0, "robot sells",MagicNumber,0,Red);break;}
}
I want to add some functions to it to make it open for buy and sell but for sell and buy need a separate magicnumber
If a Take Profit order triggers, the robot closes all pending orders. I want it to close all pending orders OP_SELLLIMIT and leave them unchanged OP_BUYLIMIT, OP_BUY
I put in your code, it doesn't compile. What is the error, I can't understand. But most importantly, I still asked, there must be some kind of logical error, orders are opened on every tick, most likely this part is not working, and I can't understand it either?