Very simple question. Why does this work fine on historical bars and live bars when using onbarclose, but when I set to onpricechange, no live bars are painted? It's obviously something to do with the last line but I can't figure out how I should amend for realtime. Thanks.
if (CurrentBar < 20)
return;
double smoothingFactor = 2.0 / (period + 1);
double currentEMA = (Input[0] - previousEMA) * smoothingFactor + previousEMA;
if (currentEMA > previousEMA)
{
BarBrush = Brushes.Lime;
}
else if (currentEMA < previousEMA)
{
BarBrush = Brushes.Red;
}
else
{
BarBrush = Brushes.Transparent;
}
previousEMA = currentEMA;
Comment