NEED HELP - GlobalVariableGet() acts weird

 

Hello mates,

I now know how to attain a variable value from custom indicator to EA by using GlobalVariableGet().

Custom indicator is ZZ_Repaint.mq4 with two variables "min,max" as lowest,highest values of most recent zigzag. So these values must be changed every tick.

Please look closer its code as below:

//Global Variable set for min,max
GlobalVariableSet(max_max,max);
GlobalVariableSet(min_min,min);

In the EA code, I use Print(GlobalVariableGet(max_max)) then it always return most recent tick which is correct to me. But if I try to use If () Print (); then it always turn last value from last bar (not recent forming bar).

Is there something wrong I did?

Any comment you have pls post...Thanks

 
   double min, max;
if (counted_bars==0) {
}
else{
         if( curlow>=lastlow ) { lastlow=curlow; }
         else {...}
            if( curhigh<=lasthigh )  { lasthigh=curhigh;}
            else {...}
}
    // Set global Variables for max,min values
     GlobalVariableSet(max_max,max);
     GlobalVariableSet(min_min,min);
If the indicator doesn't execute the ... code then min, and max are never set.
Reason: