[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 5

 
Roman.:

Don't you rule out the option of the first order turning into a market order and, as a consequence, not being able to remove it with this cycle on limit orders?

I am running a visualisation. At the moment when the order should be deleted it remains pending. I know how to set the magic number but I cannot delete the first of two pending orders.
 
Roman.:

Apparently for that - a few posts above :-))) - "The easiest way to determine which order of two to close is by the magic number. Assign them different numbers when you set them up. The example you showed above lacks this check. Also instead of ticket write OrderTicket()."

OrderTicket() will probably get the ticket of the last pending order, I need the penultimate one.
 
Andreev:

OrderTicket() will probably get a ticket of the last pending order, and I need the last but one.

If you are placing two pending orders, it's probably easier to give the first one a 1 and the second a 2. ))

Then, both you and the Expert Advisor will not be confused by the numbers.

 

alex12, it's already good to start writing something. A lot of errors, but still not bad.

1. Both compilation errors are because in the same start() you define local variables SL and TP twice. You must define them once inside the function, otherwise it will cause an error.

Remove type double in the second calculation of both variables and the error will disappear. But that's not all.

2. Are you sure you need global external variables with the same names? The problem is that the SL variable defined inside the function is different than the global variable with the same name. If you want it to be exactly the same variable as the external (extern), remove double at it everywhere.

3. The condition if() is usually a logical condition, although simple calculations are not forbidden by syntax. And you just don't have a logical condition.

Practice on simple programs first, such as calculations with output. Then you will understand the syntax.

 
Andreev:

OrderTicket() will probably get the ticket of the last pending order, and I need the last but one.

You need to remember the time when the order was placed and then compare the time in the loop and delete the oldest order, so - check here and plug it into your EA.
 
Mathemat:

alex12, it's already good to start writing something. Lots of mistakes, but still not bad.

1. Both compilation errors are because in the same start() you define local variables SL and TP twice. You have to define them once inside the function, otherwise it will cause an error.

Remove type double in the second calculation of both variables and the error will disappear. But this is not all.

2. Are you sure you need global external variables with the same names? The problem is that the SL variable defined inside the function is different than the global variable with the same name. If you want it to be exactly the same variable as the external (extern), remove double at it everywhere.

3. The condition if() is usually a logical condition, although simple calculations are not forbidden by syntax. And you simply do not have a logical condition.

Practice on simple programs first, like calculations with output. Then you will understand the syntax.

Thank you very much.
 
Roman.:

You memorise the time of placing orders, then also in the cycle you compare the time - delete the oldest one, like this - look here and connect it to your EA.

Thanks for the link! I will study it :) I have a good idea with time, as well as with magic number and order type (bylimit or selllimit). But you probably didn't quite understand me. My problem is not marking the order, but HOW TO REMOVE IT. I am only able to delete the last pending order no matter how I define the penultimate order.
 

Andreev:

Thanks for the link!!! I'll look into it :) With time, as well as magik number and by order type (bylimit or selllimit) - good idea. But you probably didn't quite understand me. My problem is not marking the order, but HOW TO REMOVE IT. I am only able to delete the last pending order no matter how I define the penultimate one.


If you take at least one of the tips offered to you (magician, type, setting time), you won't have a problem deleting exactly the order your trading strategy implies. ))

Use two criteria in your selection, e.g. installation time and type or type and magik.

 
Andreev:

Thanks for the link!!! Will look into it :) With time, as well as magic number and by order type (bylimit or selllimit) is a good idea. But you probably didn't quite understand me. My problem is not marking the order, but HOW TO REMOVE IT. I am only able to delete the last pending order, no matter how I define the penultimate order.

I am correcting my code according to your terms - I will post it here now.
 
Andreev:

OrderTicket() will probably get a ticket of the last pending order, and I need the penultimate one.


Recalculate with each tick the number of pending orders.

If there are fewer of them, it means that one pending order has become a market order.

All of the remaining ones (which have become unnecessary) can be deleted.

Reason: