Errors after hibernation ??

 

Hi,


I wrote a little M1-indicatior (here simplified):

int start()   {
  int limit,i, n=0, b=-1;
  static datetime lstQts=0;

   
//---- last counted bar will be recounted

   int counted_bars=IndicatorCounted();
   if (counted_bars>0) counted_bars--;
   if (TimeCurrent() - lstQts > 60) { // more than 60 sec = 1 min.
                limit = Bars-myOffSet;
        Print("Re-Calc ALL  TC():",TimeToStr(TimeCurrent(),TIME_SECONDS),"  lstQts: ",TimeToStr(lstQts,TIME_SECONDS),"  Diff: ",TimeCurrent() - lstQts,"s  limit: ",limit);
   } else 
                limit = Bars-counted_bars;
   lstQts = TimeCurrent();
        for(i=0; i<limit; i++) {
                pipDIFF = myFunc1( ..., i);
                pctDIFF = myFunc2( ..., i);
                if ( i < 120 ) // Print only the 'first' 120 Min = 2h
                        string stmp = StringConcatenate("chkLine:  [",i,"]  Time[i]: ",TimeToStr(Time[i],TIME_SECONDS)," pipDIFF",p2s(pipDIFF/PIP),"  pctDIFF: ",p2s(pctDIFF),"%");
                if ( pipDIFF <= 0.0 ) {
                        if ( i < 120 )
                                Print(stmp,"  pctDIFF < ZERO => continue");
                                continue;
                }

                spB0[i] = pipDIFF;
                spB1[i] = pctDIFF;
                
                if ( i < 120 )
                        Print(stmp,"  written?  spB0[i]: ",q2s(spB0[i]),"   spB1[i]:",q2s(spB1[i]) );
   }
}
string  p2s(double p){ return(DoubleToStr(p,1)); } // print PNTs

and I got after my notebook was put into hibernation and was woken up again:


2012.07.20 20:31:32     KamaSpikes EURUSDi,M1: chkLine:  [4]  Time[i]: 20:56:00 pipDIFF: 1.21588  pctDIFF: 1.8  Cls[i]: 1.21594  written?  spB0[i]: -0.9   spB1[i]:-43.7%
2012.07.20 20:31:32     KamaSpikes EURUSDi,M1: chkLine:  [3]  Time[i]: 20:57:00 pipDIFF: 1.21591  pctDIFF: 1.8  Cls[i]: 1.21604  written?  spB0[i]: -0.0   spB1[i]:15.3%
2012.07.20 20:31:32     KamaSpikes EURUSDi,M1: chkLine:  [2]  Time[i]: 20:58:00 pipDIFF: 1.21591  pctDIFF: 1.9  Cls[i]: 1.21580  written?  spB0[i]: -0.8   spB1[i]:-42.0%
2012.07.20 20:31:32     KamaSpikes EURUSDi,M1: chkLine:  [1]  Time[i]: 20:59:00 pipDIFF: 1.21591  pctDIFF: 1.9  Cls[i]: 1.21583  written?  spB0[i]: -0.7   spB1[i]:-37.4%
2012.07.20 20:31:32     KamaSpikes EURUSDi,M1: chkLine:  [0]  Time[i]: 21:31:00 pipDIFF: 1.21583  pctDIFF: 1.9  Cls[i]: 1.21525  written?  spB0[i]: 3.9   spB1[i]:209.7%
2012.07.20 20:31:32     KamaSpikes EURUSDi,M1: Re-Calc ALL  TC():21:31:41  lstQts: 20:59:49  Diff: 1912s  limit: 66351


as you can see the index should re-calc the whole chart window (limit=66351), the indicator recognizes the sleepuing time of about 30 min (TC()=21:31 <=> lstQts=20:29)

BUT Time[0] = 21:31 (correct) and Time[1] = 20:59 (FALSE) :=> it should be 21:30!!

As a consequence there are no numbers in the fields of the data window of the chart.

I have to either compile that indicator again or edit and close the indicator on that chart to see again the numbers of the bars during the hibernation time.

Most probably that the calc. numbers were not correct??

Any hint what to do that this indicator re-calc correctly after hibernation?

Thanks in advance, Gooly

 

No bars were received during the hibernation, exactly the same as if there where no ticks. Don't hibernate.

Loosing connection, refreshes history and the missing bars should be processed. Refresh after hibernation.

 
WHRoeder:

No bars were received during the hibernation, exactly the same as if there where no ticks. Don't hibernate.

Loosing connection, refreshes history and the missing bars should be processed. Refresh after hibernation.


Thanks! Haven't thought of that..

I'll try on Monday:

...
   if (TimeCurrent() - lstQts > 60) { // more than 60 sec = 1 min.
        limit = Bars-myOffSet;
        RefreshRates(); 
        Print("Re-Calc ALL  TC():",TimeToStr(TimeCurrent(),TIME_SECONDS),"  lstQts: ",TimeToStr(lstQts,TIME_SECONDS),"  Diff: ",TimeCurrent() - lstQts,"s  limit: ",limit);
   } else 
        limit = Bars-counted_bars;
   lstQts = TimeCurrent();
...
 
RefreshRates() is not a chart refresh. Right click -> Refresh
 
Programmaticaly refresh chart, please read the whole topic ( https://www.mql5.com/en/forum/140511 )
 
onewithzachy:
Programmaticaly refresh chart, please read the whole topic ( https://www.mql5.com/en/forum/140511 )

Thanks onewithzachy, well I'll try this on Monday:

...
   if (TimeCurrent() - lstQts > 60) {
        limit = Bars-iIIF(Kama_slow>atr_slow,Kama_slow,atr_slow);
        PostMessageA(WindowHandle(Symbol (), Period ()), WM_COMMAND, 33324, 0);
        Print("Re-Calc ALL  TC():",TimeToStr(TimeCurrent(),TIME_SECONDS),"  lstQts: ",TimeToStr(lstQts,TIME_SECONDS),"  Diff: ",TimeCurrent() - lstQts,"s  limit: ",limit);
        s = -1;
   } else 
        limit = Bars-counted_bars;
   lstQts = TimeCurrent();
...
 
gooly:

Thanks onewithzachy, well I'll try this on Monday:

Hi gooly,

Come to think again, I think we should let the chart refresh itself.

If you're find a gap between TimeCurrent and Last TimeCurrent() and also the gap between Time [0] and Time [1] is bigger than 1 minute, then the chart is not refreshed yet. If later the gap between Time [0] and Time [1] is a minute, then the chart is refreshed and you can calculate/count that missing bar.

:D

 

Sigh,

well the problem for me is that another indicator wonderfully draws its mv-avg lines throughout the bars of the time-gap of the hibernation-mode and in the Data Window of this chart all the results of its various calculations are shown and - hopefully - valid.

But the a.m. indicator, where all its IndexBuffers are set to:

SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_NONE);

nothing happens, no matter what I try neither your hint to refresh by PostMessageA(..) nor the Right-Click on the Chart and Refresh both doesn't help at all!!

"Let the chart refresh itself?" Even after ONE hour the hibernation was ended the missing data aren't cacluated.

Only re-compile or re-start (Indicator List -> myIndi -> edit -> do nothing -> OK) fills the missing data into the fields of the Data Window of the hibernation time.

A work around might be to define a dummy-buffer filled with EMPTY_VALUE. I haven't time to try this at the moment, it has to wait some days.

But if this works, it is a strong hint for a bug - no?

Regards

Reason: