GetBars with Renko Time Frame

Created at 12 May 2020, 14:09
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!
CT

cTKit

Joined 15.09.2016

GetBars with Renko Time Frame
12 May 2020, 14:09


Is it possible to use GetBars in a bot with a Renko Time Frame.

The TimeFrame static interface does not include any RenkoN, and the TimeFrame constructor and PredefinedTimeFrame enum seem to be internal.

I am trying to do something with multiple Renko timeframes, but does not seem possible to get the data for any of the new range based time frames.


@cTKit
Replies

PanagiotisCharalampous
12 May 2020, 15:06

Hi testpossessed,

A workaround is to use a timeframe as a parameter and choose Renko bars from there. See below and example

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(DefaultValue = 0.0)]
        public TimeFrame Parameter { get; set; }

        protected override void OnStart()
        {
            var bars = MarketData.GetBars(Parameter);
            Print(bars.Count);
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

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

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

cTKit
12 May 2020, 15:17

RE:

Thanks for the workaround, I was hoping for something more flexible i.e. providing a list of brick sizes then parsing that into relevant Renko timeframes.

Just tried the workaround and that approach lets them select any timeframe, so as well as providing a fixed number of time frames, I have to validate they have selected a Renko time frame, which it seems I can only do based on the ToString() result.  A bit on the ugly side.

On the other hand I really like that you have implemented Renko and Range bars as time frames rather than some of the convoluted ways people have implemented it.  However having done so it would be really nice if we can use them with GetBars methods like other time frames.


@cTKit