How to check if an order is selected - page 9

 
Vinin:


I didn't ask anyone in particular.

But you must have been right to take it personally.

I can't call you a fool, but you are deaf, that's for sure.

You do not hear others. I'm not talking about my remarks, but about the advice you've been given.

Have you ever written interoperable programs?

What Ant_TL asks is "interoperability", but it cannot be implemented in MQL.

 
PapaYozh:

Have you ever written an interoperable program?

What Ant_TL is asking about is "interoperability", but it's not feasible in MQL.


It's not hard to implement. And there is a solution in principle. Too lazy to read further
 
Such a solution may be viable for closed positions, which will no longer change. But for open positions, it is not worth doing
 
Vinin:

It is not difficult to implement. And there is a solution. Too lazy to read further

You will not be able to execute operations with orders and make sure the environment is not affected.

It has already been said about GetLastError(), you will not be able to restore the code that should be returnedby function GetLastError().

 
PapaYozh:

You will not be able to execute operations with orders and be sure that the environment will not be affected.

It has already been said about GetLastError(), you will not be able to recover the code that the GetLastError() function should have returned.


You can if you want, it will just have its own function ( I meanGetLastError())
 

This may look like a solution - OrderSelect() - MySelect() wrapper for use in functions that search for orders by index

int last_select=0; // put it somewhere before init and start

// ...... program code

bool MySelect(int i,int mode=MODE_TRADES){ // order selection - returns True if the order is selected and belongs to the EA, False otherwise
if(OrderSelect(i,SELECT_BY_POS,mode)){
last_select=OrderTicket();
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
return(true);
else
return(false);
}
return(false);
}

bool TickSelect(int tick){ // Order selection directly by tick
if(OrderSelect(tick,SELECT_BY_TICKET))
last_select=tick;
else
return(false);
return(true);
}

void SomeFunc(){ // A function template that can break the order selection and therefore break the program logic, if the current order selection is not taken care of
int tick=last_select;

// ... perform required actions

if(tick>0)
TickSelect(tick);
}

 
Ant_TL:

It cannot, unless you change this state yourself in the program.

It is assumed that the order state has changed from MODE_TRADES to MODE_HISTORY. And your Expert Advisor has not done anything with the order. Is it the same order or is it different?

 
Mislaid:

It was assumed that the order status changed from MODE_TRADES to MODE_HISTORY. And your EA has not done anything with the order. Is it the same order or is it different?

It is the same order

 
I don't see the problem. And there's a lot of fuss going on... You need to select an order in one main function A(), and in another function B(), called from main function A(), process the order selected in function A(). And we should know for sure in function B() whether or not the order is still selected... So pass to function B() the ticket of the order selected in function A(). In function B(), you can check from which list the order is selected and then decide where to go and what to return back to function A()...
 
Ant_TL:

This may look like a solution - OrderSelect() - MySelect() wrapper for use in functions that search for orders by index

int last_select=0; // put it somewhere before init and start

// ...... program code

bool MySelect(int i,int mode=MODE_TRADES){ // Selection of the order we need - returns True if the order has been selected and belongs to the Expert Advisor; otherwise, False
if(OrderSelect(i,SELECT_BY_POS,mode)){
last_select=OrderTicket();
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
return(true);
else
return(false);
}
return(false);
}

bool TickSelect(int tick){ // Order selection directly by tick
if(OrderSelect(tick,SELECT_BY_TICKET))
last_select=tick;
else
return(false);
return(true);
}

void SomeFunc(){ // A function template that can break the order selection and hence break the program logic, if the current order selection is not taken care of
int tick=last_select;

// ... perform the required action

if(tick>0)
TickSelect(tick);
}

Let's imagine what will happen to last_select variable after the terminal is restarted (the bad guys turned off the light)
Reason: