The for loop that drive me crazy, chacun sa bête noire

 

Hi there,

About 2 days I'm on, the for loops always take more time, I need help. At this point, it should re-enter the loop with with Volume - SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN), why doesn't it ?

for (Volume >= SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN); Volume <= SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); Volume - SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN)) {
Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);
if (ConfirmMarginOver(ORDER_TYPE_SELL,Bid,Volume) == false) { printf("Volume %G too big", Volume); return; }
if (ConfirmMarginOver(ORDER_TYPE_SELL,Bid,Volume) == true) {
... bla bla bla
}
}
 
blouf:

Hi there,

About 2 days I'm on, the for loops always take more time, I need help. At this point, it should re-enter the loop with with Volume - SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN), why doesn't it ?

For loop documentation.

This expression :

Volume >= SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN)

Returns true or false. It should probably be "=" instead of ">=".

Also what is the meaning of

Volume - SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN)

What are you trying to achieve ?

 
angevoyageur:

For loop documentation.

This expression :

Returns true or false. It should probably be "=" instead of ">=".

Also what is the meaning of

What are you trying to achieve ?

I want the volume to be tested from max lot to min lot : ie. from 50 49.99 49.98 etc ... I read the documentation but I always have been clumsy with the for, in many languages :/

But the volume is set higher above :

Volume = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
 
blouf:

I want the volume to be tested from max lot to min lot : ie. from 50 49.99 49.98 etc ... I read the documentation but I always have been clumsy with the for, in many languages :/

But the volume is set higher above :

   double Volume;  
   for (Volume = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); 
        Volume >= SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN); 
        Volume -= SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP)) 
         {
           printf("Volume=%f",Volume);  
         }
  
 
angevoyageur:
Perfect ! I wasn't that far the solution :p Thank you ! BTW I didn't know that one "-=".
 
blouf:
Perfect ! I wasn't that far the solution :p Thank you ! BTW I didn't know that one "-=".
   double Volume;  
   for (Volume = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); 
        Volume >= (SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN) && (!VolValueFind)); 
        Volume -= SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP)) 
         {
        printf(Volume);
        if (VolValueFind) { printf("Value find !"); break;  }
         }

Yeah ? It doesn't want to break.  Even if I had a variable as a trigger. I hate the loop.

Got it : it made it on each tick, but on big candle it make it more than once, how to tell it to choose the last one made of the last candle forming ?

Reason: