How to push last 10000 minute bars through custom indicator when starting bot in live trading mode

Created at 16 Mar 2021, 09:57
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!
AR

arturbrylka

Joined 11.05.2020

How to push last 10000 minute bars through custom indicator when starting bot in live trading mode
16 Mar 2021, 09:57


Hi Guys,

before my bot is ready to trade I need to push the previous e.g. 10000 minute bars thorugh my custom indicator that is loaded and used by the bot. For backtesting that works great by just starting 2 weeks earlier. But I have no idea how to push the last bars through the custom indicator when starting my bot in live mode.

 

Thank you!


@arturbrylka
Replies

PanagiotisCharalampous
16 Mar 2021, 10:11

Dear arturbrylka,

You can use LoadMoreHistory method to achieve this.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

arturbrylka
16 Mar 2021, 10:17 ( Updated at: 16 Mar 2021, 10:18 )

RE:

PanagiotisCharalampous said:

Dear arturbrylka,

You can use LoadMoreHistory method to achieve this.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Panagiotis,

that's what I already did, as You described in another thread. I put it in the bot, which loaded then more ticks but the bars have not been pushed automatically through the indicator.

protected override void OnStart()
        {
            Print("{0} bar on the chart. Loading 10 000 bars", Bars.Count);
            while (Bars.Count < 10000)
            {
                var loadedCount = Bars.LoadMoreHistory();
                Print("Loaded {0} bars", loadedCount);
                if (loadedCount == 0)
                    break;
            }
            Print("Finished, total bars {0}", Bars.Count);

....

}


@arturbrylka

PanagiotisCharalampous
16 Mar 2021, 10:39

Dear arturbrylka,

Can you explain in more detail what do you mean when you say 

been pushed automatically through the indicator.

Where is the indicator declared? Can you provide the code? How do you check if the bars are "pushed"?

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

arturbrylka
16 Mar 2021, 10:54

RE:

PanagiotisCharalampous said:

Dear arturbrylka,

Can you explain in more detail what do you mean when you say 

been pushed automatically through the indicator.

Where is the indicator declared? Can you provide the code? How do you check if the bars are "pushed"?

Best Regards,

Panagiotis 

Join us on Telegram

1) The indicator is declared in the bot:

private MyIndicator myi;

        protected override void OnStart()
        {
           ...
            myi = Indicators.GetIndicator<MyIndicator>();
        }

2) I see that the bars are not pushed through the indicator as I am logging to console from the OnBarClosed within the indicator:

 

public void OnBarClosed(int index)
        {
            Print("tick: " + series1.OpenTime[index]);

.....

Please remember: During backtesting every works completely fine, so I have no doubts about the general functioning of the code.


@arturbrylka

PanagiotisCharalampous
16 Mar 2021, 11:25

Dear arturbrylka,

Can I have the complete cBot code for both the cBot and indicator so that I can reproduce what you are looking at?

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous