Monday, May 18, 2009

Why can't I get Lines and Histogram!!?

You can have both. Both Lines and a Histogram? Yes. Here is an example of how to do it with the MACD indicator.









declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;

plot Value = Ema2(data = close, "smoothing factor" = 2 / (1 + fastLength)) - Ema2(data = close, "smoothing factor" = 2 / (1 + slowLength));
plot Avg = ExpAverage(Value, MACDLength)[1];
plot baseline= 0;
Avg.SetDefaultColor(Color.Red);
Value.SetDefaultColor(Color.White);
baseline.SetDefaultColor(GetColor(5));
plot Diff = value - ExpAverage(Value, MACDLength)[1];
diff.AssignValueColor(if Diff >= 0 then Color.UPTICK else Color.DOWNTICK);
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
blog comments powered by Disqus