mq4 programming problem that really drives me nuts! Help very much appreciated

 

I am ashamed to have to ask this, after 10+ years of mq4 programming. I have been programming in general for 30+ years, and one of the rules I use is to extensively look for an answer before asking for it. This time I am desperate, actually. Loosing my faith in MT4 (...ehm), or just losing it.

Please help me out! I found this indicator, accredited to Mladen. Part of it (init() plus relevant decalarations) looks like this: (sorry Mladen, maybe you programmed this a long time ago and don't like it anymore :)

extern string TimeFrame       = "current time frame";
bool   calculatingTma = false;
bool   returningBars  = false;
int    timeFrame;

int init() {
   timeFrame  = stringToTimeFrame(TimeFrame);
   HalfLength = MathMax(HalfLength,1);
   IndicatorBuffers(7);

         SetIndexBuffer(0,tmBuffer);  SetIndexDrawBegin(0,HalfLength);
         SetIndexBuffer(1,upBuffer);  SetIndexDrawBegin(1,HalfLength);
         SetIndexBuffer(2,dnBuffer);  SetIndexDrawBegin(2,HalfLength);
         SetIndexBuffer(3,dnArrow);   SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(5,242);
         SetIndexBuffer(4,upArrow);   SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(6,241);
         SetIndexBuffer(5,wuBuffer);
         SetIndexBuffer(6,wdBuffer);

         if (TimeFrame=="calculateTma")  { calculatingTma=true; return(0); }
         if (TimeFrame=="returnBars")    { returningBars=true;  return(0); }

   IndicatorFileName = WindowExpertName();

   return(0);
}

My problem lies in the two lines that start with if( Timeframe =="...

As we can see TimeFrame (the string with capital T), is a user entry, with default. Now I leave it like this, because I need the current time-frame.

So...the conditions for these ifs never evaluate true. So both variables (calculatingTma and returningBars) always are false, and the return(0) never happens. The indicator as it is, like this, works as it should. Now the funny part:


Since these ifs stand alone, and the conditions always evaluate to false in my case, I can remove them, since they have no effect whatsoever, right?

Nope. When I do so, the indicator gives different outcomes. 

It drives me nuts, I cannot see or grasp what the difference is. Please help! 

I attached the mq4 if anyone feels like trying it out!

Much appreciated, for to me, this is a great anomaly (maybe in my mind)...

Files:
 

This is @Mladen Rakic style. You can't remove them because the indicator is calling itself and use these Timeframe values internally. See the iCustom call in OnCalculate.

 
Alain Verleyen:

This is @Mladen Rakic style. You can't remove them because the indicator is calling itself and use these Timeframe values internally. See the iCustom call in OnCalculate.

Wonderful, I just looked into the rest of the code e.g.   

 tmBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,"calculateTma",HalfLength,Price,BandsDeviations,0,shift1);

     

and found it out a minute ago. Came back in the attempt to delete my stupid post, and your answer was already there! It was kind of funny to immediately see confirmed what just came into view.

So now I really didn't look into it far enough initially. Thanks for your very kind swift reply!