I am not very familiar with using IDataSeries in my coding and am encountering some problems when using it. See the code below. In particular, the fastMA and slowMA (which are data series coming from a multi-timeframe indicator called Trend) conditions in the if statement are not producing any values and as a result the code is producing the wrong outcome.
protectedoverridevoid OnBarUpdate()
{
IDataSeries fastMA = Trend(Fast, PeriodType, PeriodValue, Slow, Type).FastMA;
IDataSeries slowMA = Trend(Fast, PeriodType, PeriodValue, Slow, Type).SlowMA;
if (CurrentBar < Slow) // Sufficient data check
return;
if ((fastMA[0] > slowMA[0] && fastMA[1] <= slowMA[1])
|| (fastMA[0] < slowMA[0] && fastMA[1] >= slowMA[1]))
lookBack = 1; // Resets lookBack at the start of a new trend
else
lookBack++;
Am I doing something wrong? Do you have any examples I can look at to understand how to implement this code?
Thanks,
Stopped
Comment