Load more History on Backtest

Created at 02 Apr 2021, 16:23
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
EY

eynt

Joined 08.05.2020

Load more History on Backtest
02 Apr 2021, 16:23


I'd like to have the ability to load more data when I run a back test, using the LoadMoreHistory method or anything equivalent. Here's the reason why this feature is needed instead of simply start the back test in an early date:

If I start running a back test from a specific date, I will need a certain amount of past data before that date. This amount of data (bars or days) is NOT KNOWN, it is decided according to market conditions. I will need to keep calling the LoadMoreHistory until a specific condition is filled - only then I can start the run of my cBot.

When running the cBot live it is not a problem, however when I use it on a back test how far should I go back? A day? A week? a month?  Even if I knew how far should I go the cBot will start from that date instead of a date of my choosing.

The ability to use LoadMoreHistory on back test will solve all these problems.

 

Thanks


@eynt
Replies

JerryTrader
06 Apr 2021, 20:33

I couldn't agree more on that point.

If LoadMoreHistory exists, there's no reason why it should not be available for backtests.


@JerryTrader

ctid4605338
20 Feb 2024, 18:44 ( Updated at: 21 Feb 2024, 07:02 )

This feature is still not working in 2024 year. Do you need assistance to implement this?


@ctid4605338

daibatsu_thunder
18 Jun 2024, 18:49 ( Updated at: 19 Jun 2024, 04:57 )

Why LoadMoreHistory is needed

We have a bot that trades on Renko timeframes. We wanted to add multi timeframe rsi values, but the backtesting didn't load enough data. So now we're resorting to running dummy bots to dump out the RSIs to text file so we can use them while backtesting. It's quite hackish. The feature should be symmetric, in that LoadMoreHistory should work the same as in live trading. Right now it's essentially broken for multi timeframe indicators and bot backtests…


@daibatsu_thunder

PanagiotisCharalampous
19 Jun 2024, 05:04

Hi all,

This has been implemented in v5.0.

Best regards,

Panagiotis


@PanagiotisCharalampous

eynt
20 Jun 2024, 10:03

RE: Load more History on Backtest

PanagiotisCharalampous said: 

Hi all,

This has been implemented in v5.0.

Best regards,

Panagiotis

Hello

I'm using version 5.0.25.27693 and is does not seem like the issue is implemented.

While using Backtest I called the Bars.LoadMoreHistory method, however the values of Bars.Count and Bars.OpenTimes[0] are not changed

Thanks


@eynt

eynt
20 Jun 2024, 10:03

RE: Load more History on Backtest

PanagiotisCharalampous said: 

Hi all,

This has been implemented in v5.0.

Best regards,

Panagiotis

Hello

I'm using version 5.0.25.27693 and is does not seem like the issue is implemented.

While using Backtest I called the Bars.LoadMoreHistory method, however the values of Bars.Count and Bars.OpenTimes[0] are not changed

Thanks


@eynt

daibatsu_thunder
20 Jun 2024, 20:45 ( Updated at: 20 Jun 2024, 20:50 )

RE: RE: Load more History on Backtest

eynt said: 

PanagiotisCharalampous said: 

Hi all,

This has been implemented in v5.0.

Best regards,

Panagiotis

Hello

I'm using version 5.0.25.27693 and is does not seem like the issue is implemented.

While using Backtest I called the Bars.LoadMoreHistory method, however the values of Bars.Count and Bars.OpenTimes[0] are not changed

Thanks

I'm seeing the same thing. LoadMoreHistory hangs inside indicators and doesn't pull enough data in backtests. I even started the backtest way earlier so I could accumulate enough points to drive 1440 * 14 candles for a daily RSI using minute data. I'm also getting discrepancies between multi timeframe RSI on tradingview vs ctrader. I made a bunch of RSIs: 1m, 5m, 15m, 30m, 1h, 2h, 4h, 1d based off of the 1 min chart by using periods 1*14, 5*14, 30*14… etc. I can't seem to get enough data loaded so that the chart looks right. When I use Bars.GetMarketData(tf) it never loads enough either.

edit: here's the pine script i used to compare

//@version=5

indicator("Multi Timeframe RSI", overlay=false)

// Input parameters

rsiLength = input.int(14, title="RSI Length")

// Function to calculate RSI for a given timeframe

rsiTF(tf) =>ta.rsi(close, rsiLength)

// Calculate RSI for different timeframes

rsi_1m  = request.security(syminfo.tickerid, "1", rsiTF("1"))

rsi_5m  = request.security(syminfo.tickerid, "5", rsiTF("5"))

rsi_15m = request.security(syminfo.tickerid, "15", rsiTF("15"))

rsi_30m = request.security(syminfo.tickerid, "30", rsiTF("30"))

rsi_1h  = request.security(syminfo.tickerid, "60", rsiTF("60"))

rsi_2h  = request.security(syminfo.tickerid, "120", rsiTF("120"))

rsi_4h  = request.security(syminfo.tickerid, "240", rsiTF("240"))

rsi_1d  = request.security(syminfo.tickerid, "1440", rsiTF("1440"))


 

plot(rsi_1m, title="RSI 1M", color=color.new(color.red, 0), linewidth=1)

plot(rsi_5m, title="RSI 5M", color=color.new(color.yellow, 0), linewidth=1)

plot(rsi_15m, title="RSI 15M", color=color.new(color.orange, 0), linewidth=1)

plot(rsi_30m, title="RSI 30M", color=color.new(color.fuchsia, 0), linewidth=1)

plot(rsi_1h, title="RSI 1H", color=color.new(color.green, 0), linewidth=1)

plot(rsi_2h, title="RSI 2H", color=color.new(color.blue, 0), linewidth=1)

plot(rsi_4h, title="RSI 4H", color=color.new(color.purple, 0), linewidth=1)

plot(rsi_1d, title="RSI 1D", color= color.new(color.silver, 0), linewidth=1)

 


@daibatsu_thunder

... Deleted by UFO ...

PanagiotisCharalampous
21 Jun 2024, 05:27

RE: RE: Load more History on Backtest

eynt said: 

PanagiotisCharalampous said: 

Hi all,

This has been implemented in v5.0.

Best regards,

Panagiotis

Hello

I'm using version 5.0.25.27693 and is does not seem like the issue is implemented.

While using Backtest I called the Bars.LoadMoreHistory method, however the values of Bars.Count and Bars.OpenTimes[0] are not changed

Thanks

Can you provide exact steps to reproduce i.e. code, broker, cBot parameters and dates?

Best regards,

Panagiotis


@PanagiotisCharalampous

eynt
21 Jun 2024, 07:30

RE: RE: RE: Load more History on Backtest

PanagiotisCharalampous said: 

eynt said: 

PanagiotisCharalampous said: 

Hi all,

This has been implemented in v5.0.

Best regards,

Panagiotis

Hello

I'm using version 5.0.25.27693 and is does not seem like the issue is implemented.

While using Backtest I called the Bars.LoadMoreHistory method, however the values of Bars.Count and Bars.OpenTimes[0] are not changed

Thanks

Can you provide exact steps to reproduce i.e. code, broker, cBot parameters and dates?

Best regards,

Panagiotis

 

 

Hi

 

I attached a code sample below. I've tried several symbols, timeframes and data types. My broker is Pepperstone.

As can be seen in  its output the values remain the same.

 

 

20/06/2024 00:00:00.000 | Info | CBot instance [LoadBarsTest, EURUSD, h1] started.
20/06/2024 00:00:00.084 | Info | 200 07/06/2024 17:00:00
20/06/2024 00:00:00.084 | Info | 200 07/06/2024 17:00:00
20/06/2024 00:00:00.084 | Info | 200 07/06/2024 17:00:00
20/06/2024 00:00:00.084 | Info | 200 07/06/2024 17:00:00
20/06/2024 23:59:59.951 | Info | CBot instance [LoadBarsTest, EURUSD, h1] stopped.

 

protected override void OnStart()
        {
            Print(Bars.Count + " " + Bars.OpenTimes[0]);

            for (int i = 0; i < 3; i++)
            {
                Bars.LoadMoreHistory();
                Print(Bars.Count + " " + Bars.OpenTimes[0]);
            }
        }

@eynt

eynt
23 Jul 2024, 16:32

RE: RE: RE: RE: Load more History on Backtest

Hello, anything new?

Thanks


@eynt

PanagiotisCharalampous
24 Jul 2024, 06:41

RE: RE: RE: RE: RE: Load more History on Backtest

eynt said: 

Hello, anything new?

Thanks

Hi eynt,

It seems it has not been released yet. It will be released in v5.2

Best regards,

Panagiotis


@PanagiotisCharalampous

eynt
11 Aug 2024, 14:21

RE: RE: RE: RE: RE: RE: Load more History on Backtest

When is v5.2 expected to be released?

Thanks


@eynt

PanagiotisCharalampous
12 Aug 2024, 05:20

RE: RE: RE: RE: RE: RE: RE: Load more History on Backtest

eynt said: 

When is v5.2 expected to be released?

Thanks

We do not have an ETA unfortunately


@PanagiotisCharalampous