MACD Histogram other Time Frame

Created at 20 Sep 2020, 07:34
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!
DE

defontein93

Joined 20.09.2020

MACD Histogram other Time Frame
20 Sep 2020, 07:34


Dear Experts,

I am developing a bot to run in the 15-Minutes Time Frame, 
and I need the bot to only enter a trade according to the MACD Histogram in the 1-Hour Time Frame.
Is this possible to be done and how would it be done ?

Any response would be highly appreciated. Thank you.

Note : I have tried the EMA/RSI/ATR Multi Time Frame examples and all works well with the bot, 
but have no success with the MACD Histogram.


 


@defontein93
Replies

firemyst
20 Sep 2020, 14:36

RE:

defontein93 said:

Dear Experts,

I am developing a bot to run in the 15-Minutes Time Frame, 
and I need the bot to only enter a trade according to the MACD Histogram in the 1-Hour Time Frame.
Is this possible to be done and how would it be done ?

Any response would be highly appreciated. Thank you.

Note : I have tried the EMA/RSI/ATR Multi Time Frame examples and all works well with the bot, 
but have no success with the MACD Histogram.


 

In your bot get the MACD based on the 1 hour time frame data instead of the 15 minute data.

Sample code off the top of my head:

var _macd = Indicators.MacdCrossOver(MarketData.GetBars(TimeFrame.Hour, Symbol.Name), MACDLongPeriod, MACDShortPeriod, MACDSignalPeriod);

You have to fill in the MACD Long/Short/Signal period variable values are per what you want them to be.

Good luck :-)

 


@firemyst

defontein93
20 Sep 2020, 16:32

RE: RE:

firemyst said:

In your bot get the MACD based on the 1 hour time frame data instead of the 15 minute data.

Sample code off the top of my head:

var _macd = Indicators.MacdCrossOver(MarketData.GetBars(TimeFrame.Hour, Symbol.Name), MACDLongPeriod, MACDShortPeriod, MACDSignalPeriod);

You have to fill in the MACD Long/Short/Signal period variable values are per what you want them to be.

Good luck :-)

 

Dear firemyst,

Thank you for responding :-)

I have tried your suggestions and the following error codes show up :

Error CS1502: The best overloaded method match for 'cAlgo.API.Internals.IIndicatorsAccessor.MacdCrossOver(cAlgo.API.DataSeries, int, int, int)' has some invalid arguments
Error CS1503: Argument 1: cannot convert from 'cAlgo.API.Bars' to 'cAlgo.API.DataSeries'

Unlike EMA / RSI / ATR, it seems that for MacdCrossOver (the same goes for MacdHistogram), format DataSeries is needed, so it cannot be filled with MarketData.GetBars(TimeFrame.Hour) ?

Any ideas for a workaround or maybe other suggestions ? 

 


@defontein93

firemyst
20 Sep 2020, 17:52

RE: RE: RE:

defontein93 said:

firemyst said:

In your bot get the MACD based on the 1 hour time frame data instead of the 15 minute data.

Sample code off the top of my head:

var _macd = Indicators.MacdCrossOver(MarketData.GetBars(TimeFrame.Hour, Symbol.Name), MACDLongPeriod, MACDShortPeriod, MACDSignalPeriod);

You have to fill in the MACD Long/Short/Signal period variable values are per what you want them to be.

Good luck :-)

 

Dear firemyst,

Thank you for responding :-)

I have tried your suggestions and the following error codes show up :

Error CS1502: The best overloaded method match for 'cAlgo.API.Internals.IIndicatorsAccessor.MacdCrossOver(cAlgo.API.DataSeries, int, int, int)' has some invalid arguments
Error CS1503: Argument 1: cannot convert from 'cAlgo.API.Bars' to 'cAlgo.API.DataSeries'

Unlike EMA / RSI / ATR, it seems that for MacdCrossOver (the same goes for MacdHistogram), format DataSeries is needed, so it cannot be filled with MarketData.GetBars(TimeFrame.Hour) ?

Any ideas for a workaround or maybe other suggestions ? 

 

It can.

All you have to do is make it a data series.

For instance, ".ClosePrices" is a data series.

.HighPrices is a data series.

.LowPrices is a data series.

.OpenPrices is a data series.

Which one do you want to use?

Just add it on to turn the "cAlgo.API.Bars" into a "cAlgo.API.DataSeries".

I'd do it for you, but then you'd never learn. :-)

 

 


@firemyst

defontein93
21 Sep 2020, 17:11

RE: RE: RE: RE:

firemyst said:

It can.

All you have to do is make it a data series.

For instance, ".ClosePrices" is a data series.

.HighPrices is a data series.

.LowPrices is a data series.

.OpenPrices is a data series.

Which one do you want to use?

Just add it on to turn the "cAlgo.API.Bars" into a "cAlgo.API.DataSeries".

I'd do it for you, but then you'd never learn. :-)

 

 

I think I got it. Thanks very much :-)


@defontein93