This is the code:-
protected override void Initialize()
{
Add(PeriodType.Minute, 15);
CalculateOnBarClose = true;
EMA(Closes[1], fEMA).Plots[0].Pen.Color = Color.Black;
EMA(Closes[1], sEMA).Plots[0].Pen.Color = Color.Red;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (BarsInProgess == 1)
{
if(CrossAbove(EMA(Closes[1], fEMA), EMA(Closes[1], sEMA), 1))
{
BarColor = Color.Green;
}
else if(CrossBelow(EMA(Closes[1], fEMA), EMA(Closes[1], sEMA), 1))
{
BarColor = Color.Red;
}
Print(EMA(Closes[1], fEMA)[0]);
Print(EMA(Closes[1], sEMA)[0]);
}
}
Comment