Problem with multiframe indicators in Backtesting window

Created at 13 Oct 2016, 09:15
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!
XK

xkchung

Joined 11.10.2016

Problem with multiframe indicators in Backtesting window
13 Oct 2016, 09:15


I've developed some multi timeframe indicators that allow me to change the timeframe of the indicator through a TimeFrame parameter. The indicators seem to work find on the Chart window in CAlgo (i.e. if I change the timeframe parameter then the indicator will refresh accordingly). However when I try this in the backtesting window, the indicators only show if the timeframe matches with the timeframe I selected for the actual backtesting, rather than my custom timeframe parameter. 

Given that my indicators work fine in the Chart window and not in the backtesting window, I was wondering if this is something I've missed in coding or if there's a bug with the actual platform?

Is anyone else experiencing this?


@xkchung
Replies

MartSmart
18 Jan 2017, 12:03

RE:

Yes I have the same experience and it took me many hours to find out that it is a bug in the tool (actually there are multiple bughs related to using multi-timeframe indicators during backtesting/optimization). Now I'm spending hours trying out to workaround the issue but I have no luck yet.

The bug seems causing various time frames to lose various amount of historical data - i.e. each market serie has different length - and some of them are even missing. It is not completely random (as the same error can be reproduced with the same results) but it is difficult for me to find the correlation between the robot timeframe and indivcator timeframe(s) to be able to predict which of them will be affected and how much.

Spotware - are you working on fixing this issue? It is quite critical one as it invalidates the optiomization results completely and prevents from effective backtesting as well

Thank you


@MartSmart

astevani
12 Mar 2019, 03:25

Same problem here.....

Spotware - are you working on fixing this issue? It is quite critical one as it invalidates the optiomization results completely and prevents from effective backtesting as well

Thank you


@astevani

PanagiotisCharalampous
12 Mar 2019, 15:02

Hi astevani,

This is an old thread. Do you still experience the issue of indicators displaying differently on normal chart and on a backtesting chart? If yes, can you share one to check?

Best Regards,

Panagiotis


@PanagiotisCharalampous

office3131
14 Jun 2020, 06:02

RE:

PanagiotisCharalampous said:

Hi astevani,

This is an old thread. Do you still experience the issue of indicators displaying differently on normal chart and on a backtesting chart? If yes, can you share one to check?

Best Regards,

Panagiotis

Hi Panagiotis,

I am experiencing the same problem. I use your indicator here . It works well in live regime, but in backtesting (at m1 with Tick data from server) I see only the m1 line. 

Minute5 and Minute10 are missing. Any idea why?

Thank you

 


@office3131

... Deleted by UFO ...

PanagiotisCharalampous
15 Jun 2020, 10:44

Hi office3131,

When you are using indicators that consume data from other timeframes on backtesting, you need to make sure that they get enough data from the other timeframes so that they can display values for the date the backtesting starts. See an example below on how to go about the solution

        protected override void Initialize()
        {

            bars = MarketData.GetBars(matf);

        }

        public override void Calculate(int index)
        {
            while (double.IsNaN(bars.ClosePrices[bars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index])]))
            {
                bars.LoadMoreHistory();
            }
            var ma1 = Indicators.ExponentialMovingAverage(bars.ClosePrices, emaper).Result;
            //get time
            var charttime = Bars.OpenTimes[index];

            //get index
            var idx1 = bars.OpenTimes.GetIndexByTime(charttime);

            main[index] = ma1[idx1];

        }

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous