Multi-timeframe robots/indicators

13 Dec 2018, 09:53Multi-timeframe robots/indicators#31
Panagiotis Charalampousposts: 1938since: 13 Jan 2017

Hi oliveira.phc,

A workaround is to get the timeframe as a parameter. See below

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter]
        public TimeFrame Timeframe { get; set; }

        protected override void OnStart()
        {
            var t = MarketData.GetSeries(Timeframe);
        }

        protected override void OnTick()
        {

        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


Head of Community Management at cTrader
17 Dec 2018, 12:26RE:#32
oliveira.phcposts: 18since: 15 Nov 2018
Panagiotis Charalampous said:

Hi oliveira.phc,

A workaround is to get the timeframe as a parameter. See below

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter]
        public TimeFrame Timeframe { get; set; }

        protected override void OnStart()
        {
            var t = MarketData.GetSeries(Timeframe);
        }

        protected override void OnTick()
        {

        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


Thank you for your readiness, Panagiotis. But, regarding the TimeFrame class, wouldn't it be necessary to update the API in order add properties of type Tick to it? The current API only have properties of type Time. https://ctrader.com/api/reference/timeframe I don't know if it is technically possible for cTrader to have multiple timeframe bots of type Tick, but it seems that it is doable for now. Kind regards, Paulo Oliveira
17 Dec 2018, 12:28RE: RE:#33
oliveira.phcposts: 18since: 15 Nov 2018
Sorry, I meant NOT doable for now.
17 Dec 2018, 12:36#34
Panagiotis Charalampousposts: 1938since: 13 Jan 2017

HiĀ oliveira.phc,

MarketData.GetSeries(Timeframe) should work fine for tick data, as long as you set the timeframe from the interface. We just need to update the Timeframe class. We will do this in one of he upcoming updates.

Best Regards,

Panagiotis


Head of Community Management at cTrader
17 Dec 2018, 12:58RE:#35
oliveira.phcposts: 18since: 15 Nov 2018
Thanks again.