How to push last 10000 minute bars through custom indicator when starting bot in live trading mode
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!
Replies
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
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
@PanagiotisCharalampous
arturbrylka
16 Mar 2021, 10:54
RE:
PanagiotisCharalampous said:
Dear arturbrylka,
Can you explain in more detail what do you mean when you saybeen 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
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
@PanagiotisCharalampous
PanagiotisCharalampous
16 Mar 2021, 10:11
Dear arturbrylka,
You can use LoadMoreHistory method to achieve this.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous