Accumulative $TICK Meter and Index for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
Someone recently mentioned that the $TICK index can be used for trend confirmation. I just came across this post in the Yahoo thinkScript group so I thought I would share it here as well.



Accumulative $TICK Meter

Code:
#Hint: The NYSE TICK represents, at any given moment, the net number of stocks in the broad market that are trading at their offer prices minus those trading at their bids. When the NYSE TICK becomes very positive, it means that traders are lifting offers in the broad market: buyers are quite aggressive. When the TICK becomes very negative, it means that traders are hitting bids in the broad market: sellers are very aggressive. \n The swings in the NYSE TICK during the day, then, represent relative swings in short-term trader sentiment. The beauty of the measure is that it is assessing what bulls and bears are actually doing in the marketplace; not what they report as their sentiment or what they try to fool others into believing. \n

declare lower;
def upper = no;
input hidecumtick = yes;
input symbol = "$TICK"; #HINT symbol: Default SYMBOL is $TICK (New York Stock Exchange). This can be changed to see the tick values for the Russel 2000, the NASDAQ and many others.
input period = 20;
input smooth = 5;
input lookback = 4;
input filter = 300;
def p = period;
def i = barNumber();
def na = double.nan;
#input usetrend = {"No", default "Yes"};
def usetrend = yes;
rec htick = if IsNaN(high(symbol)) then htick[1] else high("$TICK") ;
rec ltick = if IsNaN(low(symbol)) then ltick[1] else low("$TICK");
rec avgh = if i == 1 then htick else Max(filter, avgh[1] + 2 / (p + 1) * (htick - avgh[1]));
rec avgl = if i == 1 then ltick else Min(-filter, avgl[1] + 2 / (p + 1) * (ltick - avgl[1]));

def hi = high("$TICK");
def lo = low("$TICK");

plot Last = if IsNaN(close(symbol)[-1]) then close(symbol) else double.nan;

plot amean = if IsNaN(close) then na else (avgh + avgl) / 2;
def trendmean = if usetrend AND (htick > avgh OR ltick < avgl) then amean else 0;

def bull = if htick > avgh then htick - avgh  else 0;
def bear = if ltick < avgl then ltick - avgl  else 0;

rec ctick = if i == 1 then 0 else if IsNaN(htick) OR IsNaN(ltick) then ctick[1] else ctick[1] + bull + bear + trendmean; 

def ctickavg = ExpAverage(ctick, smooth);
plot cumtick = if IsNaN(close) then na else ctickavg;
plot nettick = if IsNaN(close) then na else ctick;

plot zero = 0;
cumtick.AssignValueColor(if cumtick > cumtick[lookback] then color.green else color.red);
AssignPriceColor(if !upper then color.current else if cumtick > cumtick[lookback] AND ltick < avgl then color.green else if cumtick > cumtick[lookback] then color.gray else if cumtick < cumtick[lookback] AND htick > avgh then color.red else color.gray);
cumtick.SetLineWeight(2);
def hcumtick=if !hidecumtick then cumtick else na;
def hzero=if !hidecumtick then zero else na;
AddCloud(hcumtick, hzero );
plot buy = if cumtick > cumtick[lookback] AND ltick < avgl then low - tickSize() else if cumtick > cumtick[lookback] then na else if cumtick < cumtick[lookback] AND htick > avgh then na else na;
plot sell = if cumtick > cumtick[lookback] AND ltick < avgl then na else if cumtick > cumtick[lookback] then na else if cumtick < cumtick[lookback] AND htick > avgh then high + tickSize() else na;

plot ahi = if IsNaN(close) then na else avgh;
plot alo = if IsNaN(close) then na else avgl;
plot hib = if hi < 0 then hi else na;
plot lob = if lo > 0 then lo else na;
plot phi = hi;
plot plo = lo;

buy.SetDefaultColor(color.green);
buy.SetPaintingStrategy(paintingStrategy.ARROW_UP);
sell.SetDefaultColor(color.red);
sell.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);

#plot zero=0;
#
# Formatting:
#
hib.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
hib.SetDefaultColor(color.black);
hib.SetLineWeight(5);
lob.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
lob.SetDefaultColor(color.black);
lob.SetLineWeight(5);

Last.SetDefaultColor(Color.white);
Last.SetPaintingStrategy(paintingStrategy.DASHES);
phi.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
phi.AssignValueColor(if hi > ahi then color.dark_GREEN else color.gray);
phi.SetLineWeight(5);
plo.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
plo.AssignValueColor(if lo < alo then color.dark_red else color.gray);
plo.SetLineWeight(5);
zero.SetDefaultColor(color.gray);
zero.SetLineWeight(1);
amean.AssignValueColor(if cumtick > cumtick[lookback] then color.green else color.red);
amean.SetLineWeight(5);
amean.SetStyle(curve.POINTS);
ahi.SetDefaultColor(color.green);
ahi.SetStyle(curve.SHORT_DASH);
alo.SetDefaultColor(color.red);
alo.SetStyle(curve.SHORT_DASH);

#Hiding depending on if upper or lower
phi.setHiding(upper);
plo.setHiding(upper);
zero.setHiding(upper);
last.setHiding(upper);
hib.setHiding(upper);
lob.setHiding(upper);

ahi.setHiding(upper);
alo.setHiding(upper);
cumtick.setHiding(hidecumtick);
nettick.setHiding(hidecumtick);
buy.setHiding(!upper);
sell.setHiding(!upper);

amean.setHiding(upper);

Simple TICK Meter

Code:
##### Simple Tick
##### Made By Signet
##### Version 1.0
##### 11/22/2018
##### Revised 12/19/2018
#https://www.dummies.com/personal-finance/investing/day-trading/how-to-use-the-tick-and-trin-in-day-trading/
##http://tradingsmart.net/indicators/tick-trin-label/
#Hint: TICK and TRIN are two indicators that measure the general sentiment of the market. They can be used both to determine near term market movement. Theses indicators are not well know by traders. TRIN is a calculator, its formula is ((Advancing issues/declining issues) / (advancing volume/declining volume)), it's a contrarian indicator to detect overbought and oversold levels in the market.

#How to day trade with these indicators? TICK value between +200 and -300 indicate a neutral market sentiment. It became bullish when its value became higher than +200 and bearish when it is lower -300. Very bullish when its value is higher than +500 and very bearish when it is lower than -500. Note that when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon. Generally a rising TRIN is bearish and a falling TRIN is bullish. A TRIN value higher than 1 is bearish while bullish when it is below 0.9
declare lower;

plot HighTick = high("$tick");
plot LowTick = low ("$tick");
#plot ZeroLine = 0;
plot up = 800;
plot down = -1000;
plot Noise = 600;
plot Noise2 = -600;
Noise.SetDefaultColor(Color.dark_orange);
Noise2.SetDefaultColor(Color.dark_orange);
up.SetDefaultColor(Color.UPTICK);
down.SetDefaultColor(Color.UPTICK);
HighTick.AssignValueColor(if HighTick >= 800 then Color.UPTICK else Color.DOWNTICK );
HighTick.SetLineWeight(2);
HighTick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
LowTick.AssignValueColor(if LowTick <= -1000 then Color.DOWNTICK else Color.DOWNTICK);
LowTick.SetLineWeight(2);
LowTick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

def Trin = close("$TRIN");
plot Zeroline = 0;
Zeroline.AssignValueColor(if Trin <= 1 then Color.GREEN else if Trin > 1 then Color.dark_Orange else Color.dark_GRAY);
Zeroline.SetLineWeight(2);
Zeroline.SetPaintingStrategy(PaintingStrategy.POINTS);

input show_Trin = yes;
AddLabel(show_Trin, Concat("$TRIN: ", Trin) + if Trin > 1 then " : Sellers Market" else if Trin < 1 then " : Buyers Market" else "", if Trin <= 1 then Color.dark_GREEN else Color.RED);
#A trin of less than 1.00 usually means that a lot of buyers are acting strongly. A trin above 1.00 indicates that the sellers are acting more strongly.
#
def Tick = close("$TICK");
#If the tick is a positive number, that’s good: The market as a whole has a lot of buying interest. A positive tick shows that most people in the market have a positive perspective right now. Extremes show a catalyst event, and this label will stay gray unless an extreme tick is present.
#
def NeutralMarket_Top = +200; 
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def NeutralMarket_Bottom = -300;
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def BullishValue = +500;
#Hint BullishValue: Very bullish when its value is higher than +500.
def BearishValue = -500;
#Hint BullishValue: Very  bearish when it is lower than -500.
def Upper_Xtreme_Limit = 999;
 #Hint Upper_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Lower_Xtreme_Limit = -999;
 #Hint Lower_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Upper_Caution_Limit = 600;
#Hint Upper_Caution_Limit: Causes Label to change color when $TICK reaches this number.   
def Lower_Caution_Limit = -600;
#Hint Lower_Caution_Limit: Causes Label to change color when $TICK reaches this number.
input show_tick = yes;
AddLabel (show_tick, Concat("$TICK: ", Tick) +

if (close < NeutralMarket_Top and close > NeutralMarket_Bottom) then " Neutral Market"  else

if (close > NeutralMarket_Top and close < BullishValue ) then " Bullish Position" else 

if (close > BullishValue and close < Upper_Caution_Limit)   then " Bullish Extreme" else

if close > Upper_Xtreme_Limit then " CAUTION Upper Extreme" else

if (close < NeutralMarket_Bottom and close > BearishValue ) then " Bearish Position" else

if (close < BearishValue and close > Lower_Caution_Limit) then " Bearish Extreme" else

if close < Lower_Xtreme_Limit then "  CAUTION Upper Extreme" else "",

if (close > 0 and close < NeutralMarket_Top ) then Color.DARK_GREEN else

if (close > NeutralMarket_Top and close < BullishValue ) then Color.dark_GREEN else

if (close > BullishValue and close < Upper_Caution_Limit)   then Color.dark_GREEN else

if (close > Upper_Caution_Limit and close < Upper_Xtreme_Limit)   then Color.blue else

if close > Upper_Xtreme_Limit   then Color.RED else

if (close < 0 and close > NeutralMarket_Bottom ) then Color.DARK_RED else

if (close < NeutralMarket_Bottom and close > BearishValue ) then Color.red else

if (close < BearishValue and close > Lower_Caution_Limit)   then Color.DARK_ORANGE else

if (close < Lower_Caution_Limit and close > Lower_Xtreme_Limit) then Color.RED else

if close < Lower_Xtreme_Limit then Color.RED else Color.dark_GRAY);

def A = close(“$UVOL”);
def D = close (“$DVOL”);

def C = close(“$ADVN”);
def E = close (“$DECN”);

#addlabel (yes, If ((C / E) / (A / D)) > 1 then "Trin Decline " else if  ((C / E) / (A / D)) < 1 then "Trin Advance" else "", If  ((C / E) / (A / D)) > 1 then color.red else if  ((C / E) / (A / D)) < 1 then color.green else color.gray);

$TICK and $TRIN Meters with Labels

Code:
##### Smart Tick
##### Made By Signet
##### Version 1.0
##### 11/22/2018
##### Revised 12/19/2018
#https://www.dummies.com/personal-finance/investing/day-trading/how-to-use-the-tick-and-trin-in-day-trading/
##http://tradingsmart.net/indicators/tick-trin-label/
#Hint: TICK and TRIN are two indicators that measure the general sentiment of the market. They can be used both to determine near term market movement. Theses indicators are not well know by traders. TRIN is a calculator, its formula is ((Advancing issues/declining issues) / (advancing volume/declining volume)), it's a contrarian indicator to detect overbought and oversold levels in the market.

#How to day trade with these indicators? TICK value between +200 and -300 indicate a neutral market sentiment. It became bullish when its value became higher than +200 and bearish when it is lower -300. Very bullish when its value is higher than +500 and very bearish when it is lower than -500. Note that when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon. Generally a rising TRIN is bearish and a falling TRIN is bullish. A TRIN value higher than 1 is bearish while bullish when it is below 0.9
#declare hide_on_daily;
Declare lower;
def NeutralMarket_Top = +200; 
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def NeutralMarket_Bottom = -300;
#Hint NeutralMarket_Top: TICK value between +200 and -300 indicate a neutral market sentiment.
def BullishValue = +500;
#Hint BullishValue: Very bullish when its value is higher than +500.
def BearishValue = -500;
#Hint BullishValue: Very  bearish when it is lower than -500.
def Upper_Xtreme_Limit = 999;
 #Hint Upper_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Lower_Xtreme_Limit = -999;
 #Hint Lower_Xtreme_Limit: when TICK is higher than +1000 or lower than -1000, then a reversal of the market will probably happen soon.
def Upper_Caution_Limit = 600;
#Hint Upper_Caution_Limit: Causes Label to change color when $TICK reaches this number.   
def Lower_Caution_Limit = -600;
#Hint Lower_Caution_Limit: Causes Label to change color when $TICK reaches this number.
  
Plot Tick = close("$TICK");
Plot Trin = close("$TRIN");
Trin.AssignValueColor(if Trin < 1 THEN COLOR.Uptick ELSE COLOR.Downtick);

plot Upper_Xtreme = if tick > Upper_Xtreme_Limit then Upper_Xtreme_Limit else double.nan;
Upper_Xtreme.AssignValueColor(COLOR.white);;
Upper_Xtreme.AssignValueColor(COLOR.white);

plot Upper_Limit = if tick > Upper_Caution_Limit then Upper_Caution_Limit else double.nan;
Upper_Limit.AssignValueColor(COLOR.RED);

plot Bullishbottom = NeutralMarket_Top;
Bullishbottom.AssignValueColor(COLOR.Green);

plot BullishTop = BullishValue;
BullishTop.AssignValueColor(COLOR.dark_Green);

plot BearishBottom = NeutralMarket_Bottom;
Bearishbottom.AssignValueColor(COLOR.Red);

plot BearishTop = BearishValue;
BearishTop.AssignValueColor(COLOR.dark_Red);

plot Lower_Limit = if tick < Lower_Caution_Limit then Lower_Caution_Limit else double.nan ;
Lower_Limit.AssignValueColor(COLOR.RED);

plot Lower_Xtreme = if tick < lower_Xtreme_Limit then lower_Xtreme_Limit else double.nan ;
Lower_Xtreme.AssignValueColor(COLOR.white);

Tick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Tick.DefineColor("Positive", Color.UPTICK);
Tick.DefineColor("Negative", Color.DOWNTICK);
tick.definecolor("Extreme", color.cyan);
tick.definecolor("neutral", color.gray);
tick.definecolor("bullish",color.blue);
tick.definecolor("bearish",color.dark_orange);
Tick.AssignValueColor(
if (Tick >= neutralMarket_bottom and tick <= neutralMarket_top)  then Tick.color("neutral") else
if (Tick > NeutralMarket_Top and tick < Upper_Caution_Limit) then Tick.color("Positive") else
if (Tick < NeutralMarket_bottom and tick > Lower_Caution_Limit) then Tick.color("Negative") else
if (Tick > Upper_Caution_Limit and tick < Upper_Xtreme_Limit)  then  Tick.color("Bullish")  else
if  (Tick < Lower_Caution_Limit and tick > Lower_Xtreme_Limit)  then  Tick.color("bearish")  else
if tick > Upper_Xtreme_Limit or tick < Lower_Xtreme_Limit then Tick.color("Extreme")
else Tick.color("neutral"));

#A trin of less than 1.00 usually means that a lot of buyers are acting strongly. A trin above 1.00 indicates that the sellers are acting more strongly.
INPUT SHOW_trin = YES;
AddLabel(SHOW_trin, Concat("$TRIN: ", Trin) + if trin > 1 then " : Sellers Market" else if trin < 1 then " : Buyers Market" else "", IF Trin <= 1 THEN COLOR.GREEN ELSE Color.Red);

#If the tick is a positive number, that’s good: The market as a whole has a lot of buying interest. A positive tick shows that most people in the market have a positive perspective right now. Extremes show a catalyst event, and this label will stay gray unless an extreme tick is present.
AddLabel (yes, Concat("$TICK: ", Tick) + if
        (Close < NeutralMarket_Top and
    Close > NeutralMarket_Bottom) then
" Neutral Market"  else if
        (Close > NeutralMarket_Top and
    Close < BullishValue ) then
" Bullish Market" else if
        (Close > BullishValue and
    Close < Upper_Caution_Limit) then
" Bullish Extreme" else if
    Close > Upper_Xtreme_Limit then
" CAUTION Upper Extreme" else if
        (Close < NeutralMarket_Bottom and
    Close > BearishValue ) then
" Bearish Position" else if
        (Close < BearishValue and
    Close > Lower_Caution_Limit) then
" Bearish Extreme" else if
    Close < Lower_Xtreme_Limit then
" CAUTION Upper Extreme" else "", if
        (Close > 0 and
    Close < NeutralMarket_Top ) then
Color.Dark_Green else if
        (Close > NeutralMarket_Top and
    Close < BullishValue ) then
Color.Green else if
        (Close > BullishValue and
    Close < Upper_Caution_Limit) then
Color.Light_Green else if
        (Close > Upper_Caution_Limit and
    Close < Upper_Xtreme_Limit) then
Color.Cyan else if
    Close > Upper_Xtreme_Limit then
Color.red else if
        (Close < 0 and
    Close > NeutralMarket_Bottom ) then
Color.Dark_red else if
        (Close < NeutralMarket_Bottom and
    Close > BearishValue ) then
Color.pink else if
        (Close < BearishValue and
    Close > Lower_Caution_Limit) then
Color.dark_Orange else if
        (Close < Lower_Caution_Limit and
    Close > Lower_Xtreme_Limit) then
Color.red else if
    Close < Lower_Xtreme_Limit then
Color.red else Color.Gray);
Learn more about the TICK index here.
 
Top