How to check if an order is selected - page 13

 
Ant_TL:

In fact, I encountered a situation where the error was caused by one of the general-purpose functions that could be used both inside and outside the order processing loops, i.e. before an order was selected, which led to the error. If we want to make universal service functions that work with orders and can be used both after an order has been selected and before that, both when there are open orders and when there are no orders at all, we should use such mechanism as I mentioned on the previous page to avoid this error.

I already wrote earlier in this thread about the fact that order selection is not passed to library modules and back.


Anton, happy birthday to you too!
 
grell:

Make yourself accustomed to the fact that each trade operation has its own order select and there won't be any problems. And, yes, you have been correctly written, only one order can be selected. Everything else is solved by arrays.

I wasn't talking about the situation where function B() tries to intercept an order selection from function A() in order to work with it. Bypassing the order selection. The point is different. But it may be useful.

 
tara:

Anton, a happy holiday to you too!

Happy Holidays to you too!

 
FAQ:

You keep forgetting that only one order can be selected at a time. Exit = store the list of orders in a savings pool (your array). one global variable lastorder is not enough. a variant of type lastords[ticket][function] would be better.

Keeping all orders in an array is appropriate for complex grid EAs, but not for all EAs. In my situation, it is like firing a cannon at a sparrow. I am not forgetting that only one order can be selected. I was just pointing out that we wouldn't be able to find out if it was chosen (not any particular order, but if any arbitrary order was chosen at all on this tick, i.e. if an order select was successfully called) without any error. However, one variable of the lastorder type is quite enough for this purpose.

 
Ant_TL:

I wasn't talking about the situation where function B() tries to intercept an order selection from function A() in order to work with it. Bypassing the order selection. The point is different. Although it may be useful.


Well give me an example of a situation so that I understand the need to work with more than one order. By the way, happy holidays!
 
grell:

Well, give me an example of a situation, so that I understand the necessity of working with more than one order. By the way, happy holidays!

Happy Holidays to you too! -))

I'll bring it up as soon as something interesting comes to mind. Situations where it is difficult to do without this mechanism. Otherwise they will immediately give me advice on programming "correctly". ))

 
Ant_TL:

Keeping all orders in an array is appropriate for complex grid EAs, but not for all EAs. In my situation, it is like firing a cannon at a sparrow.


It is your choice if you like to bend a slingshot to fit every sparrow and waste time adjusting it. I prefer to make a cannon for any projectile once and be sure that when it will be necessary to shoot at sparrows - then we'll load buckshot and put all at once :)
 
Ant_TL:

Happy Holidays to you too! -))

I'll bring it up as soon as something interesting comes to mind. Situations where it is difficult to do without this mechanism. Otherwise they will immediately give me advice on programming "correctly". ))


What is there to look for if you are trying to prove that this is an everyday routine situation. You can work with a bunch of orders and still select them one by one without fear of losing sight of the order. And if it's one order, selecting it RETURNS in another function is nothing compared to looking for a black cat in a dark room.
 
grell:

What is there to find, if you are trying to prove that this is a normal everyday situation. You can work with a lot of orders and still take them one by one without fear of losing sight of the order. And if it is one order, selecting it in another function is nothing compared to looking for a black cat in a dark room.

Well, I encountered this situation in one of my EAs, when I called my template function MyTotal() to get the number of all orders, open for a given symbol-magic. Obviously, I used it in a loop in some previous EAs and therefore added saving and restoring the current order selection to it. And then I used it without the loop, before orderselect and that's why I got the error. I want my template functions to be universal and able to be used both in loops and out of loops, so I'll use this template with MySelect/TickSelect wrapper, since I use MySelect in all loops anyway instead of OrderSelect to reduce code size.

I think we can see why in this particular situation we need to handle more than 1 order at a time. We are working with some order in the main loop, and then we call MyTotal, which should go through all orders to determine how many we need.

 
Correct your mistake and go to bed, you have a busy day tomorrow :)