Exponential Moving Average Help
09 Sep 2016, 23:19
Can some please help me convert this Indicator to Exponential Moving Average
Thanks all for reading
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Lib;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class FastCrossSlow : Indicator
{
[Parameter("MA Type", DefaultValue = 6)]
public MovingAverageType MaType { get; set; }
[Parameter("Slow Period", DefaultValue = 11, MinValue = 1)]
public int SlowPeriod { get; set; }
[Parameter("Fast Period", DefaultValue = 5, MinValue = 1)]
public int fastPeriod { get; set; }
[Output("slowMa", Thickness = 2, Color = Colors.DeepSkyBlue)]
public IndicatorDataSeries SlowMAResult { get; set; }
[Output("fastMA", Thickness = 2, Color = Colors.Green)]
public IndicatorDataSeries FastMAResult { get; set; }
private string upArrow = "▲";
private string downArrow = "▼";
private double arrowOffset;
MovingAverage slowMA;
MovingAverage fastMA;
protected override void Initialize()
{
fastMA = Indicators.MovingAverage(MarketSeries.Close, fastPeriod, MaType);
slowMA = Indicators.MovingAverage(MarketSeries.Close, SlowPeriod, MaType);
arrowOffset = Symbol.PipSize * 5;
}
public override void Calculate(int index)
{
FastMAResult[index] = fastMA.Result[index];
SlowMAResult[index] = slowMA.Result[index];
double high = MarketSeries.High[index];
double low = MarketSeries.Low[index];
if (isCrossAbove())
ChartObjects.DrawText(string.Format("Buy {0}", index), upArrow, index - 1, low - arrowOffset, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Green);
if (isCrossBelow())
ChartObjects.DrawText(string.Format("Sell {0}", index), downArrow, index - 1, high + arrowOffset, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Red);
}
#region Predicate
public bool isCrossAbove()
{
return FastMAResult.HasCrossedAbove(SlowMAResult, 0);
}
public bool isCrossBelow()
{
return FastMAResult.HasCrossedBelow(SlowMAResult, 0);
}
#endregion
}
}

... Deleted by UFO ...