EA missing values when EA restarts!

 
Hi,

I coded ea to run from particular time. eg:1.00am-3.00am

at 3am i find high/low of previous 2 bars using iHighest()/iLowest and store in double dhigh/double dlow.

EA works fine. problom is when system retstarts or internet connection fails, the value of dhigh/dlow becomes "0".

Is there any MT4 functions available to store the datas in system, and when system/mt4 restarts EA can restore the datas.

If yes please support me to resolve the issues myself.
 
sheriffonline:
Hi,

I coded ea to run from particular time. eg:1.00am-3.00am

at 3am i find high/low of previous 2 bars using iHighest()/iLowest and store in double dhigh/double dlow.

EA works fine. problom is when system retstarts or internet connection fails, the value of dhigh/dlow becomes "0".

Is there any MT4 functions available to store the datas in system, and when system/mt4 restarts EA can restore the datas.

Yes, GlobalVariables or files.
 

at 3am i find high/low of previous 2 bars using iHighest()/iLowest and store in double dhigh/double dlow

those values you can get again

even without GlobalVariables or files.

there is also iBarShift and iHighest iLowest to get it back

whatever time you take you can find the highest and lowest of xx bars before

 
deVries:

at 3am i find high/low of previous 2 bars using iHighest()/iLowest and store in double dhigh/double dlow

those values you can get again

even without GlobalVariables or files.

there is also iBarShift and iHighest iLowest to get it back

whatever time you take you can find the highest and lowest of xx bars before

Hi deVries,

Can you describe what iBarShift does exactly.

i used the example code and the results for shift is 0, so what it says?

How iBarShift help to find high/low with iHighest/iLowest?

  datetime some_time=D'2013.07.27 12:00';
  int      shift=iBarShift("NULL",0,some_time);
Comment("shift of bar with open time ",TimeToStr(some_time)," is ",shift);
 
sheriffonline:

Hi deVries,

Can you describe what iBarShift does exactly.

i used the example code and the results for shift is 0, so what it says?

How iBarShift help to find high/low with iHighest/iLowest?


If you give iBarShift() a time of 3am it will give you the bar number for 3am, then from that bar number you can get the high and low of the 2 previous bars . . . please read the documentation, click---> iBarShiift()
 
RaptorUK:
If you give iBarShift() a time of 3am it will give you the bar number for 3am, then from that bar number you can get the high and low of the 2 previous bars . . . please read the documentation, click---> iBarShiift()


Sorry for asking more.


which results me '0' all

count=iBarShift("NULL",0,"2013.07.29 07:00");

time.

 
sheriffonline:

Sorry for asking more.


which results me '0' all

time.

Please read the documentation, iBarShift() needs a datetime not a string for the bar time & date, if you must use a string (bad idea) use this with it StrToTime()
 
It also needs a symbol. There is no symbol "NULL" on any broker.
 
WHRoeder:
It also needs a symbol. There is no symbol "NULL" on any broker.

I used "NULL" for current symbol. but i wonder why itsnot working,when i give surrency name like "EURUSD" it works.


I have studied here.

int iBarShift(  string symbol, int timeframe, datetime time, bool exact=false)
Search for bar by open time. The function returns bar shift with the open time specified. If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.
Parameters:
symbol    -     Symbol the data of which should be used to calculate indicator. NULL means the current symbol.
timeframe         -     Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
time      -     value to find (bar's open time).
exact     -     Return mode when bar not found. false - iBarShift returns nearest. true - iBarShift returns -1.
 
sheriffonline:

I used "NULL" for current symbol. but i wonder why itsnot working,when i give surrency name like "EURUSD" it works.


I have studied here.

NULL is not the same as "NULL"
 
RaptorUK:
NULL is not the same as "NULL"


Yes. thanks.
Reason: