1 (edited by electronics 2021-12-29 04:48:16)

Topic: 2 trading time sessoins

Hi, All

I have some doubt about historical data to back test my H1 strategies. The issue is the session time of a broker that I will show it's image. It shows you that there are 2 trading time sessoins each day, first 00:00 - 23:00, second 23:10 - 24:00
https://i.ibb.co/NL6zL17/MT4-Contract.jpg
acura rlx 0 to 60

For example, the screen shot from MT4 H1 chart, data bar series respectively show as image below. and I try to back check the 23:10 data bar begin from May-2021 to present.
https://i.ibb.co/tbd3C5D/23-10-MT4.png

When I save history as CSV. form and I check the respectively time series same as the MT4 chart.
https://i.ibb.co/LkQmyKD/CSV-File.png

But when I check data series in FSB chart the 23:10 data bar is skiped or no show as below.
https://i.ibb.co/Wg0bPny/Indicator-chart-FSB.png

Also check in the Bar Explorer tab. No 23:10 data time series.
https://i.ibb.co/HqRwWsW/Bar-Explorer-FSB.png

What happen? because my back test will be unreliable if some data bar not available when compared with real market chart.

Re: 2 trading time sessoins

Hello Electronics,

Thank you for the detailed report!

Forex Strategy Builder needs correct bar open times in order to produce a correct backtest. The program checks each bar of the data files at loading and ignores those bars with inconsistent open time.

In the case you report, each H1 bar must start at a round hour. However, your broker makes it strange. It looks like it suspends the trading between 23:00 and 23:10 for rollover calculation purposes. Usually, the brokers quote the market without interruption. What they do is to prevent actually trade executions. It is a problem, but not so big that in your case.

This particular case can be fixed with a modified script for exporting data from a MetaTrader chart.
The script must modify the open time of M15, M30, and H1 bars to change them from 23:10 to 23:00.

We already have Data export scripts attached to the Premium Club. You can try to modify it. if you have trouble with it, I'll be happy to help you.

Happy holidays and Trade Safe!

Re: 2 trading time sessoins

I made a modified script for you.

Please test it in your MetaTrader.

Here is how the fix works:

bool   isPeriodTofix  = period==PERIOD_M15 || period==PERIOD_M30 || period==PERIOD_H1;
string barOpenMinutes = TimeToString(rates_array[i].time,TIME_MINUTES);
string fixedMinutes   = isPeriodTofix && barOpenMinutes == "23:10" ? "23:00" : barOpenMinutes;

First, it checks if the data period is on of interest: M15, M30, or H1. We don't care for the lower periods, because the broker doesn't produce bars for them. The H4 and D1 must be correct because they start at 20:00 and 00:00 respectively.

Then the script gets the provided time in the `barOpenMinutes` variable.
The script checks if the time is "23:10" and changes it to "23:00" in such a case.


Trade safe!

Post's attachments

FSB Pro Data Fix 23.10.mq4 4.83 kb, 2 downloads since 2021-12-29 

You don't have the permssions to download the attachments of this post.

Re: 2 trading time sessoins

Popov wrote:

I made a modified script for you.

Please test it in your MetaTrader.

Here is how the fix works:

bool   isPeriodTofix  = period==PERIOD_M15 || period==PERIOD_M30 || period==PERIOD_H1;
string barOpenMinutes = TimeToString(rates_array[i].time,TIME_MINUTES);
string fixedMinutes   = isPeriodTofix && barOpenMinutes == "23:10" ? "23:00" : barOpenMinutes;

First, it checks if the data period is on of interest: M15, M30, or H1. We don't care for the lower periods, because the broker doesn't produce bars for them. The H4 and D1 must be correct because they start at 20:00 and 00:00 respectively.

Then the script gets the provided time in the `barOpenMinutes` variable.
The script checks if the time is "23:10" and changes it to "23:00" in such a case.


Trade safe!

Thanks a lot