CustomSymbols Historical Data erased with error in HistoryCache HistoryBase

 

I create a CustomSymbol with CustomSymbolCreate, download data and update the chart with the CustomRatesUpdate function into the MQLRates array. This all works fine.  After that I update the chart with live data. This works fine too.  The error I get is HistoryCache container header read error [0] (printed in the logs file), then HistoryBase invalid container (1970.01.01) found (off: 3595089750, size: 86589, file: 3050482268). When this happens the historical data is deleted from the database from Jan 1, 2021 to Present time.  This error happens persistently only once (not every day) and at the creation of a New Day. 00:00.  Last time was on Sunday Feb 14 and now Saturday Feb 20.

Could this be related to using the CustomSymbolCreate(symbol, "custompath", NULL) which creates CustomSymbolSetSessionQuote from Monday through Friday which doesn't include Saturday and Sunday by default? 

 

What is Error 4307  , Docs only show up to 4305 

https://www.mql5.com/en/docs/constants/errorswarnings/errorcodes

I get this error when creating CustomSymbolSetSessionQuote

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
  • www.mql5.com
Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
TradingToolCrypto:

What is Error 4307  , Docs only show up to 4305 

https://www.mql5.com/en/docs/constants/errorswarnings/errorcodes

I get this error when creating CustomSymbolSetSessionQuote

Same question is on post #24811 Russian language (and this post #24813), use in-built translation feature located on every post), and it is replies from MQ:
post #24812 ss and post #24814, and post #24816 about documentation.

Machine translation to the English:

As for the code 4307, show the code how you expose sessions. If you request a session with index 6, then you have set 7 sessions for this day.

There are special functions CustomSymbolSetSessionQuote and CustomSymbolSetSessionTrade to set up sessions

The documentation says

Sessions can be added only sequentially, that is, a session with the session_index = 1 index can be added only if there already exists a session with the index equal to 0. If this rule is violated, a new session is not created, and the function itself will return false.

The documentation explicitly says about the day of the week for which you set the session. ONE day of the week.

ENUM_DAY_OF_WEEK

[in] Day of the week, value from the ENUM_DAY_OF_WEEK enumeration.

what does the index number of days have to do with it? There is a special session_index parameter for the session number. This is clearly stated in the documentation

I am not a coder so I can not help more (I just found the information).
But it is related to the coding anyway.

Documentation on MQL5: Custom Symbols / CustomSymbolSetSessionQuote
Documentation on MQL5: Custom Symbols / CustomSymbolSetSessionQuote
  • www.mql5.com
CustomSymbolSetSessionQuote - Custom Symbols - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Apparently undocumented runtime error #4307, probably connected to "SymbolInfoSessionTrade(...)"
Apparently undocumented runtime error #4307, probably connected to "SymbolInfoSessionTrade(...)"
  • 2020.03.27
  • www.mql5.com
Hello dear MetaQuotes team, it is certainly desirable for all users of the platform that every type of error that can occur is actually named in th...
 
Sergey Golubev:
Same question is on post #24811 Russian language (and this post #24813), use in-built translation feature located on every post), and it is replies from MQ:
post #24812 ss and post #24814, and post #24816 about documentation.

Thank you. To summarize. Each day (Sunday-Saturday) requires a starting session_index of 0. If each day requires more than one session, increase the session_index accordingly.   Session_Index is not a cumulative value of all trading sessions created within the week.  Now I understand.


   if(!CustomSymbolSetSessionQuote(customSymbolName,SUNDAY,0, StringToTime("2021.2.7 00:00"),StringToTime("2021.2.7 24:00")))
     {
      Print("CustomSymbolSetSessionQuote | --- | Failed" + IntegerToString(GetLastError()));
      ResetLastError();
     }

   if(!CustomSymbolSetSessionQuote(customSymbolName,MONDAY,0, StringToTime("2021.2.7 00:00"),StringToTime("2021.2.7 23:59")))
     {
      Print("CustomSymbolSetSessionQuote | --- | Failed" + IntegerToString(GetLastError()));
      ResetLastError();
     }

The code is an example of how to set the SessionQuote correctly.  However, I am unable to insert an endTime that appears within the MT5 platform under Symbols-> Session equal to 24:00 . If I try 23:59 , I get 23:59 which is normal but a value of 24:00 results as 23:00.  

Any comment or suggestion regarding the main topic?

MQL5 forum
MQL5 forum
  • www.mql5.com
MQL5: Forum on automated trading systems and strategy testing
 
TradingToolCrypto:
Thank you. To summarize. Each day (Sunday-Saturday) requires a starting session_index of 0. If each day requires more than one session, increase the session_index accordingly.   Session_Index is not a cumulative value of all trading sessions created within the week.  Now I understand. Any comment or suggestion regarding the main topic?

Read the latest post of this thread https://www.mql5.com/en/forum/335996 (the user summarized):

Forum on trading, automated trading systems and testing trading strategies

Apparently undocumented runtime error #4307, probably connected to "SymbolInfoSessionTrade(...)"

Markus, 2020.04.03 22:31

Hi,

recently I made a small testscript with wich I found out, that the ominous error #4307 just seconds the failure of the call I mentioned, when the specified session does not exist. That's about all to say there besides the importance to really ignore the date output by this function. Thanks anyway - another problem solved.

Greetings


Apparently undocumented runtime error #4307, probably connected to "SymbolInfoSessionTrade(...)"
Apparently undocumented runtime error #4307, probably connected to "SymbolInfoSessionTrade(...)"
  • 2020.03.27
  • www.mql5.com
Hello dear MetaQuotes team, it is certainly desirable for all users of the platform that every type of error that can occur is actually named in th...
 

This is my local time (GMT +7) , starting a new day GMT , logs error and from Jan 1st, 2021 to present all Bars are deleted from chart and history database.  Tick data remains in database. 

MR 3 07:00:00.386 HistoryCache 'BTCUSDT.bnf' invalid container header [0]

NG 3 07:00:00.388 HistoryBase 'BTCUSDT.bnf' invalid container (1970.01.01) found (off: 3190380716, size: 86589, file: 7485434850)

DH 3 07:00:01.840 HistoryCache 'ETHUSDT.bnf' container header read error [0]

PM 3 07:00:01.840 HistoryBase 'ETHUSDT.bnf' invalid container (1970.01.01) found (off: 3133605624, size: 86589, file: 2590179215)



 

Happened again. Same time! History data deleted from Jan1st to present. Data before Jan 1st, 2021 remains in database. 

PM 3 07:00:00.819 HistoryCache 'BTCUSDT.bnf' invalid container header [0]

MM 3 07:00:00.819 HistoryBase 'BTCUSDT.bnf' invalid container (1970.01.01) found (off: 995271083, size: 86589, file: 5290325217)


Any suggestions? I've tried on several builds and its persistent across all of them. (build 2755-2784 beta)

Files:
 
TradingToolCrypto:

Happened again. Same time! History data deleted from Jan1st to present. Data before Jan 1st, 2021 remains in database. 

PM 3 07:00:00.819 HistoryCache 'BTCUSDT.bnf' invalid container header [0]

MM 3 07:00:00.819 HistoryBase 'BTCUSDT.bnf' invalid container (1970.01.01) found (off: 995271083, size: 86589, file: 5290325217)

This is a problem that has been around for a very long time. If the developers are looking through the forum, they can easily recreate it. Please see https://www.mql5.com/en/forum/360938

Problem with CustomRatesUpdate (Metatrader 5)
Problem with CustomRatesUpdate (Metatrader 5)
  • 2021.01.22
  • www.mql5.com
Hi, I'm experiencing a problem with the CustomRatesUpdate function...
 
Artur Zas:

This is a problem that has been around for a very long time. If the developers are looking through the forum, they can easily recreate it. Please see https://www.mql5.com/en/forum/360938

Thank you for dropping the link for your discussion and showing your example. Yes, its the exact scenario that I am facing. I've tested on stable builds 2755-2784 and every beta build coming out (2796 so far).  Same errors in logs, same gaps in history. 


Thank you for also pinpointing the issue within the CustomRatesUpdates() function. 

Files:
 
Does anyone know if there is a work-around or a fix to this issue?  I'm experiencing this same problem a year and a half later, so seems like it has not been addressed.  How did you guys deal with it?
Reason: