I have to re-run the indicator at start up

 

Hi Guys, when I stopped my MT4 application and lunched it on the next day it downloaded all history data till the moment. I noticed that my indicator showed only one value /in red ellipse /, so i had to re-run it in order to re-calculate all received history data. What have to be changed in the code to be fixed ? Thank you in advance!

Files:
 

Here: https://www.mql5.com/en/forum/135902/page6#528942.

You can try reading the entire thread for more information.

 
elo15: lunched it on the next day it downloaded all history data till the moment. I noticed that my indicator showed only one value
You aren't handling ERR_HISTORY_WILL_UPDATED. A) Move the ArrayCopySeries to init. B) check TimeArray[0] for zero. If it is, you have not yet download history for the H1. Exit and next tick check and redo all bars.
 

WHRoeder,

I have this in init() :

   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),0); 
   if(GetLastError()!=4066) Print("Historic data on Current TF is up to date (",iBars(Symbol(),0)," bars, first on ",TimeToStr(iTime(Symbol(),0,iBars(Symbol(),0)-1)),")");
   else {
       Print("Updating historic data on Current TF");
   }

and this in Start() :

    int counted_bars=IndicatorCounted(), limit;

   if(TimeArray[0]==0) {reDoAllBars=true; Print("*** Not all history bars updated /handling ERR_HISTORY_WILL_UPDATED/ ***");return(0);}
   if(reDoAllBars) counted_bars=0;

   if(counted_bars>0) counted_bars=counted_bars-2;
   
   limit=Bars-counted_bars;
   
   if(limit>barsToProcess) limit=barsToProcess;

   for(int i=1;i<limit;i++)
   {
      // check every bar
   }

but the result is not what I would like. I noticed that the indicator was re-run after I re-compiled the code. Please advise what have to be changed/updated ? Thank you.

 

I have good experience with monitoring iBars value. If it changes by 2 or more I recalculate the entire range.

Btw. the error 4066 never worked for me, I believe it has a dummy implementation, throwing error 4066 every first run and then never again.

 
Ovo:

I have good experience with monitoring iBars value. If it changes by 2 or more I recalculate the entire range.

Btw. the error 4066 never worked for me, I believe it has a dummy implementation, throwing error 4066 every first run and then never again.

Hi Ovo,

Could you please share how I can use iBars value, check and recalculate the entire range. Thanks.

 
elo15:

Hi Ovo,

Could you please share how I can use iBars value, check and recalculate the entire range. Thanks.

Is it your indicator? It uses iBars, it calculates range of candles, so what should I share?
 
Ovo:
Is it your indicator? It uses iBars, it calculates range of candles, so what should I share?


Yes, it is an indicator. How I can check with iBars and run recalculate the entire range? I have used Bars function. Some peace of code as example will be very useful. If I have to use something like :

if(reDoAllBars) counted_bars=0;
 

So are you asking me to code this piece of code for you? lol.

static int recentBars = 0;
int currentBars = iBars(Symbol(), 0);
if ( recentBars+1 < currentBars) {
   recentBars = currentBars;
   limit=currentBars;
}
 
Ovo:

So are you asking me to code this piece of code for you? lol.


Thank you very much.
 

Hi Guys, when I set any time frame value 30 or 60 the MTF indicator freeze out my MT4 application, and I have to restart it. It is only working when the value is default - current time frame. Could you please check and fix the code?

I wish you Happy and Successful New 2014 Year!

Files:
mtf_i.zip  4 kb
Reason: