How to use GetBars as a 2nd TimeFrame Source for Indicators

Created at 23 Jul 2020, 19:36
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!
AC

ac15x

Joined 22.07.2020

How to use GetBars as a 2nd TimeFrame Source for Indicators
23 Jul 2020, 19:36


Hi,

 

I want two indicators for two different time frames:

 

 protected override void OnStart()
        {
            _emaLow = Indicators.ExponentialMovingAverage(SourceSma, 9); //current timeframe 1HR

            var dataSeries = MarketData.GetBars(TimeFrame.Hour4, SymbolName);

            _emaHigh = Indicators.ExponentialMovingAverage(dataSeries , 9); //timeframe 4HR
        }

 

I was told to use GETBars but it is not a valid type to pass on the indicator.

 

Thanks


@ac15x
Replies

PanagiotisCharalampous
24 Jul 2020, 08:12

Hi ac15x,

Here is the correct way to do it

 var emaHigh = Indicators.ExponentialMovingAverage(MarketData.GetBars(TimeFrame.Hour4, SymbolName).Close, 9);

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous