How to check if an order is selected - page 7

 
tara:

Spain too:)
Spain is southern and Barcelona has a very mild climate without cold and unbearable heat, and the city itself is very beautiful and compact, so I, as a Muscovite, liked it very much!
 

The TS wants to take advantage of an undocumented feature of MT4. The OrderSelect() function creates a pointer (TC calls it "order selected") that is global to the EA (script). The following two scripts illustrate this

The pointer created by this called procedure is available in the calling procedure:

int start()
{
   ordsel();
   Print( OrderTicket( ) );
   return(0);
}
void ordsel()
{
   OrderSelect( 1, SELECT_BY_POS, MODE_HISTORY );
   Print( OrderTicket( ) );
}

2013.02.17 02:50:48 111 EURUSD,H1: uninit reason 0
2013.02.17 02:50:48 111 EURUSD,H1: 18338793
2013.02.17 02:50:48 111 EURUSD,H1: 18338793
2013.02.17 02:50:48 111 EURUSD,H1: loaded successfully

The created pointer is available in the called procedure:

int start()
{
   OrderSelect( 1, SELECT_BY_POS, MODE_HISTORY );
   Print( OrderTicket( ) );
   ordsel();
   return(0);
}
void ordsel()
{
   Print( OrderTicket( ) );
}

2013.02.17 02:56:10 111 EURUSD,H1: uninit reason 0
2013.02.17 02:56:10 111 EURUSD,H1: 18338793
2013.02.17 02:56:10 111 EURUSD,H1: 18338793
2013.02.17 02:56:10 111 EURUSD,H1: loaded successfully


But it is kind of creepy to use it.

 
tara:
You should get married, brother.
What for? Lots of people live here without registration and with children. Why pay all kinds of fees? Then I've had everything, so there's no need.
 
Ant_TL:

Well, apparently everyone here is super cool, but I'm afraid if I start focusing on the coolness aspects of it all I'm going to get a banhammer in the head from Mr FAQ, who is no doubt cool too. So thanks to everyone who took part in the discussion, the topic can probably be closed since no one is interested in this question except me.

Maybe, the name of the topic was misleading, it should have been called"How to check if the current order in mql4 is currently selected" or something like that. Otherwise, some educators need to spell out questions to the level of bucs.


1) I think it's your"awesomeness" that makes your eyes water.

2) If you continue to be rude, you will get exactly what you call a "banhammer" for educational purposes.

3) Your message (in bold) has been understood without any "spelling out" since page 2 and I (as for those who are in the tank) have already answered no. There is no such warrant, if you want to have one, take care of it yourself and well in advance.

4) You can write as long programs as you want, but if you have a gap in knowledge and want to fill it at the expense of society (which is what this forum is for), then try to behave decently.

 
Mislaid:

The TS wants to take advantage of an undocumented feature of MT4. The OrderSelect() function creates a pointer (TC calls it "order selected") that is global to the EA (script). As demonstrated in the following two scripts

But it's creepy to use it.

Why undocumented and why weird? This always works, except for custom libraries, because apparently this "pointer" is global only within an EA or a script module, and a library module has its own pointer.

 
FAQ:

3) Your message (in bold) is already clear without "spelling it out" from page 2, and I (as for those in the tank) have already answered no. There is no such warrant, if you want to have one, take care of it yourself and well in advance.

4) You can write as long programs as you want, but if you have a knowledge gap and want to fill it at the expense of society (which is what this forum is for), then try to behave decently.

What other warrant isn't there? I don't have any gap in knowledge, that's your fiction. I drew attention to a problem, which I think is a gap in the mechanism of working with orders in mql4, that's all. If a number of functions work with a highlighted order, it should be possible to check whether an order is highlighted or not, so as not to generate an error. I understand that you can contrive crutches, memorize order selection in a dozen places, pass a parameter so as not to make a mistake, and so on.

FAQ:

2) If you continue to be rude, you will surely get what you call a "banhammer" for educational purposes.

The fact that your friend bori was rude to me for several pages obviously passed by your keen eyes. You're being selective.

 
Ant_TL:

What other warrant isn't there? I don't have any gap in my knowledge, that's your fiction. I pointed out the problem, which I think is a gap in the mechanism of working with orders in mql4, that's all. If some functions work with a selected order, we need to be able to check whether an order is selected or not, so as not to generate an error. I understand that we can make crutches, remember to select an order in a dozen places, send a parameter not to make a mistake, and so on.

There is no gap in mql4. The state of the selected order can change during any operation with orders: open/close, take/stop, execute/delete a pending order, or partially close an order. So we don't need to memorize and transmit anything. You should never count on the fact that the state has not changed. An order may be selected, but it is no longer the same.
 
Mislaid:
There is no gap in mql4. The state of a selected order may change during any operation with orders: open/close, take/stop, execute/delete a pending order, or partially close an order. Therefore, we should not memorize and transmit anything. You should never count on the fact that the state has not changed. An order may be selected, but it is no longer the same.

I pointed to a specific situation: we have a main loop that works with orders. And there are a number of auxiliary functions that are used in this loop, which also work with orders. The logic of the main loop must not be broken after these functions are called. This means that if an auxiliary function affects working with orders, it should remember the state of the "pointer" at the moment of its call and return it to the state it was in when it was finished. But it cannot do it without crutches and generating errors. This is exactly a gap here.

In fact, as I wrote in the first post, ignoring the need to control the "pointer" state in auxiliary functions can lead to hard-to-detect errors.

 
Ant_TL:

I pointed to a specific situation: we have a main loop that works with orders. And there are a number of auxiliary functions that are used in this loop, which also work with orders. The logic of the main loop must not be broken after these functions are called. This means that if an auxiliary function affects working with orders, it should remember the state of the "pointer" at the moment of its call and return it to the state it was in when it was finished. But it cannot do it without crutches and generating errors. This is exactly a gap here.

In fact, as I wrote in the first post, ignoring the need to monitor the "pointer" state in auxiliary functions can lead to hard-to-detect errors.

Suppose you have passed your EA to someone. You do not know if he/she has other EAs working, maybe he/she is trading hands himself/herself.

Maybe, you have finished this EA and start writing a new one. This is where the old one will glitch.

 
Mislaid:

Suppose you have passed your EA to someone. You do not know, maybe he has other EAs working, he trades his own hands.

Maybe you have finished this EA and start writing a new one. That's where the old one will glitch.

Excuse me? What does this have to do with who I gave the Expert Advisor to? Do you think that the state of the "pointer" is influenced by any actions of other EAs and the terminal? The "pointer" (the ticket of the currently selected order) is a variable of module level. It would be nice to access it without possible 4105 error generation, which is what I have been writing about all this time