For example, suppose I plot the SMA of Close, SMA(Close,10) and I also calculate the momentum of this SMA, Momentum(SMA(Close,10), 5). I want to plot the portions of the SMA curve green where the momentum is above a "long threshold" value, and plot the curve red when it is below a "short threshold" value and plot it white if the momentum falls between the two threshold values:
Schematically:
if ( Momentum(SMA(Close,10), 5)[0] > LongThreshold)
plot SMA(Close,10) green;
else if ( Momentum(SMA(Close,10), 5)[0] < ShortThreshold)
plot SMA(Close,10) red;
else
plot SMA(Close,10) white;
How would I do this formally?
Can I insert an appropriate "if statement" into the argument of the AddPlot statement so that it would look something like this:
AddPlot(Brushes.{if(....)...}, "SMAPlot");
Would this continually update the color as the curve is plotted?
Thank you for your advice.
Comment