EMA across multi timeframes

Created at 20 Jan 2022, 11:44
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!
SU

sue.bugg

Joined 09.01.2021

EMA across multi timeframes
20 Jan 2022, 11:44


Hi, wondering if someone can help me with this?

I’m trying to write an EMA over multiple timeframes, but it is not working. When I run it on one timeframe it looks like this

[Parameter("Fast EMA", DefaultValue = 9, Group = "EMA")]
        public int FastEMAPeriod { get; set; }

[Parameter("Fast EMA Source", DefaultValue = "Close", Group = "EMA")]
        public DataSeries SourceClose { get; set; }

 

private ExponentialMovingAverage _fastEMA;

 

_fastEMA = Indicators.ExponentialMovingAverage(SourceClose, FastEMAPeriod);

_fastEMA.Result.Last(1) > _fastEMA.Result.Last(1)

 

But if I try to do over multiple time frames – Daily, 1 Hour & 5 minute… I’m doing the following, but something is wrong

 

private ExponentialMovingAverage _fastEMADaily;

private ExponentialMovingAverage _fastEMAHourly;

private ExponentialMovingAverage _fastEMAFiveM;

 

_dailyBars = MarketData.GetBars(TimeFrame.Daily);
_hourlyBars = MarketData.GetBars(TimeFrame.Hour); 

_m5Bars = MarketData.GetBars(TimeFrame.Minute5);

 

_fastEMADaily = Indicators.ExponentialMovingAverage(SourceClose, FastEMAPeriod);

_fastEMAHourly = Indicators.ExponentialMovingAverage(SourceClose, FastEMAPeriod);

_fastEMAFiveM = Indicators.ExponentialMovingAverage(SourceClose, FastEMAPeriod);

 

_fastEMADaily.Result.Last(1) > _fastEMADaily.Result.Last(1)

 

This doesn’t work either. I think there is something wrong with this section

 

_fastEMADaily = Indicators.ExponentialMovingAverage(_dailyBars, SourceClose, FastEMAPeriod);

_fastEMAHourly = Indicators.ExponentialMovingAverage(_hourlyBars, SourceClose, FastEMAPeriod);

_fastEMAFiveM = Indicators.ExponentialMovingAverage(_m5Bars, SourceClose, FastEMAPeriod);

 

I appreciate any assistance please

Thanks

Sue


@sue.bugg
Replies

sue.bugg
21 Jan 2022, 07:50

No need to respond, I've figured it out


@sue.bugg