When would this statement be false? - page 2

 
So basically MT4 needs some history first before it can properly loads the indicator.
 
deysmacro:
So basically MT4 needs some history first before it can properly loads the indicator.

Yes it appears so, I think the terminal should check history first history first, then reload the indicator.

Funny enough I also had a copy of the old zigzag indicator on the same chart, the old version that used int start() and the old series arries arrays.

The zigzag continued to run without a problem through all the pair changes that threw the test indicator off the chart.

The test indicator was run in OnCalculate() with #property strict.

 
SDC: 4) It does work when you change pairs. It makes no difference if the static is reset or not.
You missed my point.
If you use
static datetime last_time = Time[0];
Then it doesn't trigger on the current bar on initial load or changing pairs, (it waits until the next bar,) but it may trigger mid-bar when changing to another timeframe.
If you use
 static datetime last_time = 0;
Then it triggers on the mid-bar on initial load or on changing pairs and may trigger mid-bar when changing to another timeframe.
If you use
resetting static
datetime last_time; void OnInitFcn(){ last_time = Time[0]; }
type Fcn(){
  bool isNewbar = last_time != Time[0];
Only a resetting static pattern insures no trigger mid-bar on initial load or changing pairs or timeframes. But it may trigger mid-bar during a disconnect/reconnect cycle.
 

Oh i see, I thought we were talking about initializing specifically for first tick, next new bar reasons. static datetime last_time = Time[0];

static datetime last_time = 0 will not trigger mid bar on pair changing because the current bar time has already been executed on the previous pair. The static datetime is not re-initialized when changing pairs so it still retains the current bar time.

To make it always execute mid bar on pair change and/or timeframe change we could set the static back to zero in OnDeinit() reason 3 or retain the reason code for other alternatives in the new chart.

void OnTick()
  {
//---
   static datetime last_time = 0;
   bool newbar = false;
   Alert("last time = ", last_time);
//---
   if(Time[0] != last_time)
   {
    newbar = true;
    last_time = Time[0];
   }
   if(newbar) Alert("new bar");
  }

2014.05.16 12:35:03.657 Test Forum EA stuff USDJPY,H1: Alert: last time = 2014.05.16 20:00:00
2014.05.16 12:35:03.467 Test Forum EA stuff USDJPY,H1: Alert: last time = 2014.05.16 20:00:00
2014.05.16 12:35:03.142 Test Forum EA stuff USDJPY,H1: Alert: last time = 2014.05.16 20:00:00 // ---- static datetime retains previous pair's bar time
2014.05.16 12:34:59.179 Test Forum EA stuff USDJPY,H1: initialized
2014.05.16 12:34:58.446 Test Forum EA stuff XAGUSD,H1: uninit reason 3 // ------------------------------- pair changed
2014.05.16 12:34:56.115 Test Forum EA stuff XAGUSD,H1: Alert: last time = 2014.05.16 20:00:00
2014.05.16 12:34:50.740 Test Forum EA stuff XAGUSD,H1: Alert: last time = 2014.05.16 20:00:00
2014.05.16 12:34:42.075 Test Forum EA stuff XAGUSD,H1: Alert: new bar
2014.05.16 12:34:42.075 Test Forum EA stuff XAGUSD,H1: Alert: last time = 1970.01.01 00:00:00 // --- static datetime initialized to zero = 1970 date
2014.05.16 12:34:19.518 Test Forum EA stuff XAGUSD,H1: initialized
2014.05.16 12:34:15.103 Expert Test Forum EA stuff XAGUSD,H1: loaded successfully

Reason: