3.7 GetBars() works on backtest not in optimize

Created at 29 Dec 2019, 22:52
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!
GE

genappsforex

Joined 25.11.2019

3.7 GetBars() works on backtest not in optimize
29 Dec 2019, 22:52


This code works in Backtest but not in Optimize 3.7



using System;
using cAlgo.API;
using cAlgo.API.Requests;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]
    public class Test : Robot
    {
        Bars Daily, Hour4, Hour1;

        protected override void OnStart()
        {
            try
            {
                Daily = MarketData.GetBars(TimeFrame.Daily, Symbol.Name);
                if (Daily == null)
                    Print("Nope D");
                Hour4 = MarketData.GetBars(TimeFrame.Hour4, Symbol.Name);
                if (Hour4 == null)
                    Print("Nope H4");
                Hour1 = MarketData.GetBars(TimeFrame.Hour, Symbol.Name);
                if (Hour1 == null)
                    Print("Nope H1");
            } catch (Exception ex)
            {
                Print(ex.Message, " ", ex.StackTrace.ToString());
            }
        }
        protected override void OnBar()
        {
        }
        protected override void OnTick()
        {
        }
    }
}

Best rgds,

 


@genappsforex
Replies

PanagiotisCharalampous
30 Dec 2019, 09:05

Ηι genappsforex,

As the message indicates, MultiSymbol does not work on optimization at the moment.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

trentgale
08 Feb 2020, 06:07 ( Updated at: 21 Dec 2023, 09:21 )

I'm getting the same issue, this used to work in 3.6 optimisation (without the Bars interface and related code), but now doesn't work at all with either.

I have added in the obsolete MarketSeries as reference to what used to work.

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class testing : Robot
    {
        protected override void OnStart()
        {
            TryGetBars();
            TryGetSeries();
        }

        public void TryGetBars()
        {
            try
            {
                Bars barsMinute = MarketData.GetBars(TimeFrame.Minute);
                Print("barsMinute.Count: {0}", barsMinute.OpenPrices.Count.ToString());
            } catch (Exception ex)
            {
                Print(ex);
            }
        }

        public void TryGetSeries()
        {
            try
            {
                MarketSeries seriesMinute = MarketData.GetSeries(TimeFrame.Minute);
                Print("seriesMinute.Count: {0}", seriesMinute.Open.Count.ToString());
            } catch (Exception ex)
            {
                Print(ex);
            }
        }
    }
}

If I run any other timeframe apart from m1 in optimisation I get the following log:

But in RealTime or backtesting:

 

As you can see, I am not referencing another symbol, nor was the OP.

Regards,

Trent


@trentgale

TzvetomirTerziysky
08 Feb 2020, 09:14

MultiFrame is crashing the Optimisation in 3.7 even though continues to work in backtesting.

@Panagiotis Charalampous Any ideas when this is going to be fixed.?

Or at least any workaround?

P.S.I have raised that issue on 05.02.2020


@TzvetomirTerziysky

mike.mcclelland
11 Feb 2020, 08:13

Hi @Panagiotis Charalampous -

Like the Op & TzvetomirTerziysky I am also experiencing this problem when trying to load Bars or MarketSeries of another TimeFrame for the same Symbol.

My entire strategy is now at a standstill since the 3.7 upgrade. Help!


@mike.mcclelland