Multicurrency advisor question - page 12

 

Afternoon. Function MiniMaxOrderPrice(Symbol(), -1, OP_BUYSTOP, 1 )

correctly displays a ticker order which is currently further away from the current price than other orders.

I have to delete this "far away" order if the number of placed orders exceeds the specified value.

I do it like this:

//--------Удаление лишних ордеров--------------

if ( NumberOfOrders(NULL,OP_BUYSTOP,-1)> Количество_ордеров_  ){
//если число ордеров больше заданного

 for (int v=0; v<OrdersTotal(); v++)                                   {       
  if (OrderSelect( v, SELECT_BY_TICKET, MODE_TRADES))                    {
// перебираем по тикету
           
   if (OrderSymbol()==Symbol())                                        {                  
    if (OrderType() == OP_BUYSTOP)     { выбираем байстопы 


if (OrderTicket()== MiniMaxOrderPrice(Symbol(), -1,OP_BUYSTOP,1) )
//если тикет равен тикету самого дальнего ордера, - удаляем его

{     OrderDelete(OrderTicket(),Yellow);     return(0);    }
             }}}}} 


But unfortunately it is not the furthest order which is deleted (if it is deleted) at all.

However, I can see in the comment and on the chart that the function

MiniMaxOrderPrice(Symbol(), -1,OP_BUYSTOP,1)
it's the furthest away ticket that's returned.

But it is the furthest order that is removed. And then, after several deletions, we start getting 4108 order deletion errors (wrong ticket/unknown ticket).

Apparently there is an error in the code in the last 2-3 lines.... !

Please advise where there could be an error ...? ??


 
rid писал(а) >>

Afternoon. Function MiniMaxOrderPrice(Symbol(), -1, OP_BUYSTOP, 1 )

correctly displays a ticker order which is currently further away from the current price than other orders.

I have to delete this "far away" order if the number of placed orders exceeds the specified value.

I do it like this:


But unfortunately it is not the furthest order that is deleted (if it is deleted).

Although, in the comment and visually on the chart, I see that the function

returns the ticket exactly the furthest away.

But it deletes the close one for some reason. And then, after several deletions, the 4108 order deletion errors start happening (wrong ticket/unknown ticket.)

Apparently there is an error in the code in the last 2-3 lines.... !

Please advise where there could be an error ...? ??

int DeleteTicket= MiniMaxOrderPrice(Symbol(), -1,OP_BUYSTOP,1);
OrderSelect( DeleteTicket, SELECT_BY_TICKET);
OrderDelete(OrderTicket(),Yellow);  
You could do something like this, although I'm not sure it's the best option
 
Thank you. I'll give it a try.
 

Yeah...

It seems that sorting by ticket in this situation is a tricky business and not quite correct.

The program gets confused in the tickets! It's getting delayed on the way out. Deletes orders out of order...

I will try to set orders with different mages. And then sort by magician with all the implications...

 

If you don't mind, I can take a look at the whole code, check it out. vinin@mail.ru

 

OK! Thank you. I'll clean up the snot in the code, brush it up and send it over.

 

Can you please tell me something. If I open a bunch of charts and put an EA on each chart, will each of them work or only the one in the active chart window?

 

Yes - this is likely to be the case. All EAs will work, in all windows.

Also, take a look at EA parameters.

There must be an option Magic or something similar. SIMILAR.

That is, this is the parameter by which the EA distinguishes "alien" orders and positions from its own!

As the poet said! -

If a man is faithful to me - he is my brother,
An unfaithful brother is my enemy, damn him a hundredfold.
Medicine is sometimes more dangerous than poison,
Disease sometimes cures poison. (O.H.)

In other words, warrants put up by another expert, with another magician, each particular expert does not pay attention. And exhibits and "picks up for modification" or closes only their own, with the magician specifically set by him!

That's it...

 

I wonder if everyone has their own wizard and only one allowable position at a time, will the EA open a position if there is already an open position

by another EA?

 

The question is vaguely phrased, but I understood it.

The answer is - Yes! - of course it will! For it is said:

Who in the cup of life shall gleam a drop?
Thou or I? He will glisten and vanish.
And the cupbearer of life, - millions
Radiant splashes and spills and will spill.(0.X.)

//-------------------------------------------------------------

Regardless of whether there are open positions in the terminal for this instrument. Opened manually or by another Expert Advisor.

But if the magik of these open positions does not match the magik of the specific EA in question, then this EA will open its own position with its own magik! Notwithstanding the presence of other (with a different Magician) positions for this instrument.


Reason: