Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 430

 
Well the chimera is not crucial, in general it should work, I only have a question about count, it is incremented at bays and sells, but there is a quantity check tied to it.
 
splxgf:

Why are k and n compared to the total number of closed orders?

Thenumber of orders will be counted only for orders of the otype type:
Well that chimera is not crucial, in general it should work, I only have a question about count, it is incremented during bays and sells, but there is a check on the quantity tied to it.

The otype parameter is passed to the function, and for this particular call count will only be counted for orders of otype.

 
Mr.Profit:

The otype parameter is passed to the function, and for this particular call count will be counted only for orders of otype.


The function can be compressed a couple of times. We have already implemented it and we have seen that it works in real time. (for real we need a separate function to close orders with RefreshRates and other stuff).

double n = NormalizeDouble (CTbuy/2,1);

if (count<n) 

For example, four CTbuy orders will be open, divided by two, they will be two. The comparison condition will close only one.

P.S. Although, no, I am not. but the question of what we don't like remains open.

 
splxgf:

but the question of what you don't like remains open.


Even my option on the previous page?
 

Folks, why bother with the problem of deleting part of the grid:

Array the values of the tickets in the first search without deleting, and then just go through the array and delete everything by ticket - and nothing will jump anywhere and the right order will be there.

 
Mr.Profit:

Even my version on the previous page?

void CloseHalfOrders(int otype) {
  if (otype!=OP_BUY || otype!=OP_SELL) return;
  int count = CountTrades(otype)/2; 
  for (int i =0; i<OrdersTotal();i++) 
    if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES))
       if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType() == otype){
         if (otype == OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,0,Lime); 
            else OrderClose(OrderTicket(),OrderLots(),Ask,0,Lime);
         count--; i--;
         if (count<1) return;
         Sleep(1000);
       }
}
You can optimise forever.
 
splxgf:

Optimisation can take forever.

if (otype!=OP_BUY ||&& otype!=OP_SELL) return;
;-)
 

Good afternoon. I am a newbie. Something strange has happened to my account. Please help me with advice.

Stop loss did not trigger in demo. The loss on the set SL should be about 50, but in fact it bit off 158. How did this happen?

 
moloko:

Good afternoon. I am a newbie. Something strange has happened to my account. Please help me with advice.

Stop loss did not trigger in demo. The loss on the set SL should be about 50, but in fact it bit off 158. How did this happen?

It's good that it's a demo, but it's more of a question for the brokerage company, it's more of a coding forum.
 
evillive:
It's good that it's a demo, but it's more of a question for the DC, it's more of a coding forum anyway.

Thanks for the tip.