How to check if terminal was just started? - page 2

 
Alain Verleyen:

Of course there is a logical error if you get an alert (which I suppose is only needed for live signals) using "old" data.

Anyway, if you need coding help show your code. Nobody can guess how to fix an invisible code.

You will see, my code is really not the issue. It's just the lack of data.

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
   static datetime m15Time0;
   if (m15Time0!=iTime(_Symbol, 15, 0)) {
      m15Time0=iTime(_Symbol, 15, 0);
      for (int i=4; i<iBars(_Symbol, 15); i++) {
         if (iHigh(_Symbol, 15, i)>MathMax(MathMax(iHigh(_Symbol, 15, i+1), iHigh(_Symbol, 15, i+2)), MathMax(iHigh(_Symbol, 15, i-1), iHigh(_Symbol, 15, i-2)))) {
            ObjectCreate(0, "fractalHigh", OBJ_TREND, 0, iTime(_Symbol, 15, i), iHigh(_Symbol, 15, i), Time[0], iHigh(_Symbol, 15, i));
            break;
         }
      }
   }
   static datetime m1Time0;
   if (m1Time0!=iTime(_Symbol, 1, 0)) {
      m1Time0=iTime(_Symbol, 1, 0);
      double fractal = ObjectGetDouble(0, "fractalHigh", OBJPROP_PRICE1);
      if (iHigh(_Symbol, 1, 1)>fractal && iLow(_Symbol, 1, 1)<fractal) {
         Alert(_Symbol+" broke fractal high");
      }
   }  
   //--- return value of prev_calculated for next call
   return(rates_total);
  }   
//+------------------------------------------------------------------+

As you can see, I look for the latest fractal high on M15 and then I check every minute if it's broken. That always causes errors if the terminal was closed for a couple of hours.

 
whroeder1:
This will not help. In #4, #6, timecurrent and open will be what it was and therefor no return. In #7 they both update, and therefor no return.

So there is no chance to check if the current data is loaded before the indicator starts its work? According to what you said earlier (not closing the terminal) I guess there really isn't.

 
Copying iFractal values instead of calculating might help.
 
kypa:
Copying iFractal values instead of calculating might help.

The fractals are just an example. I work with fractals, zig zags and other things. 

My main issue is how to be sure that the current data is completely loaded before an indicator starts its work. It's a general thing I want to know and implement into more of my indicators.

 
CopyBuffer returns value, you could use logic if(CopyBuffer==true) Alarm(). Or CopyRates.
Reason: