Simple $TICK Index for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
This indicator will show the NYSE $TICK index as a lower study in your ThinkorSwim. Great for anyone who wants to easily track the market internal while looking at the indices like SPY.
  • When TICK value is above 800 = market is considered overbought
  • When TICK value is below -800 = market is considered oversold


thinkScript Code

Code:
# Simple TICK
# Assembled by BenTen at UseThinkScript.com

declare lower;

def value = close("$TICK");
plot tick = value;
plot ob1 = 800;
plot ob2 = 1000;
plot os1 = -800;
plot os2 = -1000;
tick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ob1.assignvaluecolor(color.light_red);
ob2.assignValueColor(color.red);
os1.assignvaluecolor(color.light_green);
os2.assignValueColor(color.green);
 
Z

Zlotko

New member
VIP
Did anyone try to do this code for Trin? The Better TRIN Indicator with the Emini

By making some simple mathematical adjustments to the original TRIN Indicator formula you can make a more intuitive and accurate indicator. Here’s what to do to create a Better TRIN Indicator:
  1. Take the Log of the NYSE TRIN value
  2. Invert this value so negative values are positive and vice versa
  3. Multiply the inverted Log value by 100, and
  4. Repeat for the NASDAQ TRIN data and average the two values
  • Values range between -100 and +100, with 0 as the neutral point
  • Positive values indicate buying and a market in an upswing
  • Negative results indicate selling activity and downward moves in the market
  • Values are balanced, requiring the same amount of buying or selling for the indicator to be +100 or -100 and, therefore, averages are accurate
 
Welkin

Welkin

Active member
VIP
have a slightly different way of plotting tick, figured I'd post it here, also includes alerts when tick reaches specified threshold (default +/- 1000) and plots a vertical line when threshold is reached, plus labels for breadth ratio, put/call ratio, and vix:

the labels are dark due to markets being closed, but the blue represents the tick high, orange is tick low and green or red depends on if it closes above or below zeroline. I find it easier to see the slope of the $tick trend this way.
Code:
#[email protected]
declare lower;

input alerttype = Alert.BAR;
input alertsound = Sound.DING;
input alertThreshold = 1000;

plot zeroline = 0;
plot tick500 = 500;
plot tick500m = -500;
plot tick1000 = 1000;
plot tick1000m = -1000;

DefineGlobalColor("Vertical Line Color", Color.WHITE);

def NA = Double.NaN;
def ticko = open("$TICK");
plot tickc = close("$TICK");
plot tickh = high("$TICK");
plot tickl = low("$TICK");

def tickh1000test = tickh >= alertThreshold;
def tickl1000test = tickl <= -alertThreshold;
Alert(tickh1000test, " >+1000 $TICK", alerttype, alertsound);
Alert(tickl1000test, " <-1000 $TICK", alerttype, alertsound);
AddVerticalLine(tickh1000test, "+"+alertThreshold, GlobalColor("Vertical Line Color"));
AddVerticalLine(tickl1000test, "-"+alertThreshold, GlobalColor("Vertical Line Color"));

def PCALL = Round(close("$PCALL"),2);
def NYSEUVOL = close("$UVOL");
def NYSEDVOL = close("$DVOL");

def BR = Round(if NYSEUVOL >= NYSEDVOL then NYSEUVOL / NYSEDVOL else -(NYSEDVOL/NYSEUVOL),2);
AddLabel(1,"$TICK: "+ tickc, if tickc > 0 then Color.GREEN else Color.RED);
AddLabel(1,"BR: " + BR ,if BR > 0 then Color.GREEN else Color.RED);
AddLabel(1,"$PCALL: " + PCALL, Color.GRAY);
AddLabel(1, "VIX: "+ close("VIX"), Color.GRAY);

zeroline.SetDefaultColor(Color.BLACK);
tick500.SetDefaultColor(Color.GRAY);
tick500m.SetDefaultColor(Color.GRAY);
tick1000.SetDefaultColor(Color.GRAY);
tick1000m.SetDefaultColor(Color.GRAY);
tick1000.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
tick1000m.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
tick1000.SetLineWeight(2);
tick1000m.SetLineWeight(2);

tickh.SetPaintingStrategy(PaintingStrategy.Squared_HISTOGRAM);
tickh.SetDefaultColor(CreateColor(0,100,200));
tickl.SetPaintingStrategy(PaintingStrategy.Squared_HISTOGRAM);
tickl.SetDefaultColor(Color.DARK_ORANGE);
tickc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
tickc.AssignValueColor(if tickc > 0 then color.green else color.red);
 
Last edited:
S

sunnyr

New member
VIP


Code:
# AD, TICK Study

# Mobius



declare lower;



def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and

          GetTime() <= RegularTradingEnd(GetYYYYMMDD());

def x = if RTH and !RTH[1]

        then 1

        else if RTH then x[1] + 1

        else x[1];

def o = if RTH and !RTH[1]

        then open(symbol = "$ADSPD")

        else o[1];

def h = if RTH and !RTH[1]

        then high(symbol = "$ADSPD")

        else if high(symbol = "$ADSPD") > h[1]

             then high(symbol = "$ADSPD")

             else h[1];

def l = if RTH and !RTH[1]

        then low(symbol = "$ADSPD")

        else if low(symbol = "$ADSPD") < l[1]

             then low(symbol = "$ADSPD")

             else l[1];

def c = if IsNaN(close(symbol = "$ADSPD"))

        then c[1]

        else close(symbol = "$ADSPD");

def sumC = if RTH and !RTH[1]

           then c

           else if RTH

                then sumC[1] + c

                else sumC[1];

plot cumC = if RTH and !IsNaN(close)

            then sumC / x

            else Double.NaN;

     cumC.SetStyle(Curve.FIRM);

     cumC.AssignValueColor(if cumC > cumC[1]

                           then Color.GREEN

                           else Color.RED);

     cumC.SetLineWeight(1);

     cumC.HideBubble();

     cumC.HideTitle();

plot AD = if RTH and !IsNaN(close)

          then Round(Inertia(c, 13), 0)

          else Double.NaN;

     AD.SetStyle(Curve.FIRM);

     AD.SetLineWeight(2);

     AD.AssignValueColor(if AD > cumC and AD > AD[1]

                         then Color.DARK_GREEN

                         else if AD > cumC and AD < AD[1]

                              then Color.GREEN

                              else if AD < cumC and AD < AD[1]

                                   then Color.DARK_RED

                         else Color.RED);

AddLabel(1, "AD open = " + o +

          "  high = " + h +

          "  low = " + l +

          "  close = " + c, if AD < AD[1]

                              then Color.RED

                              else Color.GREEN);

def t = if IsNaN(close(symbol = "$TICK"))

        then t[1]

        else close(symbol = "$TICK");

def sumT = if RTH and !RTH[1]

           then t

           else if RTH

                then sumT[1] + t

                else sumT[1];

plot cumT = if RTH and !IsNaN(close)

            then sumT / x

            else Double.NaN;

     cumT.SetStyle(Curve.FIRM);

     cumT.AssignValueColor(if cumT > cumT[1]

                           then Color.BLUE

                           else Color.YELLOW);

     cumT.SetLineWeight(2);

     cumT.HideBubble();

     cumT.HideTitle();

plot avg_t = if RTH and !IsNaN(close)

             then Round(Inertia(t, 10), 0)

             else Double.NaN;

     avg_t.SetLineWeight(2);

     avg_t.AssignValueColor(if avg_t > cumT then Color.BLUE else Color.YELLOW);



plot zero = if RTH and !IsNaN(close("$TICK"))

            then 0

            else Double.NaN;

     zero.SetStyle(Curve.LONG_DASH);

     zero.SetDefaultColor(Color.Gray);

     zero.SetLineWeight(2);

AddCloud(cumC,  AD,  Color.RED,  Color.GREEN);

AddCloud(cumT, avg_t, Color.YELLOW, Color.BLUE);

AddCloud(0, if AD < cumC and AD > 0

            then AD

            else double.nan, Color.light_gray, color.light_gray);

AddLabel(1, "TICK = " + t, if avg_t > avg_t[1] then Color.GREEN else Color.RED);

Alert(t >= 1000, "", Alert.BAR, Sound.Ring);

Alert(t <= -1000, "", Alert.BAR, Sound.Bell);

AddVerticalLine(t crosses above 1000, "TICK 1000", Color.GREEN);

AddVerticalLine(t crosses below -1000, "TICK -1000", Color.RED);

# End Code

Does anyone know how to use this study? I could not find instruction in the onedrive. Thank you!

Edit: so after reviewing the code more the blue and yellow are attached to $ADSPD still not exactly sure what the Green and red are following. maybe lagging price on a longer period?
 
Last edited:
M

Miket

Member
Can someone code the following so when the edge of the line is sloping up its green, sloping down is red, and straight horizontal yellow? I'm trying to get a sense of all 4 indices if they are having positive or negatives ticks before I enter in a trade. Any other ideas greatly appreciated.

Code:
# Mobius Dev
# V03.25.2017

declare lower;

input closeTime = 1555;
input labelOffset = 5;
input showFloatingLabels = yes;

def openTime = 0930;
def rawTickData1 = hlc3("$TICK");
def rawTickData2 = hlc3("$TIKRL");
def rawTickData3 = hlc3("$TIKSP");
def rawTickData4 = hlc3("$TICK/Q");
def maxTick1 = close("$ADVN") + close("$DECN") + close("$UNCN");
def maxTick2 = close("$ADVRL") + close("$DECLRL") + close("$UNCHRL");
def maxTick3 =  close("$ADVSP") + close("$DECLSP") + close("$UNCHSP");
def maxTick4 =  close("$ADVN/Q") + close("$DECN/Q") + close("$UNCN/Q");
def TickData1 = rawTickData1 / maxTick1;
def TickData2 = rawTickData2 / maxTick2;
def TickData3 = rawTickData3 / maxTick3;
def TickData4 = rawTickData4 / maxTick4;
def CT1 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT1[1] + TickData1
               else 0;
plot cumulativeTick1 = if !IsNaN(TickData1) and
                           CT1 <> 0
                       then CT1
                       else Double.NaN;
def CT2 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT2[1] + TickData2
               else 0;
plot cumulativeTick2 = if !IsNaN(TickData2) and
                           CT2 <> 0 
                       then CT2
                       else Double.NaN;
def CT3 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT3[1] + TickData3
               else 0;
plot cumulativeTick3 = if !IsNaN(TickData3) and
                           CT3 <> 0
                       then CT3
                       else Double.NaN;
def CT4 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT4[1] + TickData4
               else 0;
plot cumulativeTick4 = if !IsNaN(TickData4) and
                           CT4 <> 0
                       then CT4
                       else Double.NaN;
plot CT1DownTick = if cumulativeTick1 < cumulativeTick1[1]
                   then cumulativeTick1
                   else Double.NaN;
CT1DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT1DownTick.SetDefaultColor( color.white);
CT1DownTick.SetLineWeight(1);
CT1DownTick.HideBubble();
plot CT2DownTick = if cumulativeTick2 < cumulativeTick2[1]
                   then cumulativeTick2
                   else Double.NaN;
CT2DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT2DownTick.SetDefaultColor( color.white);
CT2DownTick.SetLineWeight(1);
CT2DownTick.HideBubble();
plot CT3DownTick = if cumulativeTick3 < cumulativeTick3[1]
                   then cumulativeTick3
                   else Double.NaN;
CT3DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT3DownTick.SetDefaultColor( color.white);
CT3DownTick.SetLineWeight(1);
CT3DownTick.HideBubble();

plot CT4DownTick = if cumulativeTick4 < cumulativeTick4[1]
                   then cumulativeTick4
                   else Double.NaN;
CT4DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT4DownTick.SetDefaultColor( color.white);
CT4DownTick.SetLineWeight(1);
CT4DownTick.HideBubble();
cumulativeTick1.SetDefaultColor(Color.MAGENTA);
cumulativeTick1.SetLineWeight(5);
cumulativeTick2.SetDefaultColor(Color.Dark_green);
cumulativeTick2.SetLineWeight(5);
cumulativeTick3.SetDefaultColor(Color.DARK_RED);
cumulativeTick3.SetLineWeight(5);
cumulativeTick4.SetDefaultColor(Color.BLUE);
cumulativeTick4.SetLineWeight(5);
cumulativeTick1.HideBubble();
cumulativeTick2.HideBubble();
cumulativeTick3.HideBubble();
cumulativeTick4.HideBubble();
plot allUp = if cumulativeTick1 > cumulativeTick1[1] and
                cumulativeTick2 > cumulativeTick2[1] and
                cumulativeTick3 > cumulativeTick3[1] and
                cumulativeTick4 > cumulativeTick4[1]
             then 0
             else Double.NaN;
allUp.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
allUp.SetDefaultColor(Color.green);
allUp.setLineWeight(5);
allup.HideBubble();
plot allDown = if cumulativeTick1 < cumulativeTick1[1] and
                  cumulativeTick2 < cumulativeTick2[1] and
                  cumulativeTick3 < cumulativeTick3[1] and
                  cumulativeTick4 < cumulativeTick4[1]
               then 0
               else Double.NaN;
allDown.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
allDown.SetDefaultColor(Color.red);
allDown.SetLineWeight(5);
allDown.HideBubble();
plot zero = if isNaN(close) then double.nan else 0;
zero.SetDefaultColor(Color.WHITE);
zero.HideBubble();
zero.HideTitle();
AddVerticalLine(SecondsTillTime(openTime) == 0 or (GetDay() != GetDay()[1] and (SecondsTillTime(0000) > 0)), "", Color.GRAY, 1);
AddLabel(!showFloatingLabels, "NYSE", Color.MAGENTA);
AddLabel(!showFloatingLabels, "NASDAQ", Color.BLUE);
AddLabel(!showFloatingLabels, "SP500", Color.DARK_RED);
AddLabel(!showFloatingLabels, "R2000", Color.Dark_green);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick1[labelOffset], "NYSE", Color.MAGENTA, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick4[labelOffset], "NASDAQ", Color.BLUE, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick3[labelOffset], "SP500", Color.DARK_RED, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick2[labelOffset], "R2000", Color.DARK_GREEN, yes);

# End Code
 
A

alokranjan3

New member
@BenTen
Can you, please, help with the following indicator?

Stan Weinstein's MOMENTUM INDEX
Stan Weinstein also uses a 200-day moving average of the daily AD figures, which he calls his Momentum Index (MI).
  • The most important MI signal is crossing the zero line – a move up is bullish, and a move down is bearish.
  • The longer the line has been on the other side of zero, the stronger is the crossing signal.
 
TheGrimmReaper

TheGrimmReaper

New member
@Zlotko I saw this from Barry Taylor and have the same question as you...
 
BenTen

BenTen

Administrative
Staff
VIP
@alokranjan3 @TheGrimmReaper So you just add the 200 SMA to the Daily chart?

 
A

alokranjan3

New member
@alokranjan3 @TheGrimmReaper

Please, use this link. I tried to make it based on Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets. My first contribution to this forum.

http://tos.mx/qyoNOz8

Code:
#Market Momentum Index from Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets



Script for Stan's momentum index

declare lower;
input AvgType = AverageType.WILDERS;
input Length = 200;
input level=0;
input exchange = {default NYSE, NASDAQ, AMEX};

def advnDecn = AdvanceDecline(type = "Advance/Decline Line (Daily)", exchange = exchange);


plot Data = MovingAverage(AvgType, advnDecn, Length);
plot LevelLine = level;

# End Code
http://tos.mx/ZixYnsb

This is the link to chart set-up based on Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets.
 
Last edited by a moderator:

Similar threads

Top