for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (condition1==true) { buyticket=OrderSend(OP_BUY...) buystopticket=OrderSend(OP_BUYSTOP...) } if (condtion2==true) { sellstopticket=OrderSend(OP_SELLSTOP...) } if (condition3==true && OrdersTotal()>0) { OrderClose(buyticket,OrderLots(),Bid,3,CLR_NONE); OrderDelete(buystopticket); OrderDelete(selltopticket); }
}maybe something like this?
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
I'm Intended use OrderClose and OrderDelete functions, with a system that can open multiple operations.
What's wrong here?:
(condition1=entry, condition2=other entry, condition3=exit)
if (condition1==true)
{
ordersend(OP_BUY...)
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
ordersend(OP_BUYSTOP...)
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
}
if (condtion2==true)
{
OrderSend(OP_SELLSTOP...)
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
}
if (condition3==true && OrdersTotal()>1)
{
while (OrdersTotal()>0)
{
if (OrdersTotal()>0)
OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
}
{
if (OrdersTotal()>0)
OrderDelete(OrderTicket());
}
}
the MT4 test giveme error: wrong ticket in orderdelet.
The idea is if last condition is true, stay between orderclose and orderdelete until they are all closed and removed
thanks
trader201