[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 187

 

Hi all. My history search doesn't return the volume of lots. Is this the way to do it?


if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
   {
   if(OrderType()==0)
      {
      Comment("\n\n\n",OrderLots()," ",OrderTicket());
It returns the lot 0.1, although lots are changed by the program. tickets are displayed correctly (change). a bug? a bug?
 
Pyro:

Hi all. My history search doesn't return the volume of lots. Is this the way it's supposed to be?


It returns 0.1 lots, although lots are changed by the program. Tickets are reflected correctly (changed).


Don't look for "bugs and features" in everything - sometimes the door opens very simply ... :-)

Where's the order loop?

 
 if(OrdersHistoryTotal() != 0)
   {
    for(int counter = OrdersHistoryTotal()-1; counter >= 0; counter--)
      {
       OrderSelect(counter, SELECT_BY_POS, MODE_HISTORY);
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
         {
          if(OrderType() == OP_BUY || OrderType() == OP_SELL)   
             Comment("\n\n\n",OrderLots()," ",OrderTicket());                        
         }
      }
   }
 
Pyro:

Hi all. My history search doesn't return the volume of lots. Is this the way to do it?


It returns the lot 0.1, although lots are changed by the program. tickets are displayed correctly (change). a bug? a bug?


See code analogue, edit, try:

 //---------------------расчет по истории ордеров номера очередной итерации----------------------------------------------- 
  Iteration = 0; // зануляем инерации перед их учетом в цикле по истории
  Sum_Loss = 0;  // суммарный убыток по этим итерациям

datetime 
Time_at_History_Current = 0,
Time_at_History_Previos = 0;  
    
 
 if(OrdersHistoryTotal() != 0)
   {
    for(int counter = OrdersHistoryTotal()-1; counter >= 0; counter--)
      {
       OrderSelect(counter, SELECT_BY_POS, MODE_HISTORY);
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
         {
          if(OrderType() == OP_BUY || OrderType() == OP_SELL)
            {
             if(OrderProfit() < 0) // если убыток по выбранному ордеру, то считаем суммарный и записываем время закрытия ордера
                                   // для последующего его анализа при подсчете количества итераций
                {
                 double lastLoss = OrderProfit();
                 Sum_Loss=Sum_Loss+lastLoss;  // считаем общий убыток по закрытым подряд убыточным ордерам
                 Time_at_History_Current = OrderCloseTime();
                } 
             
             //Print(" Time_at_History_Current_в цикле = ", TimeToStr(Time_at_History_Current, TIME_DATE|TIME_SECONDS));
             //Print(" Time_at_History_Previos_в цикле = ", TimeToStr(Time_at_History_Previos, TIME_DATE|TIME_SECONDS));
             
             if(Time_at_History_Current != Time_at_History_Previos) // если они не равны, то считаем итерации и делаем их равными
               {
                Time_at_History_Previos = Time_at_History_Current ;
                Iteration++;
                //Print("Iteration at History в условии сравнения  = ",  Iteration);
               }   
             else // они равны, то проверяем, дополнительно, наличие профита по выбранному следующему ордеру и выходим из цикла
               {
                if(OrderProfit() >= 0)
                  break;
               }
            }
         }
      }
   }
 

Roman


I don't need a cycle. I need to get the LOT of the last order, no matter which one, I don't need filtering. There is nothing about LOT in the example. I am puzzled.

 
Pyro:

Roman


I don't need a cycle. I need to get the LOT of the last order, no matter which one, I don't need filtering. There is nothing about LOT in the example. I am puzzled.


Have a look - I've made edits to my previous post...
 
I don't get it. A loop is needed when you need to filter by some criteria, like in your case. My task is simpler - to take the last order from the history. By definition, it is closed, and by definition, there are no open positions in the market. Pending orders are not used. I.e., the last order will definitely be the market one. Tickets are returned correctly, lots are not.
 
Pyro:
I don't get it. A loop is needed when you need to filter by some criteria, like in your case. My task is simpler - to take the last order from the history. By definition, it's closed, and by definition, there are no open positions in the market. Tickets are returned correctly, lots are not.

Own! Learn to use the search! :-)
 
Thanks for that :) The problem was something else.
 
MK07:

Thanks for wanting to help. I put if (D_sig==0) { command for signal ; }. "Steps" became less, but still they are there. And it is not clear how they are formed.

I put MathAbs in order to have a "corridor" for comparison, because the probability that the signal lines will be absolutely equal is negligibly small.

Maybe someone else has thoughts on my problem?


I wrote it like this and it displays D_Sig in the comment.

         D_sig=MathAbs(Signal1Buffer[0]-Signa13Buffer[0]);                              // разница между сигнальными линиями 1-ого и 3-ого MACD на
                                                                                        // нулевом баре
if(D_sig==0)  {   D_sig_Last=D_sig; }
      
//       break;          
             
           
              
         
         j++;
         
}             
     
      Comment( "\n"," Баров = ",WindowBarsPerChart()-1, 
               "\n"," Macd1Buffer = ",DoubleToStr(Macd1Buffer[0],4),
               "\n"," Signal1Buffer = ",DoubleToStr(Signal1Buffer[0],4),
               "\n"," Macd3Buffer = ",DoubleToStr(Macd3Buffer[0],4),
               "\n"," Signa13Buffer = ",DoubleToStr(Signa13Buffer[0],4),
               "\n"," D_sig = ",DoubleToStr(D_sig,4));
 
Suggest a "favourite principle" of EA name formation - and that it takes into account the principle of operation and version, etc.