Is there a possibility to added a red color when McClellan goes below 0 and turns negative? I am using the standard one from thinkorswim, but when negative it shows the same color as possible. Thanks!
I modified the standard indicator for the same reason.
Added capibility to plot it on intraday charts. Refer to "periodicity" to indicate multiple to make it equal to daily version eg. on 30 min chart use 13
------------------------------------------------------------------------------------------
declare lower;
input exchange = {default NYSE, NASDAQ, AMEX};
input fastLength = 19;
input slowLength = 39;
input periodicity = 1;
input ratioAdjusted = Yes;
input isCumulative = Yes;
def advances;
def declines;
switch (exchange) {
case NYSE:
advances = close("$ADVN");
declines = close("$DECN");
case NASDAQ:
advances = close("$ADVN/Q");
declines = close("$DECN/Q");
case AMEX:
advances = close("$ADVA");
declines = close("$DECA");
}
def breadth;
def neutral_level;
def over_bought;
def over_sold;
if (ratioAdjusted) {
breadth = 1000 * (advances - declines) / (advances +
declines);
neutral_level = 0;
over_bought = 500;
over_sold = -500;
} else {
breadth = advances - declines;
neutral_level = 1000;
over_bought = Double.NaN;
over_sold = Double.NaN;
}
def emaFastCorr = ExpAverage(CompoundValue(1, if !IsNaN(breadth) then breadth else emaFastCorr[1], 0), fastLength*periodicity);
def emaSlowCorr = ExpAverage(CompoundValue(1, if !IsNaN(breadth) then breadth else emaSlowCorr[1], 0), slowLength*periodicity);
def mcClellanOsc = if !IsNaN(close) then emaFastCorr - emaSlowCorr else Double.NaN;
def mcClellanSummationIndex = mcClellanSummationIndex[1] + if !IsNaN(breadth) then mcClellanOsc else 0;
plot SummationIndex;
if IsNaN(close) {
SummationIndex = Double.NaN;
} else if (isCumulative) {
SummationIndex = neutral_level + mcClellanSummationIndex;
} else {
SummationIndex = neutral_level + mcClellanOsc - (10 * emaFastCorr + 20 * emaSlowCorr);
}
plot OverBought = over_bought;
plot OverSold = over_sold;
plot NeutralLevel = neutral_level;
SummationIndex.DefineColor("Up", GetColor(1));
SummationIndex.DefineColor("Down", GetColor(0));
SummationIndex.AssignValueColor(if SummationIndex > SummationIndex[1] then SummationIndex.color("Up") else SummationIndex.color("Down"));
OverBought.SetDefaultColor(GetColor(5));
OverSold.SetDefaultColor(GetColor(5));
NeutralLevel.SetDefaultColor(GetColor(7));