iTime question - page 2

Agent86
1059
Agent86  
And this

if(b>c)
      {
       Print(b, " b");
       Print(c, " c");
I changed the scheme to b and c

Anyhow this will print (b) no problems and never 0

However,

if(c>b)
      {
       Print(b, " b");
       Print(c, " c");
this print (c) all the time no problem but b = 0 so I have something wrong here, but I don't know what or why ?

Back to the drawing board it would seem
Agent86
1059
Agent86  
int i=0;                 
   val1=iFractals(NULL, 0, MODE_UPPER,3);
   val2=iFractals(NULL, 0, MODE_LOWER,3); 
   double   faster = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,3), //MODE_MAIN
            slower = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,3); //MODE_SIGNAL
               
                
   if(val1 > 0 && faster > slower)
      {
       Print (val1, " val1");
       Print(TimeToStr(Time[3],TIME_DATE|TIME_MINUTES), " = val1 time");      
       datetime b = Time[3];  
  
      }
   if(val2 > 0 && faster > slower)
      {
       Print (val2, " val2");
       Print(TimeToStr(Time[3],TIME_DATE|TIME_MINUTES), " = val2 time");
       datetime c = Time[3]; 
      }
      
   if(c>b)
      {
       Print(b, " b");
       Print(c, " c");
       //Print (TimeToStr(a,TIME_DATE|TIME_MINUTES), " a");
       //Print (TimeToStr(b,TIME_DATE|TIME_MINUTES), " b");
      }       
updated version, with same empty value problem
Simon Gniadkowski
17179

Slow down, read through and follow your code step by step by step . . . follow what happens to the value of b (or a) for each possible outcome of each conditional statement . . .

I'm assuming b isn't a static so for each tick b starts as undefined ( set to 0 ). val1 and val2 are the Fractals, they can't both be greater than 0 for each bar . . . so when val1 > 0 val2 will be <= 0 . . . so if val1 > 0 b has a value but c will be set to 0, so in this case c will not > b so the values for b & c will not get printed.

Agent86
1059
Agent86  
RaptorUK:

Slow down, read through and follow your code step by step by step . . . follow what happens to the value of b (or a) for each possible outcome of each conditional statement . . .

I'm assuming b isn't a static so for each tick b starts as undefined ( set to 0 ). val1 and val2 are the Fractals, they can't both be greater than 0 for each bar . . . so when val1 > 0 val2 will be <= 0 . . . so if val1 > 0 b has a value but c will be set to 0, so in this case c will not > b so the values for b & c will not get printed.


I partially understand this but at least I understand iTime, Time[], and TimeToStr a bit better now

So I guess this is nor really related to the time subject so if I have other trouble with it I'll post another thread

Thanks