MACD different timeframe
MACD different timeframe
03 Nov 2022, 20:15
Hello!
I want cBot to trade on the m1 timeframe, but make calculations based on the MacdHistogram indicator with the ability to select a timeframe, for example h1
private MacdHistogram mcd;
private Bars source;
protected override void OnStart()
{
source = MarketData.GetBars(TimeFrame.Hour, SymbolName);
mcd = Indicators.MacdHistogram(source.ClosePrices,shortCycle, longCycle, signalPeriod);
}
I did it. OK. But then, when trying to use the MASD () data in the OnBar and OnTick methods, he doesn't care, he counts by closing the bar of the current timeframe/tick. Seems I need to create some kind of "dancing with a tambourine" so that he, like, waits until 12 M5 bars are collected, for example, in order to calculate the closing price of an hourly bar?
Replies
v.fiodorov83
03 Nov 2022, 22:58
RE: RE: https://ctrader.com/forum/calgo-support/39249 have a look here
Alwin123 said:
v.fiodorov83 said:
Hello!
I want cBot to trade on the m1 timeframe, but make calculations based on the MacdHistogram indicator with the ability to select a timeframe, for example h1
private MacdHistogram mcd; private Bars source; protected override void OnStart() { source = MarketData.GetBars(TimeFrame.Hour, SymbolName); mcd = Indicators.MacdHistogram(source.ClosePrices,shortCycle, longCycle, signalPeriod); }
I did it. OK. But then, when trying to use the MASD () data in the OnBar and OnTick methods, he doesn't care, he counts by closing the bar of the current timeframe/tick. Seems I need to create some kind of "dancing with a tambourine" so that he, like, waits until 12 M5 bars are collected, for example, in order to calculate the closing price of an hourly bar?
Yes. I saw this post, and thats my correct code for this task here in my post - Intitialize on start. But then begins bugs which I described
@v.fiodorov83
Alwin123
03 Nov 2022, 22:16 ( Updated at: 03 Nov 2022, 22:17 )
RE: https://ctrader.com/forum/calgo-support/39249 have a look here
v.fiodorov83 said:
@Alwin123