May I ask would the.bin file be readable by notepad++? The file created by my EA is not readble 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 readble 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"// Название файла для чтения/записи Календаря.#property tester_file CALENDAR_FILENAME // Указание, чтобы MT5-Тестер подхватывал данный файл.#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430CALENDAR CalendarFull;// Объект с данными календаря.intOnInit()
{
return(CalendarFull.Load(CALENDAR_FILENAME) == -1); // Загрузили события из файла
}
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"// Название файла для чтения/записи Календаря.#include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430voidOnStart()
{
CALENDAR Calendar;
if (Calendar.Set(NULL, CALENDAR_IMPORTANCE_NONE, 0, 0)) // Загрузили абсолютно все события (история + будущее) из MT5-Терминала.
Calendar.Save(CALENDAR_FILENAME); // Сохранили их в файл.
}
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.
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,