How delete pending order with MagicNumber = 1?

 

First I try to delete pending order with magic number=1 using this:

OrderDelete(OrderMagicNumber()== 1 );

Doesn't work!

But somebody tell me that this is boolean expression. //by the way thanks brewmanz

So i think about:

int OMN= OrderMagicNumber;

for ( OMN= 1 ) {

OrderDelete............

But trully I don't know how to code it.

Looking for help..

 
BorysekPL:

First I try to delete pending order with magic number=1 using this:

OrderDelete(OrderMagicNumber()== 1 );

Doesn't work!

But somebody tell me that this is boolean expression. //by the way thanks brewmanz

So i think about:

int OMN= OrderMagicNumber;

for ( OMN= 1 ) {

OrderDelete............

But trully I don't know how to code it.

Looking for help..


i guess you need to read and learn a lil bit more about orders and changing/closing them .. :-)

https://book.mql4.com/trading/orderclose

 
EADeveloper:


i guess you need to read and learn a lil bit more about orders and changing/closing them .. :-)

https://book.mql4.com/trading/orderclose


Thanks, but I read it before. The problem is that I still have a problem when use ticket and when use MagicNumber.

I thought that I must to use MagicNumber to select the order that I want to delete.

The articles in the web I found scribes about deleting first pending order. I want to delete order with some ID.

bool OrderDelete(int ticket, color arrow_color=CLR_NONE)

I don't know how to do it using "ticket" so if you know how - it'll be appreciated :)

 

first find the ticket & then........ very simple

 
qjol:

first find the ticket & then........ very simple

//order magic number that I want to delete = 1
int ticket=1;
OrderDelete(ticket);

is that correct?

ticket instead of MagicNumber in that case?

 

c for yourself

bool OrderDelete( int ticket, color Color=CLR_NONE)

 
for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
&&  OrderMagicNumber()  == magic.number             // my magic number
&&  OrderSymbol()       == Symbol() ){              // and my pair.
    if (OrderType() <= OP_SELL){
        if (!OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage.Pips*pips2points))
           Alert("OrderClose(",OrderTicket(),", ...) Failed: ", GetLastError());
    }
    else{
        if (!OrderDelete(OrderTicket()) 
           Alert("OrderDelete(",OrderTicket(),") failed: ", GetLastError());
    }
}
 
WHRoeder:

I can't see in your prompt any command to delete order. Only alerts if it's not delete or close.

I need to use OrderDelete to delete the order before it's open.

for(pos = OrdersTotal()-1; pos >= 0 ; pos--) {
 if (OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
&&  OrderMagicNumber()  == magic.number             // my magic number
&&  OrderSymbol()       == Symbol() ){              // and my pair. 

if (OrderType() == OP_SELLSTOP || OrderType() ==OP_BUYSTOP){

// And now orderdelete command but i don't know how

 
qjol:

c for yourself

bool OrderDelete( int ticket, color Color=CLR_NONE)


Mabe I see it but I don't know that I see it.

I'm too stupid for this mabe:(

 

Try understanding this program https://www.mql5.com/en/code/7607

But I think the problem lies in your understanding of how programming and in this case functions work. Computer language is very limited and very precise and does the same thing all the time.

So if someone defines a function and says it needs parameters, then that function will only work if it is given parameters the as per its definition.

OrdersTotal() is a function with no parameters defined but that it returns the number of open orders as in integer. There is no need to question how it works but just accept that it does. However we can guess that it sends a mesage or messages to the brokers server counts the openorders and then returns the required value.

If you manually Close an order you can see that you are selecting it and the window title shows the Order# otherwise known at the ticket number and a button to confirm it close, the color parameter is just a convienience to help understand the nature of why the order was closed. Thus that is the information that is sent to the brokers server. If you called a broker to close an order you would say on the phone "please close my Trade Order with ticket/order number 457634" the broker would then confirm "done" but as it is possible that the phone line is bad he might say not done. The result of trying to close and order it either True or False which is known as a Boolean condition as first discribed by the Mathematition Boole years befor computers were invented.

 
Ickyrus:

Try understanding this program https://www.mql5.com/en/code/7607

But I think the problem lies in your understanding of how programming and in this case functions work. Computer language is very limited and very precise and does the same thing all the time.

So if someone defines a function and says it needs parameters, then that function will only work if it is given parameters the as per its definition.

OrdersTotal() is a function with no parameters defined but that it returns the number of open orders as in integer. There is no need to question how it works but just accept that it does. However we can guess that it sends a mesage or messages to the brokers server counts the openorders and then returns the required value.

If you manually Close an order you can see that you are selecting it and the window title shows the Order# otherwise known at the ticket number and a button to confirm it close, the color parameter is just a convienience to help understand the nature of why the order was closed. Thus that is the information that is sent to the brokers server. If you called a broker to close an order you would say on the phone "please close my Trade Order with ticket/order number 457634" the broker would then confirm "done" but as it is possible that the phone line is bad he might say not done. The result of trying to close and order it either True or False which is known as a Boolean condition as first discribed by the Mathematition Boole years befor computers were invented.

Thanks, I'm working to understand how the language works.

So if I give a command:

for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
&&  OrderMagicNumber()  == magic.number             // my magic number
&&  OrderSymbol()       == Symbol() ){              // and my pair.
if (!OrderDelete(OrderTicket()) 
           Alert("OrderDelete(",OrderTicket(),") failed: ", GetLastError()); 

First program have to select the order. When the order is selected in function all the commands are subscribed to this order.

Next program will delete the order and if can't, than will send the alert.

Is that correct?