Cybersloth
Member
This simplified SMI indicator kindly provided by Dap is very useful on its own but is also interesting when examined comparatively in juxtaposition with other SMI indicator lengths on the same panel (the default setting is 4) rather than on different lower indicator panels. However, I notice when I place the settings at, say, 4 and 13 for the two comparative lengths SMI on the same panel, the zero line is not quite the same for either. Is there a way to align 2 or more SMI studies with varying lengths at the same zero point in a single panel? The formula for the study is below.
##SMI
declare lower;
input Length = 4;
#Add your indicator code here (if you want to use this as a template)
def min_low = Lowest(low, Length+1);
def max_high = Highest(high, Length+1);
def rel_diff = close - (max_high + min_low) / 2;
def range = max_high - min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, Length), Length );
def avgdiff = ExpAverage(ExpAverage(range, Length), Length);
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
SMI.DefineColor("Up", GetColor(1));
SMI.DefineColor("Down", GetColor(0));
SMI.AssignValueColor(if SMI > SMI[1] then SMI.color("Up") else SMI.color("Down"));
SMI.SetLineWeight(2);
plot line_0 = 0;
##
##SMI
declare lower;
input Length = 4;
#Add your indicator code here (if you want to use this as a template)
def min_low = Lowest(low, Length+1);
def max_high = Highest(high, Length+1);
def rel_diff = close - (max_high + min_low) / 2;
def range = max_high - min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, Length), Length );
def avgdiff = ExpAverage(ExpAverage(range, Length), Length);
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
SMI.DefineColor("Up", GetColor(1));
SMI.DefineColor("Down", GetColor(0));
SMI.AssignValueColor(if SMI > SMI[1] then SMI.color("Up") else SMI.color("Down"));
SMI.SetLineWeight(2);
plot line_0 = 0;
##