I checked this code now on a real account, everything is OK, I modified all market orders, but the only thing I haven't touched is the pending orders. What's the problem? What do you think?
Noterday: I checked this code on my real account, everything is ok, I modified all market orders, but I left the pending orders untouched. What's the problem? What do you think?
There's also a phrase in the script's name that says market orders only... Remove those conditions for market orders, then conditions for market and pending orders will be met - that's all. No that's not all - read it carefully - requirements and limitations... ...and make sure you add these minimum requirements to your pending orders so they are met as well.
Market orders are not closed if StopLoss or TakeProfit values violate FreezeLevel parameter requirements. StopLoss or TakeProfit market orders can not be modified if StopLoss or TakeProfit values violate the StopLevel parameter requirements. Deletion and modification of pending orders are not performed if the declared open price of the order violates the FreezeLevel parameter requirements.
if (OrdersTotal()!=0)
{
bool modify;
int Done=0;
for (i = 1; i <= OrdersTotal(); i++)
{
if (OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES) == true)
{
Stop = OrderStopLoss();
Take = OrderTakeProfit();
Print("Пробую модифицировать ",i," ордер (#",OrderTicket(),")");
modify = OrderModify(OrderTicket(),0,SL,TP,0,0); <<<--------------------- во втором параметре OrderModify нужно ставить не ноль а Orderopenprice()
if (modify==true) Done++;
if (modify==false)
{
int error = GetLastError();
Print(" Неудача... Ошибка ",error);
Sleep(5000);
}
}
}
Alert("Модифицировано ",Done," из ",OrdersTotal());
Sleep(10000);
}
and already then you check for compliance with "Trading Requirements and Restrictions" of this or that selected order, each type of selected order has its own requirements and restrictions... and here the script is only for market orders... Edit by analogy and that's it - you have all the information. Calmly, carefully and methodically.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I checked this code on my real account, everything is ok, I modified all market orders, but I left the pending orders untouched. What's the problem? What do you think?
In the condition
if(cmd==OP_BUY || cmd==OP_SELL)and in the condition
if(cmd==OP_BUY)I don't get it :(
There's also a phrase in the script's name that says market orders only... Remove those conditions for market orders, then conditions for market and pending orders will be met - that's all. No that's not all - read it carefully - requirements and limitations... ...and make sure you add these minimum requirements to your pending orders so they are met as well.
So I have no such lines at all, I don't select type AT ALL, I modify ALL of them, be it pending or market.
I am writing you to carefully read: " FreezeLevel distance restriction.
Market orders are not closed if StopLoss or TakeProfit values violate FreezeLevel parameter requirements.
StopLoss or TakeProfit market orders can not be modified if StopLoss or TakeProfit values violate the StopLevel parameter requirements.
Deletion and modification of pending orders are not performed if the declared open price of the order violates the FreezeLevel parameter requirements.
That's it, the error was there:
So I have no such lines at all, I don't select type AT ALL, I modify ALL of them, be it pending or market.
Also in the condition this
change similarly under the order to be selected (change the order type definition condition to one of these: