Organising the order cycle - page 15

 
Alexey Viktorov:

How about replacing GetAmountPositions with the regular OnTradeTransaction???

Approximately like this:

It won't help. Especially, in your variant there is no independence between OnTick at all.

 
fxsaber:

It won't help. Especially since there is no independence between OnTick at all in your version.

Well, yes. I didn't take into account the fact that it's as far away from tick emulation as the moon is from Mars.

No matter how much delay you make, the OnTick event will not occur until the OnTradeTransaction is executed and nothing will be written in history.

 
fxsaber:

You could do something like this:

   if(Trade.Buy(volume,_Symbol,OP,SL,TP))
     {
      uint retcode=Trade.ResultRetcode();
      if(retcode==TRADE_RETCODE_PLACED||retcode==TRADE_RETCODE_DONE)
         {
         ulong ticket=Trade.ResultDeal();
         for(int n=0;n<500;n++)
            {
            if(!PositionSelectByTicket(ticket)) Sleep(10);
            else return(true);
            }
         }
      else return(false);
     }
   else return(false);
i.e. we just wait until the position is in the list
 
Aleksey Lebedev:

You could do something like this:

i.e. we just wait until the position is in the list
ulong ticket=Trade.ResultDeal(); // В этом месте может быть ноль
 

fxsaber:

It could be zero

Unlikely, by retcode the order is either executed or placed.

If it is zero, we wait 5 seconds for the end of the cycle (perhaps 2-3 is enough).

During this time the list of positions will hopefully be updated.

 
Aleksey Lebedev:

In the meantime, the list of poses will hopefully be updated.

On the dare.

 
fxsaber:

On a dare.

no, the scientific method of the average ceiling)