Pete
I’m trying to get the color of the SMI to a watchlist…If SMI is red W/L background is red and the same if SMI is green…
declare lower;
input audioalarm=yes;
input Price = hlc3;
input RsqLength = 5;
input RsqLimit = .5;
input SmiLimit = 30;
input chopband2= 70;
input smibarbufr = 4;
input showBreakoutSignals = yes;
def overbought = SmiLimit;
def oversold = -SmiLimit;
def percentDLength = 4;
def percentKLength = 5;
# Stochastic Momentum Index (SMI)
def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close – (max_high + min_low) / 2;
def diff = max_high – min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diff, percentDLength), percentDLength);
plot chopband = if IsNaN(close) then Double.NaN else 0;
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
#SMI.SetDefaultColor(Color.BLUE);
SMI.DefineColor(“Up”, CreateColor(0, 153, 51));
SMI.definecolor(“Weak”, Color.LIGHT_GRAY);
SMI.DefineColor(“Down”, Color.RED);
SMI.AssignValueColor(if SMI > SMI[1] then SMI.Color(“Up”) else if SMI < SMI[1] then SMI.Color(“Down”) else SMI.Color(“Weak”));
SMI.SetLineWeight(2);
SMI.SetStyle(Curve.SHORT_DASH);
SMI.SetLineWeight(3);
plot AvgSMI = ExpAverage(SMI, percentDLength);
AvgSMI.DefineColor(“Up”, CreateColor(0, 153, 51));
AvgSMI.definecolor(“Weak”, Color.LIGHT_GRAY);
AvgSMI.DefineColor(“Down”, Color.RED);
AvgSMI.AssignValueColor(if AvgSMI > AvgSMI[1] then AvgSMI.Color(“Up”) else if AvgSMI < AvgSMI[1] then AvgSMI.Color(“Down”) else AvgSMI.Color(“Weak”));
AvgSMI.SetLineWeight(3);
Like this:
Like Loading...