[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 503

 

to sergeev:

Yes, I got a bit confused there, thanks. But still no order with take profit is selected.


to Roger, abolk:

Oops, forgot with the problems and didn't even notice. Thank you!

 
Solree:

Yes, I got a bit confused there, thank you. But still no order with a take profit is selected.

Where is the corrected loop code?
 

to sergeev:

I thought there was just one fix, which you don't need to write. But if you have to, there you go:

for (int a = 0; a < OrdersTotal(); a++)
    if (OrderSelect(a, SELECT_BY_POS, MODE_TRADES))
        if (OrderComment() == "Aelit" && OrderType() == OP_SELL)
            OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), 0);
 
Solree:

I thought there was just one correction there that didn't need to be written. But if you have to, there you go:

You still don't get it. Let me explain it to you.

at the beginning of the loop you have a=0 and OrdersTotal()=2

after the first deletion, you have a=1 and OrdersTotal()=1

that's it. there will be no second iteration. and only one order remains. do you understand?

what conclusions can you draw? i.e. what are the two solutions to the problem?
 

Hello! Please help me. I need the indicator to calculate the sum of the volumes. Something is not working for me.

#property indicator_separate_window    
#property indicator_buffers 1       
#property indicator_color1 Blue  
 
double Buf_0[];           
//--------------------------------------------------------------------
int init()                        
  {
//--------------------------------------------------------------------
   SetIndexBuffer(0,Buf_0);       
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);
//--------------------------------------------------------------------
   return;                     
  }
//--------------------------------------------------------------------
int start()                        
  {
   int i,                         
       n,                         
       Counted_bars;              
       double
       Sum;                      

//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); 
   i=Bars-Counted_bars-1;           
   while(i>=0)                     
     {
      Sum=0;                 
      for(n=i;n<=i+1;n++) 
        {
         Sum=Sum + Volume[n];    
        }
      Buf_0[i]=Sum;   
      i--;                         
     }
//--------------------------------------------------------------------
   return;                         
  }
//--------------------------------------------------------------------
 

to sergeev:

In OrderSelect 0 is also a position, i.e. if there are 2 orders, their positions are 0 and 1.

 
Solree:

In OrderSelect 0 is also a position, i.e. if there are 2 orders, their positions are 0 and 1.

Yes. There are two orders. And OrdersTotal will return 2.

Please read it again.

If you do not believe me, then use the Print in the journal

 
prom18:

Hello! Please help me. I need the indicator to calculate the sum of the volumes. Something is not working for me.


Yeah, it seems to be working.

 
prom18:

Hello! Please help me. I need the indicator to calculate the sum of the volumes. Something is not working for me.


Yeah, it seems to be working.

 
Vinin:


It seems to be working.

I meant Volume[100]+Volume[99]+...+Volume[1]. The graph should look like an increasing curve.
Reason: