History file reading problem
// Terminal and editor version: 4.00 build 419 // To reproduce bug, do following: // - after compiling this script, stop Terminal and Editor // - delete all NZDUSD history file if there is any // - start Terminal // - open a chart: NZDUSD H1 (H1 is default if open from toolbar) // - place this test script on it: it will write 0 // - place this test script on it again: it will write the correct data at last int start() { for (int i = 0; i < 3; i++) Print(iClose("NZDUSD", PERIOD_M15, 0)); return(0); }
Thank you, I tried it, first time it creates a 4066 error as above, and after that creates this:
| ERR_INCORRECT_SERIES_ARRAY_USING | 4054 | Incorrect series array using. |
Is there any known way to handle this error, for example force reloading? Or I can only write the error and stop?
I found a way to handle this last error, waiting only for the refreshing :) It can be useful when using Multi Timeframe (but only for regular timeframes).
#include <stderror.mqh> int start() { if (iClose("NZDUSD", PERIOD_M15, 0) == 0.0) { int lastError = GetLastError(); while (lastError == ERR_HISTORY_WILL_UPDATED || lastError == ERR_INCORRECT_SERIESARRAY_USING) { Sleep(1000); if (iClose("NZDUSD", PERIOD_M15, 0) > 0.0) break; lastError = GetLastError(); } } Print(iClose("NZDUSD", PERIOD_M15, 0)); return(0); }
I would prefer it this way, so there is only one position for the test.
#include <stderror.mqh> int start() { while( iClose("NZDUSD", PERIOD_M15, 0) == 0.0 ){ int lastError = GetLastError(); if( lastError != ERR_HISTORY_WILL_UPDATED && lastError != ERR_INCORRECT_SERIESARRAY_USING ){ Print("Fatal Error " + lastError); return( 0 ); } Sleep(1000); } Print(iClose("NZDUSD", PERIOD_M15, 0)); return(0); }
Thank you, I tried it, first time it creates a 4066 error as above, and after that creates this:
| ERR_INCORRECT_SERIES_ARRAY_USING | 4054 | Incorrect series array using. |
Is there any known way to handle this error, for example force reloading? Or I can only write the error and stop?
I had the same problem. Looks the history data were updated ramdomly. Still looking for a solution to this. Can anybody shed some light on this problem?
I want to use History file to manipulate candle data, write it to a History file, and after that use in technical indicators, from script/ea. The History file writing is Ok, but the system does not want to read and synchronize data automatically from it if I call an indicator from the code. Maybe there is a command to refresh indicators? Or what I'm doing wrong?..
If you have other solution to use array data in iCustom input, also it woud be great.
This is my mq4 test script: