Jim Cramers' S&P Oscillator for ThinkorSwim

Happyfadez

New member
2019 Donor
Does anyone know which indicator is similar to Jim Cramer's mention the S&P Oscillator but for ThinkorSwim?

Is this it?

Code:
# McClellan Oscillator    
# Example for using label instead of indicator
# Nube 10.19.18

declare lower;

    # inputs
input exchange = {NYSE, NASDAQ, default SPX};
input fastLength = 19;
input slowLength = 39;

    # variablea
def advances;
def declines;
switch (exchange) {
case SPX:
    advances = close("$ADVSP");
    declines = close("$DECLSP");
case NYSE:
    advances = close("$ADVN");
    declines = close("$DECN");
case NASDAQ:
    advances = close("$ADVN/Q");
    declines = close("$DECN/Q");
}

def advance = if   !IsNaN(advances)
              then advances 
              else advance[1];
def decline = if   !IsNaN(declines)
              then declines
              else decline[1];

def ad = if   advance + decline > 0
         then (advance - decline) / (advance + decline)
         else ad[1];
def emaFast = ExpAverage(ad, fastLength);
def emaSlow = ExpAverage(ad, slowLength);

def mcClellanOsc = if   !IsNaN(close) 
                   then emaFast - emaSlow            
                   else Double.NaN;

    # plots   
plot 
ZeroLine = 0;
ZeroLine.  SetDefaultColor(Color.Gray);
ZeroLine.  SetStyle(Curve.Long_Dash);
    
plot 
AverageMc = Average(mcClellanOsc,fastLength);
AverageMc.  SetDefaultColor(Color.Gray);

plot 
McOsc = mcClellanOsc;
McOsc.  AssignValueColor(if   McOsc < AverageMc    
                         then if   McOsc < McOsc[1]
                              then Color.Red
                              else Color.Gray
                         else if   McOsc < McOsc[1]
                              then Color.Gray
                              else Color.Green);

addcloud(McOsc, 0, Color.Dark_Gray, Color.Dark_Gray);

AddLabel(SecondsTillTime(1530) > 0, " ", 
                         if   McOsc < AverageMc    
                         then if   McOsc < McOsc[1]
                              then Color.Red
                              else Color.Gray
                         else if  McOsc < McOsc[1]
                              then Color.Gray
                              else Color.Green);
 
Last edited by a moderator:

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

Similar threads

Top