i get a error 4108. why is the orderticket invalid?
What was the ticketnumber you send you get error 4108 ??
What OrderType() did this ticket have ??
Can you tell us ??
i get a error 4108. why is the orderticket invalid?
((OP_BUYSTOP) ||(OP_SELLSTOP))) is equal 1, so you select OrderType()==1 (OP_SELL)
and you can't delete a market order.
Try this :
for(i=OrdersTotal()-1; i >=0 ; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==true) { if (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP) OrderDelete(OrderTicket()); } }
and you can't delete a market order.
Try this :
((OP_BUYSTOP) ||(OP_SELLSTOP))) is equal 1, so you select OrderType()==1 (OP_SELL)
This is giving output true or false so possible value can be also 0, then it will not be you have select OP_BUY
and if the outcome is 1, then also the selected OrderType( ) you try to delete can be different from ( OP_SELL )
a little mistake in your explanation
This is giving output true or false so possible value can be also 0, then it will not be you have select OP_BUY
and if the outcome is 1, then also the selected OrderType( ) you try to delete can be different from ( OP_SELL )
I don't agree, why :
OP_BUYSTOP is a constant which is equal 4, OP_SELLSTOP is 5. So we have :
(4 || 5) which is ALWAYS true, and true is 1.
Logical operation OR (||) of x and y values. The expression value is TRUE (1) if x or y value is true (not null).
Someone once said : "AS you can see good reading gives you the answer and sometimes i have trouble with it" ;-)
I don't agree, why :
OP_BUYSTOP is a constant which is equal 4, OP_SELLSTOP is 5. So we have :
(4 || 5) which is ALWAYS true, and true is 1.
Someone once said : "AS you can see good reading gives you the answer and sometimes i have trouble with it" ;-)
From your link See documentation :
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
will return OrderDelete error 4108 EURUSD,H1: market order #2 cannot be deleted if we get output 1 it means (4 || 5) which is ALWAYS true, and true is 1. So if ((OrderType() == ((OP_BUYSTOP) ||(OP_SELLSTOP)))) can be rewritten as if ((OrderType() == ((true)))) |
or
if ((OrderType() == ((1))))
and the selected OP_BUYSTOP or the selected OP_SELLSTOP is not deleted
Hope With this explanation you do agree ???
overlooked one thing so i edit this post if x or y value is true (not null).
Ok, sorry, seem like a communication problem because my english is not so good. When I write "so you select OrderType()==1 (OP_SELL)", actually I meant that the "if test" is always checking OrderType==1. This has nothing to do with selecting order. And I misunderstood your point, thinking that you were saying that "((OP_BUYSTOP) || (OP_SELLSTOP))" could be 0.
Ok, sorry, seem like a communication problem because my english is not so good. When I write "so you select OrderType()==1 (OP_SELL)", actually I meant that the "if test" is always checking OrderType==1. This has nothing to do with selecting order. And I misunderstood your point, thinking that you were saying that "((OP_BUYSTOP) || (OP_SELLSTOP))" could be 0.
It is not English it is the programming you have to learn to understood to see what happens
first you have an orderselect gives a ordertype ( )
( || ) true or false
== ( || ) means this way OrderType() equal to .... 0 or 1
and only if ordertype is equal the funtion OrderDelete(OrderTicket()) will go to broker
this error i made myself also in the past
but searching why it failed i learned to understand the logic behind this
about your coding return codes !!
bool result; for(i=OrdersTotal()-1; i >=0 ; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==true) { //---- pending stop orders only are considered if (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP) { //---- print selected order OrderPrint(); //if you like to print this also //---- delete first pending order result=OrderDelete(OrderTicket()); if(result!=TRUE) Print(OrderTicket()," ",OrderType()," LastError = ", GetLastError()); } } else { Print( "Error when order select ", GetLastError()); break; } }
something like this
I responded to the initial question only : " why is the orderticket invalid?". Obviously if the code inside the "if" is not run there will be no errors. This is not my code, only the correction of the problem.
You (and others) you assign yourself the task of teaching others to program, while a forum is to answer questions.
I responded to the initial question only : " why is the orderticket invalid?". Obviously if the code inside the "if" is not run there will be no errors. This is not my code, only the correction of the problem.
You (and others) you assign yourself the task of teaching others to program, while a forum is to answer questions.
the explanation you gave by the correction of the problem was in my opinion wrong !!!!
the code you gave will also not answer the questions I asked the OP
If the OP was using printstatements in the returncoding
then he was able to answer my questions. With his code and your code he is not !!!
I responded to the initial question only : " why is the orderticket invalid?". Obviously if the code inside the "if" is not run there will be no errors. This is not my code, only the correction of the problem.
You (and others) you assign yourself the task of teaching others to program, while a forum is to answer questions.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use