Renko bot access to archival bricks in OnStart() method

Created at 17 Jan 2019, 20: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!
SY

sylwester.guzek

Joined 05.01.2019

Renko bot access to archival bricks in OnStart() method
17 Jan 2019, 20:23


I am referring to Renko indicator:  https://ctrader.com/algos/indicators/show/1086

I would like to have access to bricks before the bot starts in OnStart() method.

(...)        
        [Parameter("Renko Pips", DefaultValue = 10)]
        public double RenkoPips { get; set; }

        public int BricksToShow = 100;
        private Renko renko;

        protected override void OnStart()
        {
            renko = Indicators.GetIndicator<Renko>(RenkoPips, BricksToShow, 3, "SeaGreen", "Tomato");
            for (var i = 0; i < 10; i++)
            {
                Print("ON-ST-(renko O;C) [", i, "]: ", renko.Open.Last(i), ";", renko.Close.Last(i));
            }
        }

        protected override void OnTick()
        {
            // bot code
        }

The following result shows that i can only access to very few bricks:

and I would like to have access to last 100 bricks. Changing value of  BricksToShow variable  does not change the result. When I pick different point in time for backtesting or different value for  RenkoPips than different number of bricks is shown in the result. It looks like indicator has some fixed period of time which takes for creating archival bricks.

I would appreciate for any help on how to access bigger amout of bricks (ex. 100) keeping specific RenkoPips value.

Thanks


@sylwester.guzek
Replies

PanagiotisCharalampous
18 Jan 2019, 09:53

Hi silvio,

Is there a reason you do not use the built in Renko Charts?

Best Regards,

Panagiotis


@PanagiotisCharalampous

sylwester.guzek
18 Jan 2019, 10:04

Hi Panagiotis,

I wasn't aware that API for built in Renko is available. I was searching here https://ctrader.com/api/reference/indicators.

Can you advise where to find it?

Thanks

Silvio


@sylwester.guzek

PanagiotisCharalampous
18 Jan 2019, 10:18 ( Updated at: 21 Dec 2023, 09:21 )

Hi silvio,

See screenshot below

You can change the code as below and run the cBot on a Renko chart.

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
    {
        protected override void OnStart()
        {
            for (var i = 0; i < 10; i++)
            {
                Print("ON-ST-(renko O;C) [", i, "]: ", MarketSeries.Open.Last(i), ";", MarketSeries.Close.Last(i));
            }
        }


        protected override void OnBar()
        {

        }

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

Best Regards,

Panagiotis


@PanagiotisCharalampous

sylwester.guzek
18 Jan 2019, 18:04

Hi Panagiotis,

Good to know that it is already available to run robot on Renko or Range timeframes. Anyhow I prefer Renko as indicator beacause it is more flexible.

Investigating further more my issue reported above I found that Robot instance at start-up downloads certain amout of historical data depending on selected timeframe. For example for D1 it is ~73 candles, for H1 it is ~125 candles, for M1 it is ~1400 candles. It is accordingly 73 days, 5 days and 1 day. It explains why I can get only few archival bricks when my robot is set to M1 timeframe. 

Is is possible to configure Robot instance to obtain specific amount archival data ? Based on my knowledge of other broker API, it was for example possible to get up to 1 month of data for M1 and 6 months of data for D1 timeframe. 

Thanks

Sylwester


@sylwester.guzek

PanagiotisCharalampous
21 Jan 2019, 11:58

Hi Sylwester,

Check my suggestion here.

Best Regards,

Panagiotis


@PanagiotisCharalampous

martin100181@gmail.com
25 Jun 2019, 05:04

Dear Panagiotis, 

 

is there any way to backtest with range bars or renko? 

With built in range and renko I cant, is it possible somehow with an indicator?

 

BR

 

Martin


@martin100181@gmail.com

martin100181@gmail.com
25 Jun 2019, 05:44

Also, when trying to use the indicator I get this error: 

 

Error CS0246: The type or namespace name 'Renko' could not be found (are you missing a using directive or an assembly reference?)

 

How can I solve it? 


@martin100181@gmail.com

PanagiotisCharalampous
25 Jun 2019, 09:23

Hi Martin,

Backtesting for Range/Renko is not available yet. Regarding the error, it seems you have not referenced the indicator.

Best Regards,

Panagiotis


@PanagiotisCharalampous

martin100181@gmail.com
25 Jun 2019, 23:32

Thank you Panagiotis. 

Could you please take a look a this simple code? can´t find the error: 

 

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 Range_Franki_v1 : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Parameter("Renko Pips", DefaultValue = 10)]
        public double RenkoPips { get; set; }

        public int BricksToShow = 100;
        private Renko renko;


        protected override void OnStart()
        {
            {
                Print("ON-ST-(renko O;C) [", i, "]: ", MarketSeries.Open.Last(i), ";", MarketSeries.Close.Last(i));
            }
 

        }

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

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

 


@martin100181@gmail.com

PanagiotisCharalampous
26 Jun 2019, 09:36

Hi Martin,

Did you add a reference to the Renko indicator in the project. Also apparently i variable is not declared. Did you just copied and pasted the code from somewhere else?

Best Regards,

Panagiotis


@PanagiotisCharalampous