Errors, bugs, questions - page 3178

 
Andrei Sokolov #:

Now I came across an algorithm where afterOrderSelect() there are more OrderSelect() calls, so I think that a warning is needed if afterOrderSelect() there are more OrderSelect() calls and the enclosed OrderSelect() "selects" another order.

Suppose you write a loop:
for(int i=...; ....; i++) {
...
}
And inside the loop, the iterator i changes its value under a certain condition.
You also need to display a warning, don't you think?

 
Sergey Gridnev #:
Suppose you write a loop:
for(int i=...; ....; i++) {
...
}
And inside the loop, the iterator i changes its value under a certain condition.
Do you think a warning must be generated too?

+++ Control of a ticket or a function variable in an array of the same function or structure, or temperature and pressure in the patient's x, not y.

ZY control X or igc)))) not temperature)))
 
Sergey Gridnev #:
Suppose you write a loop:
for(int i=...; ....; i++) {
...
}
And inside the loop, the iterator i changes its value under a certain condition.
Do you think a warning should be generated too?

Yes.
But I think there's no sense in discussing it further since I don't think the warning will be implemented with such conditions.

 
Andrei Sokolov #:

Yes.
But I think there is no point in discussing it further, because I don't think the warning will be implemented with such conditions.

In bayscore it's a harm in general, and here top-down with loops won't improve programming environment and algorimization either.

It's just the rigor and correctness of the algorithms. No more. and an understanding of the rules and possibilities of the language.

 
Andrei Sokolov #:

Yes.
But I don't think there's any point in discussing it further as I don't think the warning will be implemented with these conditions.

From the very beginning the point of discussing this question was completely absent. You are writing about a problem with mql4, in the thread where mql5 problems are discussed. If you had said from the start that the question concerns mql4, no one would have answered you.

 
Alexey Viktorov #:

You write about a problem in mql4, in a thread where mql5 problems are discussed.

Where is this stated?

 
Alexey Viktorov #:

From the very beginning, the point of discussing this issue has been completely absent.

Alexei, first you tried to point, now you are trying to decide for others where it makes sense and where it does not.

If there is no constructive answer, you could not provoke such pointless correspondence.

 
Andrei Sokolov function calls.

Yesterday all night looking for the bug, and this is the second time for this reason.

void Trailing()
{
   for(int i=OrdersTotal()-1; i>=0; i--)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      {
         if (OrderSymbol() == Symbol() && OrderMagicNumber()==magic)
         {
            if(OrderType() == OP_BUY)
            {
               if(Bid >= GetAveragePrice(OP_BUY)+start_tral_level*Point)//OrderOpenPrice()
               {
                  if(Bid >= OrderStopLoss()+(tral_stop+tral_step)*Point || OrderStopLoss()==0)
                  {
                     if(!OrderModify(OrderTicket(), OrderOpenPrice()
                     , NormalizeDouble(Bid-tral_stop*Point, Digits), OrderTakeProfit(), OrderExpiration())) 
                     {
                        Print("Trailing buy err ", GetLastError());
                     }
                  }
               }
            }
            if(OrderType()==OP_SELL)
            {
               if(Ask <= GetAveragePrice(OP_SELL)-start_tral_level*Point)//OrderOpenPrice()
               {
                  if(Ask <= OrderStopLoss()-(tral_stop+tral_step)*Point || OrderStopLoss()==0)
                  {
                     if(!OrderModify(OrderTicket(), OrderOpenPrice()
                     , NormalizeDouble(Ask+tral_stop*Point, Digits), OrderTakeProfit(), OrderExpiration())) 
                     {
                        Print("Trailing sell err ", GetLastError());
                     }
                  }   
               }   
            }   
         }
      }
   }
}
double GetAveragePrice(int in_type)//расчет средней цены позиций
{
   double dRes=-1;
   double dSum=0;
   double dLot=0;
   double dComission=0;
   double dSwap=0;
   int iTotalPos=OrdersTotal();
   for(int cnt=0;cnt<iTotalPos;cnt++)
   {
      if(!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) Print( "Error Select Order");
      {
         if(OrderType()==in_type && OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
         {
            dSum+=OrderOpenPrice()*OrderLots();
            dLot+=OrderLots();
            dSwap+=OrderSwap();
            dComission+=OrderCommission();
         }
      }    
   }     
   if(in_type==OP_BUY && dLot!=0) dRes=dSum/dLot-dSwap/dLot*Point-dComission/dLot*Point;
   if(in_type==OP_SELL && dLot!=0) dRes=dSum/dLot+dSwap/dLot*Point+dComission/dLot*Point;
   
   return dRes;
}
You have already received a lot of constructive answers. It only remains for the drummer to pay attention to the discussion of mql4 problems in this thread...
 
Alexey Viktorov #:

This code makes it clear that it's about mql4. I wish I had paid attention to it at first.

You have already received a lot of constructive answers. It only remains for Tumblr to pay attention to the discussion of mql4 problems in this thread...

Where does it say thatonly mql5 problems are discussed?

 
Andrei Sokolov #:

So where does it say thatonly mql5 problems are discussed ?

mql4 is on reserve - there is a separate section on the forum for it. Everything else is mql5