$TICK Charts, Divergences, Labels for ThinkorSwim

Trader_Vic

New member
VIP
Hi Guys! I joined this site a few months ago and this is such an amazing site for traders and coders to come together. I would need some help from someone who can write a code with this Strategy. I trade /ES on 5 Min & 1 Min Chart with $TICK as the bottom indicator. I usually draw lines every time there is a divergence or a flag formation for the TICKS to go Long or Short. I would need help from coders on this site to help me with the CODE.

vP6e5uS.png
 
Last edited by a moderator:
  • Like
Reactions: GOS

HigherLow

New member
I'd also be very interested in seeing this. I believe it already exists as a tradestation indicator which plots a dot at a price pivot when $tick confirms with its own high vs prior price pivots.
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
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
QSviJjg.png


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);
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
I found this, not sure if it's what you guys are looking for:

Code:
# $TICK Oscillator with Divergence
# Mobius
# V01.03.2020

declare lower;

input length = 5;
input AvgType = AverageType.HULL;

addLabel(1, "Green Line sloping up or red sloping down is divergence", color.white);
def o = open("$TICK");
def h = high("$TICK");
def l = low("$TICK");
def c = close("$TICK");
def x = BarNumber();
def nan = Double.NaN;
AddChart(h, l, c, o, ChartType.CANDLE, Color.YELLOW);
AddChart(h, l, o, c, ChartType.CANDLE, Color.CYAN);
def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
          GetTime() <= RegularTradingEnd(GetYYYYMMDD());
plot "0" = if !RTH then Double.NaN else 0;
     "0".SetDefaultColor(Color.MAGENTA);
     "0".HideBubble();
     "0".HideTitle();
plot avg = MovingAverage(AvgType, c, length);
     avg.AssignValueColor(if avg < 0
                          then color.red
                          else color.green);
     avg.HideBubble();
     avg.HideTitle();
addCloud(0, avg, color.red, color.green);
plot upArrow = if avg crosses above 0
               then l
               else double.nan;
     upArrow.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     upArrow.SetDefaultColor(Color.Green);
     upArrow.SetLineWeight(3);
     upArrow.HideBubble();
     upArrow.HideTitle();
plot dnArrow = if avg crosses below 0
               then h
               else double.nan;
     dnArrow.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
     dnArrow.SetDefaultColor(Color.Red);
     dnArrow.SetLineWeight(3);
     dnArrow.HideBubble();
     dnArrow.HideTitle();
def hh = if avg crosses above 0
         then h
         else if avg > 0 and h > hh[1]
         then h
         else hh[1];
def xh = if h == hh
         then x
         else xh[1];
plot hp = if x == highestAll(xh)
          then hh
          else nan;
     hp.SetStyle(Curve.Points);
     hp.SetDefaultColor(Color.red);
     hp.SetLineWeight(3);
     hp.HideBubble();
     hp.HideTitle();
def xh1 = if !isNaN(dnArrow)
          then getValue(xh, 2)
          else xh1[1];
plot hp1 = if x == highestAll(xh1)
           then h
           else nan;
     hp1.SetStyle(Curve.Points);
     hp1.SetDefaultColor(Color.red);
     hp1.SetLineWeight(3);
     hp1.HideBubble();
     hp1.HideTitle();
plot hd = if x == highestAll(xh1)
          then h
          else if x == highestAll(xh)
          then h
          else nan;
     hd.EnableApproximation();
     hd.SetDefaultColor(Color.red);
     hd.HideBubble();
     hd.HideTitle();
def ll = if avg crosses below 0
         then l
         else if avg < 0 and l < ll[1]
         then l
         else ll[1];
def xl = if l == ll
         then x
         else xl[1];
plot lp = if x == highestAll(xl)
          then ll
          else nan;
     lp.SetStyle(Curve.Points);
     lp.SetDefaultColor(Color.green);
     lp.SetLineWeight(3);
     lp.HideBubble();
     lp.HideTitle();
def xl1 = if !isNaN(dnArrow)
          then xl[1]
          else xl1[1];
plot lp1 = if x == highestAll(xl1)
           then l
           else nan;
     lp1.SetStyle(Curve.Points);
     lp1.SetDefaultColor(Color.green);
     lp1.SetLineWeight(3);
     lp1.HideBubble();
     lp1.HideTitle();
plot ld = if x == highestAll(xl1)
          then l
          else if x == highestAll(xl)
          then l
          else nan;
     ld.EnableApproximation();
     ld.SetDefaultColor(Color.green);
     ld.HideBubble();
     ld.HideTitle();
# End Code TICK Oscillator with Divergence


# AI Adds

def lastHP = if x == highestAll(xh)
then xh else lastHP[1];
def lastHP1 =  if x == highestAll(xh1)
then xh1 else lastHP[1];
def lastLP = if x == highestAll(xl)
then xl else lastLP[1];
def lastLP1 =  if x == highestAll(xl1)
then xl1 else lastLP1[1];

Addlabel(lastHP1<lastHP,"Divergent",color.red);
Addlabel(lastLP1>lastLP,"Divergent",color.green);
 

HigherLow

New member
Wow! this is great! Thanks @BenTen !!!. I'm not the original poster but this is what I'm looking for. Can't speak for Trader_Vic. I really appreciate you finding this and for Mobius creating this.
 

Zlotko

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

Active member
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:
X2pPKNV.png

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]il.com
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:

sunnyr

New member
GgduCmU.png


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:

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
 

Miket

Member
Can anyone recommend a tick divergence indicator that you've had luck with. I trade ES and looking to improve my entries.
 

3_Buddah_Bottom

New member
VIP
Can you add an alert for everytime it crosses 1000 or -1000 please. i know that i can manually input the alerts, but onces it goes off, i have to reset if i remember to. or reset it everyday.
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
@3_Buddah_Bottom Add this to the bottom of your existing script:

Code:
def condition1 = tick > ob2;
def condition2 = tick < os2;

# Alerts
Alert(condition1, " ", Alert.Bar, Sound.Chimes);
Alert(condition2, " ", Alert.Bar, Sound.Bell);
 

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top