Download MetaTrader 5

I have to re-run the indicator at start up

To add comments, please log in or register
Thousands of developers have already published their products in the Market. Join them!
Elo
87
Elo 2013.12.16 22:54 

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:
Ubzen
5394
Ubzen 2013.12.17 01:44  

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

You can try reading the entire thread for more information.

whroeder1
14517
whroeder1 2013.12.17 02:23  
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.
Elo
87
Elo 2013.12.18 08:33  

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.

Ex Ovo Omnia
3154
Ex Ovo Omnia 2013.12.18 09:09  

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.

Elo
87
Elo 2013.12.18 09:39  
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.

Ex Ovo Omnia
3154
Ex Ovo Omnia 2013.12.18 11:24  
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?
Elo
87
Elo 2013.12.18 12:20  
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;
Ex Ovo Omnia
3154
Ex Ovo Omnia 2013.12.18 12:47  

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;
}
Elo
87
Elo 2013.12.18 12:59  
Ovo:

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


Thank you very much.
Elo
87
Elo 2013.12.30 09:41  

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
To add comments, please log in or register