Market Internals Dual-Mode (NYSE / NASDAQ) For ThinkOrSwim

cando13579

Member
VIP
This tool provides a consolidated, real-time view of market breadth and short-term sentiment by visualizing the core U.S. market internals: TICK, Advance/Decline (ADD), Up/Down Volume (VOLD), TRIN, and the Volatility Index (VIX/VXN). It is designed to help traders identify trend conditions, momentum shifts, and exhaustion points with clarity and speed.
T5d8MWd.png

---------How It Works
TICK Histogram shows the number of stocks trading on an uptick versus a downtick.
Green = broad buying,​
Red = broad selling,​
Magenta = extreme internal pressure (±900+).

ADD and VOLD Bands measure market-wide breadth and volume flow.
Green = strong trend support,​
Red = strong trend pressure,​
Gray = neutral or mixed conditions.​

TICK Trend Line (EMA) helps identify short-term strength or weakness.

Centerline Balance Dot highlights whether internals are aligned with directional trend (white) or in a balanced environment (yellow).

Vertical Line Signals (Converted from Bubbles)
----Vertical lines:
Magenta Lines – Extreme TICK events Indicate exhaustion, pivot zones, or trend continuation pressure.​
Cyan Lines – Zero-cross TICK shifts​

Show transitions in short-term buying/selling dominance.
Pink/Green Lines – Divergences​
Pink: Price makes a higher high while TICK weakens (bearish divergence).​
Green: Price makes a lower low while TICK strengthens (bullish divergence).​
These help anticipate reversals or momentum failure.

------How to Use It
Trend Confirmation
ADD and VOLD green → Trend moves have internal support.​
Both red → Downside pressure is broad and persistent.​

Identify Reversals / Exhaustion
Magenta extreme-TICK lines often signal exhaustion or strong continuation bursts.​
Use alongside price for timing entries or exits.

Momentum Shift Timing
Cyan zero-cross lines help identify rotation from selling → buying or vice-versa.​

Reversal Detection
Pink/Green divergence lines are early signals that internal momentum is changing before price reacts.​

--------Best Time Frames
The indicator is optimized for intraday trading on:
5-minute (best balance for clarity and signal quality)​
2-minute (faster scalping, more sensitivity)​
1-minute (high detail, best for active futures traders)​

It can be used on higher time frames, but the internals themselves update tick-by-tick, so intraday timeframes provide the most actionable value.

Code:
# ==============================================
# Market Internals Dual-Mode (NYSE / NASDAQ)
# ==============================================
declare lower;

# ------------------- Inputs -------------------
input market = {default "NYSE", "NASDAQ"};

input tickSmooth       = 8;     # TICK EMA smoothing
input tickNormalThresh = 500;   # Histogram normal threshold
input tickExtreme      = 900;   # Extreme tick level for diamonds
input balanceThreshold = 50;    # Centerline balanced threshold (percent)
input addThresholdPct  = 0.10;  # ADD band color threshold
input voldThresholdPct = 0.10;  # VOLD band color threshold

input showADD          = yes;
input showVOLD         = yes;
input showTRIN         = no;
input showMetrics      = yes;
input showDivergence   = yes;
input showExtremeAlerts = yes;
input RTHonly          = no;

# ------------------- Session Filter -------------------
def RTH = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) >= 0;
def plotFlag = if RTHonly then RTH else 1;

# ------------------- Internals (Close Values) -------------------
# NYSE Symbols
def NY_ADV  = close("$ADVN");
def NY_DEC  = close("$DECN");
def NY_UVOL = close("$UVOL");
def NY_DVOL = close("$DVOL");
def NY_TRIN = close("$TRIN");
def NY_VIX  = close("$VIX");

# NASDAQ Symbols
def NQ_ADV  = close("$ADVNQ");
def NQ_DEC  = close("$DECNQ");
def NQ_UVOL = close("$UVOLNQ");
def NQ_DVOL = close("$DVOLNQ");
def NQ_TRIN = close("$TRINQ");
def NQ_VXN  = close("$VXN");

# ------------------- Dual-Mode Selection -------------------
def ADV  = if market == market."NASDAQ" then NQ_ADV  else NY_ADV;
def DEC  = if market == market."NASDAQ" then NQ_DEC  else NY_DEC;
def UVOL = if market == market."NASDAQ" then NQ_UVOL else NY_UVOL;
def DVOL = if market == market."NASDAQ" then NQ_DVOL else NY_DVOL;
def TRIN = if market == market."NASDAQ" then NQ_TRIN else NY_TRIN;
def VOLX = if market == market."NASDAQ" then NQ_VXN  else NY_VIX;

# ------------------- Derived Internals -------------------
def ADD     = ADV - DEC;
def ADDtot  = ADV + DEC;
def VOLD    = UVOL - DVOL;
def VOLDtot = UVOL + DVOL;

def ADDratio  = if ADDtot == 0 then 0 else ADD / ADDtot;
def VOLDratio = if VOLDtot == 0 then 0 else VOLD / VOLDtot;

# ------------------- TICK Histogram & Trend -------------------
def tick = close("$TICK");

plot tickHist = if plotFlag then tick else Double.NaN;
tickHist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
tickHist.SetLineWeight(3);
tickHist.AssignValueColor(
    if AbsValue(tick) >= tickExtreme then Color.MAGENTA
    else if tick > tickNormalThresh then Color.GREEN
    else if tick > 0 then Color.DARK_GREEN
    else if tick < -tickNormalThresh then Color.RED
    else Color.DARK_RED
);

plot tickTrend = if plotFlag then ExpAverage(tick, tickSmooth) else Double.NaN;
tickTrend.SetDefaultColor(Color.WHITE);
tickTrend.SetLineWeight(2);
tickTrend.SetStyle(Curve.LONG_DASH);

# ------------------- Centerline & Balance Dot -------------------
plot zeroLine = if plotFlag then 0 else Double.NaN;
zeroLine.SetDefaultColor(Color.GRAY);
zeroLine.SetLineWeight(1);

def isBalanced = AbsValue(ADDratio*100) < balanceThreshold and AbsValue(VOLDratio*100) < balanceThreshold;

plot centerDot = if plotFlag and !isBalanced then 0 else Double.NaN;
centerDot.SetPaintingStrategy(PaintingStrategy.POINTS);
centerDot.SetLineWeight(3);
centerDot.AssignValueColor(if isBalanced then Color.YELLOW else Color.WHITE);

# ------------------- ADD Band -------------------
plot ADDpct = if plotFlag and showADD then 100*ADDratio else Double.NaN;
ADDpct.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ADDpct.SetLineWeight(3);
ADDpct.AssignValueColor(
    if ADDratio >= addThresholdPct then Color.GREEN
    else if ADDratio <= -addThresholdPct then Color.RED
    else Color.DARK_GRAY
);

# ------------------- VOLD Band -------------------
plot VOLDpct = if plotFlag and showVOLD then 100*VOLDratio else Double.NaN;
VOLDpct.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VOLDpct.SetLineWeight(3);
VOLDpct.AssignValueColor(
    if VOLDratio >= voldThresholdPct then Color.GREEN
    else if VOLDratio <= -voldThresholdPct then Color.RED
    else Color.DARK_GRAY
);

# ------------------- Optional TRIN -------------------
plot TRINplot = if plotFlag and showTRIN then TRIN else Double.NaN;
TRINplot.SetDefaultColor(Color.ORANGE);
TRINplot.SetLineWeight(1);

# ============================================================
#                >>> VERTICAL LINE CONVERSION <<<
# ============================================================

# ------------------- Extreme TICK Vertical Lines -------------------
def extremeHigh = tick > tickExtreme and tick[1] <= tickExtreme;
def extremeLow  = tick < -tickExtreme and tick[1] >= -tickExtreme;

AddVerticalLine(extremeHigh and showExtremeAlerts, "▲ EXT High", Color.MAGENTA);
AddVerticalLine(extremeLow  and showExtremeAlerts, "▼ EXT Low", Color.MAGENTA);

# ------------------- Zero Cross Vertical Lines -------------------
def crossUpZero = tick > 0 and tick[1] <= 0;
def crossDnZero = tick < 0 and tick[1] >= 0;

AddVerticalLine(crossUpZero, "+ ZC", Color.CYAN);
AddVerticalLine(crossDnZero, "- ZC", Color.CYAN);

# ------------------- Divergence Vertical Lines -------------------
def priceHH = high > high[1] and high > high[2];
def tickLH  = tick < tick[1] and tick[1] > tick[2];
def bearishDiv = showDivergence and priceHH and tickLH;

def priceLL = low < low[1] and low < low[2];
def tickHL  = tick > tick[1] and tick[1] < tick[2];
def bullishDiv = showDivergence and priceLL and tickHL;

AddVerticalLine(bearishDiv, "Div ↓", Color.PINK);
AddVerticalLine(bullishDiv, "Div ↑", Color.LIGHT_GREEN);

# ------------------- Extreme Signal Point Plot -------------------
plot ExtremeSignal = if (extremeHigh or extremeLow) and showExtremeAlerts
                     then tick
                     else Double.NaN;
ExtremeSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
ExtremeSignal.SetLineWeight(3);
ExtremeSignal.SetDefaultColor(Color.MAGENTA);

# ------------------- Metrics Table -------------------
def metricADD  = Round(ADD,0);
def metricVOLD = Round(VOLD,0);
def metricTick = Round(tick,0);
def metricTRIN = Round(TRIN,2);
def metricVolX = Round(VOLX,2);

AddLabel(showMetrics, "Market Internals [" +
    (if market == market."NASDAQ" then "NASDAQ" else "NYSE") + "]",
    Color.GRAY);

AddLabel(showMetrics,
    " TICK: " + metricTick +
    "  |  ADD: " + metricADD + " (" + AsPercent(ADDratio) + ")" +
    "  |  VOLD: " + metricVOLD + " (" + AsPercent(VOLDratio) + ")",
    Color.DARK_GRAY
);

AddLabel(showMetrics,
    " TRIN: " + metricTRIN +
    "  |  VolIndex: " + metricVolX,
    Color.DARK_GRAY
);

# ------------------- Hide Titles -------------------
tickHist.HideTitle();
tickTrend.HideTitle();
zeroLine.HideTitle();
ADDpct.HideTitle();
VOLDpct.HideTitle();
TRINplot.HideTitle();

# ==============================================
# END OF SCRIPT
# ==============================================
;
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1528 Online
Create Post

Similar threads

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.
Back
Top