Why are you looping trough all your orders?
if you have stored the ticketnumber in the variables sellStopOrder and buyStopOrder there is no need for the loop, but i assume you have made a mistake in the OrderOpen() code..
and btw, no matter what happens to your orders, ready333 and ready444 will always be 0.
//z
Why are you looping trough all your orders?
if you have stored the ticketnumber in the variables sellStopOrder and buyStopOrder there is no need for the loop, but i assume you have made a mistake in the OrderOpen() code..
and btw, no matter what happens to your orders, ready333 and ready444 will always be 0.
//z
i have different orders, each with their own magicnumber) so i have to check them all. Also in the main code, the ready333 and ready444 are both set to 1 each time, so only when the order alrady exists, it wont take the order again.
I don't use OrderOpen() but OrderSend(), but do you see a mistake it it? If so, whats wrong?
And yes, the SellStopOrder and BuyStopOrder should have the right ticket number, but when i watch the results in backtest, i see orders are deleted, but somehow it also gives many 4108 errors in Journal?
i have the follwing commands to send the order:
buyStopOrder=OrderSend(Symbol(),OP_BUYSTOP,lots,entryw1,100,SLw1,TPw1,NULL,333,0,Blue);
sellStopOrder=OrderSend(Symbol(),OP_SELLSTOP,lots,entryw2,100,SLw2,TPw2,NULL,444,0,Red);
and then the following code. The EA should (for example) delete pending order (with magicnumber 333) when order with magicnumber 444 opens.
Right now i get many error 4108 in journal, saying "unknown ticket 6 for OrderDelete function"
You are trying to delete open orders. OrderDelete() only works on pending orders. For example you say if the order type is OP_BUY then delete it.
An OP_BUY from the open orders pool is a long position not a pending position. It can't be deleted, it has to be closed using the OrderClose() function.
You should of course be checking your sellStopOrder and buyStop order variables to make sure they hold valid tickets (not -1).
You are trying to delete open orders. OrderDelete() only works on pending orders. For example you say if the order type is OP_BUY then delete it.
An OP_BUY from the open orders pool is a long position not a pending position. It can't be deleted, it has to be closed using the OrderClose() function.
You should of course be checking your sellStopOrder and buyStop order variables to make sure they hold valid tickets (not -1).
I think you misread, if the order type is OP_BUY, THEN delete the pending order (OP_SELLSTOP) with ticketnumber sellStopOrder.
other way around, if order type is OP_SELL, then delete pending order OP_BUYSTOP
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i have the follwing commands to send the order:
buyStopOrder=OrderSend(Symbol(),OP_BUYSTOP,lots,entryw1,100,SLw1,TPw1,NULL,333,0,Blue);
sellStopOrder=OrderSend(Symbol(),OP_SELLSTOP,lots,entryw2,100,SLw2,TPw2,NULL,444,0,Red);
and then the following code. The EA should (for example) delete pending order (with magicnumber 333) when order with magicnumber 444 opens.
Right now i get many error 4108 in journal, saying "unknown ticket 6 for OrderDelete function"