protected override void OnBarUpdate()
{
double prevSma = SMA(20)[1];
// When the close of the bar crosses above the SMA(50) & above the SMA(20) one bar ago, draw a black diamond
if (CrossAbove(Close, SMA(50), 1) && Close[1] > prevSma)
{
/* Adding the 'CurrentBar' to the string creates unique draw objects because they will all have unique IDs
Having unique ID strings may cause performance issues if many objects are drawn */
DrawDiamond("Up Diamond" + CurrentBar, false, 0, SMA(50)[0], Color.Black);
}
// But when the close crosses below the SMA(50) and below the SMA(20) one bar ago, draw a black diamond
else if (CrossBelow(Close, SMA(50), 1) && Close[1] < prevSma)
{
/* Adding the 'CurrentBar' to the string creates unique draw objects because they will all have unique IDs
Having unique ID strings may cause performance issues if many objects are drawn */
DrawDiamond("Down Diamond" + CurrentBar, false, 0, SMA(50)[0], Color.Black);
}
Comment