EMA from other timeframe
EMA from other timeframe
05 Jul 2021, 17:02
Hi
I'm new to cAlgo though have programming experience.
I'm wanting to code a bot that will check the values of 3 EMA on the 15 minute timeframe and check the stochastic on the 5 and 1 minute. I have the stochastic timeframes sorted as you can specify Bars when initializing the indicator. However, there doesn't seem to be the ability to specify the timeframe for the EMAs
I'm assuming it's possible to do this?
private Bars data1Min;
private Bars data5Min;
private Bars data15Min;
private StochasticOscillator oneMinStochasticOscillator;
private StochasticOscillator fiveMinStochasticOscillator;
private MovingAverage ma1ExpMovingAverage;
private MovingAverage ma2ExpMovingAverage;
private MovingAverage ma3ExpMovingAverage;
protected override void OnStart()
{
// Define TimeFrames for indicators
data1Min = MarketData.GetBars(TimeFrame.Minute);
data5Min = MarketData.GetBars(TimeFrame.Minute5);
data15Min = MarketData.GetBars(TimeFrame.Minute15);
// Convert Lots to Units
volumeInUnits = Symbol.QuantityToVolumeInUnits(lotSize);
// Initiate Stochastic indicators for 1 and 5 minute TimeFrames
oneMinStochasticOscillator = Indicators.StochasticOscillator(data1Min, oneMinKValue, oneMinDValue, oneMinDPeriod, oneMAType);
fiveMinStochasticOscillator = Indicators.StochasticOscillator(data5Min, fiveMinKValue, fiveMinDValue, fiveMinDPeriod, fiveMAType);
// Initiate Exponential Moving Averages for 15 minute TimeFrame
ma1ExpMovingAverage = Indicators.MovingAverage(Source, ma1Period, ma1Type);
ma2ExpMovingAverage = Indicators.MovingAverage(Source, ma2Period, ma2Type);
ma3ExpMovingAverage = Indicators.MovingAverage(Source, ma3Period, ma3Type);
Replies
ctid3999979
07 Jul 2021, 12:00
RE:
PanagiotisCharalampous said:
Hi ctid3999979,
You are passing the wrong source to the MAs. It needs to be DataSeries, not Bars. See below
// Initiate Exponential Moving Averages for 15 minute TimeFrame ma1ExpMovingAverage = Indicators.MovingAverage(data1Min.ClosePrices, ma1Period, ma1Type); ma2ExpMovingAverage = Indicators.MovingAverage(data5Min.ClosePrices, ma2Period, ma2Type); ma3ExpMovingAverage = Indicators.MovingAverage(data15Min.ClosePrices, ma3Period, ma3Type);
Best Regards,
Panagiotis
Thanks a lot. I knew it would be something simple.
@ctid3999979
PanagiotisCharalampous
06 Jul 2021, 08:03
Hi ctid3999979,
You are passing the wrong source to the MAs. It needs to be DataSeries, not Bars. See below
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous