May I ask would the.bin file be readable by notepad++? The file created by my EA is not readable by notepad++, and during BT, the calendar.Load returns nothing. Do you have any hint on this?
May I ask would the.bin file be readable by notepad++? The file created by my EA is not readable by notepad++, and during BT, the calendar.Load returns nothing. Do you have any hint on this?
It is better to immediately formulate what the task is.
It is better to immediately formulate what the task is.
Sorry fxsaber, let me clarify.
Basically, I start with the example code you shared, I am able to download and create a .bin file.
I am trying to code the below for Backtest, objective is to load the .bin in every iteration, so as to check for news/events of each currency listed in the class.
However, when I am doing backtesting, The Calendar.ToString returned blank.(the "Print" are for debugging)
I am trying to code the below for Backtest, objective is to load the .bin in every iteration, so as to check for news/events of each currency listed in the class.
You only need to load the data from the file into a static variable once.
#define CALENDAR_FILENAME "Calendar.bin"// File name for reading/writing the Calendar.#property tester_file CALENDAR_FILENAME // Specifies that MT5-Tester picks up this file.#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430CALENDAR CalendarFull;// Object with calendar data.intOnInit()
{
return(CalendarFull.Load(CALENDAR_FILENAME) == -1); // Load events from the file
}
voidOnTick()
{
CALENDAR Calendar = CalendarFull;//....
}
the CalendarFULL.Load does return a "1", but there seems nothing inside CalendarFULL.
Run this script once in the MT5-terminal to generate the bin-file.
#define CALENDAR_FILENAME "Calendar.bin"// File name for reading/writing the Calendar.#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430voidOnStart()
{
CALENDAR Calendar;
if (Calendar.Set(NULL, CALENDAR_IMPORTANCE_NONE, 0, 0)) // Loaded absolutely all events (history + future) from MT5-Terminal.
Calendar.Save(CALENDAR_FILENAME); // Save them to a file.
}
Eventually, I found out the problem with my code, my .mq5 was saved as Unicode somehow, that made the fileread didnt work, once I change it to ANSI, it works.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Calendar :
Author: fxsaber
It is better to immediately formulate what the task is.
It is better to immediately formulate what the task is.
Sorry fxsaber, let me clarify.
Basically, I start with the example code you shared, I am able to download and create a .bin file.
I am trying to code the below for Backtest, objective is to load the .bin in every iteration, so as to check for news/events of each currency listed in the class.
However, when I am doing backtesting, The Calendar.ToString returned blank.(the "Print" are for debugging)
thanks,
I am trying to code the below for Backtest, objective is to load the .bin in every iteration, so as to check for news/events of each currency listed in the class.
You only need to load the data from the file into a static variable once.
You only need to load the data from the file into a static variable once.
Thanks a lot, it is nice and precise.
You only need to load the data from the file into a static variable once.
Thanks fxaber,
I was able to tidy up the code with your suggestion, but still, the CalendarFULL is also empty after loading the .bin.
the CalendarFULL.Load does return a "1", but there seems nothing inside CalendarFULL.
Would it be some sort of encoding issue of the .bin?
THanks
the CalendarFULL.Load does return a "1", but there seems nothing inside CalendarFULL.
Run this script once in the MT5-terminal to generate the bin-file.
Run this script once in the MT5-terminal to generate the bin-file.
Thanks fxsaber, I did that and it did generate a 7xmb .bin file. However, still once I attempt to load and print out, it returned blank.
Thanks fxsaber,
Eventually, I found out the problem with my code, my .mq5 was saved as Unicode somehow, that made the fileread didnt work, once I change it to ANSI, it works.
Thanks,