This code works for me. You can give it a try.
// FUNCTION LogAppend ---------------------------------------------- void LogAppend(string filename, string text) { int filehandle=FileOpen(filename,FILE_READ|FILE_SHARE_READ|FILE_WRITE|FILE_TXT|FILE_COMMON); FileSeek(filehandle,0,SEEK_END); FileWrite(filehandle, text); FileClose(filehandle); } // FUNCTION FindFirstBar ---------------------------------------------- void FindFirstBar() { string SymbolList [4]; SymbolList [0] = "SP500"; SymbolList [1] = "EURUSD"; SymbolList [2] = "XAUUSD"; SymbolList [3] = "BTCUSD"; int TFlist[4]; TFlist[0] = 60; TFlist[1] = 15; TFlist[2] = 5; TFlist[3] = 1; int SymbolIteration = 0; while(SymbolIteration < ArraySize(SymbolList) { int TFIteration = 0; // ------------ change timeframe ------------ while(TFIteration < ArraySize(TFlist)) { // ------------ detect oldest bar ------------ int shift = 0; int firstbar = 0; while(1 > 0) { Timestamp = iTime(SymbolList[SymbolIteration], TFlist[TFIteration], shift); if (Timestamp == 0) { firstbar = shift - 1; Timestamp = iTime(SymbolList[SymbolIteration], TFlist[TFIteration], firstbar); ExactDate = IntegerToString(TimeYear(Timestamp)) + "-" + IntegerToString(TimeMonth(Timestamp)) + "-" + IntegerToString(TimeDay(Timestamp)) + "_" + IntegerToString(TimeHour(Timestamp)) + ":" + IntegerToString(TimeMinute(Timestamp)); LogText = "firstbar in TF " + TFlist[TFIteration] + " of " + SymbolList[SymbolIteration] + " is " + firstbar + ", on date " + ExactDate; LogAppend(LogFile, LogText); break; } shift++; } // ------------ collect data below ------------ // ------------ collect data above ------------ TFIteration++; } SymbolIteration++; } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello there,
I'm trying to find out if history of a symbol-timeframe is fully loaded or not within my mql4 expert.
there is this function ...
with this identifier
SERIES_SERVER_FIRSTDATE
The very first date in the history of the symbol on the server regardless of the timeframe
datetime
that shows "The very first date in the history of the symbol on the server regardless of the timeframe" but it is regardless of the timeframe.
Is there a way to identify SERIES_SERVER_FIRSTDATE depending on the timeframe?
regards