Repaints HTF MAD Volatility Confluence Dashboard For ThinkOrSwim

Repaints

antwerks

Well-known member
VIP
VIP Enthusiast
MAD HTF CONFLUENCE DASHBOARD
from original script:
https://usethinkscript.com/threads/mad-volatility-trail-backquant-for-thinkorswim.22663/#post-164103

mod note:
This script acts as a Multi-Timeframe Trend State Matrix built on robust statistics from the original script. It acts purely as an information compression tool: taking complex volatility-adjusted trailing calculations across four timeframes (5M, 15M, 30M, 1H) and outputting them into four clean, real-time dashboard labels.

rPerzN4.png

Code:
# MAD HTF LABELS ONLY - SEPARATE STUDY
# Add as a NEW study alongside the ORIGINAL MAD_Volatility_Trail.
# Remove the previous dashboard add-on from the original study first.
# Use on a 5-minute time chart. Match inputs to your original MAD study.
# Green = bullish. Red = bearish. Matching colors = confluence.
# No signal filtering, arrows, orders, clouds, or candle coloring.
# Default LIVE labels can change before the candle closes.
# Uses close as source and preserves the original rolling-deviation formula.

declare upper;

input showLabels = yes;
input completedBarsOnly = no;
input madLen = 45;
input madScale = 1.4655;
input factor = 1.15;
input useAtrFloor = no;
input atrLen = 14;
input atrFloorMult = 0.2;
input useSlopeConfirm = no;
input slopeLen = 2;

script MADLabelState {
    input agg = AggregationPeriod.FIVE_MIN;
    input n = 45;
    input scale = 1.4655;
    input mult = 1.15;
    input floorOn = no;
    input atrN = 14;
    input floorMult = 0.2;
    input slopeOn = no;
    input slopeN = 2;
    input closedOnly = no;

    def c = close(period = agg);
    def h = high(period = agg);
    def l = low(period = agg);
    def m = Median(c, n);
    def dev = Median(AbsValue(c - m), n);
    def atr = WildersAverage(TrueRange(h, c, l), atrN);
    def width = if floorOn
                then Max(dev * scale * mult, atr * floorMult)
                else dev * scale * mult;
    def upper = m + width;
    def lower = m - width;

    def lowerTrail = CompoundValue(1,
        if !IsNaN(lowerTrail[1]) and c[1] > lowerTrail[1]
        then Max(lower, lowerTrail[1]) else lower, lower);

    def upperTrail = CompoundValue(1,
        if !IsNaN(upperTrail[1]) and c[1] < upperTrail[1]
        then Min(upper, upperTrail[1]) else upper, upper);

    def bullSlope = !slopeOn or m > m[slopeN];
    def bearSlope = !slopeOn or m < m[slopeN];

    def direction = CompoundValue(1,
        if direction[1] == 0 and !IsNaN(m) then
            if c >= m then 1 else -1
        else if c > upperTrail and direction[1] != 1 and bullSlope then 1
        else if c < lowerTrail and direction[1] != -1 and bearSlope then -1
        else direction[1], 0);

    def valid = !IsNaN(width) and !IsNaN(c);
    plot State = if closedOnly
                 then (if valid[1] then direction[1] else 0)
                 else (if valid then direction else 0);
}

def s5 = MADLabelState(
    agg = AggregationPeriod.FIVE_MIN,
    n = madLen, scale = madScale, mult = factor,
    floorOn = useAtrFloor, atrN = atrLen, floorMult = atrFloorMult,
    slopeOn = useSlopeConfirm, slopeN = slopeLen,
    closedOnly = completedBarsOnly).State;

def s15 = MADLabelState(
    agg = AggregationPeriod.FIFTEEN_MIN,
    n = madLen, scale = madScale, mult = factor,
    floorOn = useAtrFloor, atrN = atrLen, floorMult = atrFloorMult,
    slopeOn = useSlopeConfirm, slopeN = slopeLen,
    closedOnly = completedBarsOnly).State;

def s30 = MADLabelState(
    agg = AggregationPeriod.THIRTY_MIN,
    n = madLen, scale = madScale, mult = factor,
    floorOn = useAtrFloor, atrN = atrLen, floorMult = atrFloorMult,
    slopeOn = useSlopeConfirm, slopeN = slopeLen,
    closedOnly = completedBarsOnly).State;

def s60 = MADLabelState(
    agg = AggregationPeriod.HOUR,
    n = madLen, scale = madScale, mult = factor,
    floorOn = useAtrFloor, atrN = atrLen, floorMult = atrFloorMult,
    slopeOn = useSlopeConfirm, slopeN = slopeLen,
    closedOnly = completedBarsOnly).State;

AddLabel(showLabels,
    "5M: " + (if s5 == 1 then "BULL" else if s5 == -1 then "BEAR" else "LOADING"),
    if s5 == 1 then Color.GREEN else if s5 == -1 then Color.RED else Color.GRAY);

AddLabel(showLabels,
    "15M: " + (if s15 == 1 then "BULL" else if s15 == -1 then "BEAR" else "LOADING"),
    if s15 == 1 then Color.GREEN else if s15 == -1 then Color.RED else Color.GRAY);

AddLabel(showLabels,
    "30M: " + (if s30 == 1 then "BULL" else if s30 == -1 then "BEAR" else "LOADING"),
    if s30 == 1 then Color.GREEN else if s30 == -1 then Color.RED else Color.GRAY);

AddLabel(showLabels,
    "1H: " + (if s60 == 1 then "BULL" else if s60 == -1 then "BEAR" else "LOADING"),
    if s60 == 1 then Color.GREEN else if s60 == -1 then Color.RED else Color.GRAY);
 
Last edited by a moderator:

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

Using in conjunction with the VIPMagic Supertrend helps with the late entries - I found that 14 as the lookback is a better play for the 5 minutes chart.

45 is not critical. It is an adjustable sensitivity setting, not a proven optimum. Changing it affects both the median price and the deviation calculation that sets the trail’s distance.

LookbackTypical effectMain pitfall
Shorter: 14–21Reacts faster to recent price changesMore false reversals and repeated flips in consolidation
Middle: 30–34More responsive than 45, with some smoothingStill a compromise between earlier signals and noise
Current: 45Uses a broader price historyCan recognize reversals later and give back more profit
Longer: 60+Emphasizes longer-lasting trendsCan remain bullish or bearish after the immediate opportunity has changed

Those are tendencies—not guarantees. Because the lookback changes both the centerline and band width, shortening it does not make every signal earlier or every stop tighter.

The timeframe matters- The same number represents very different amounts of market history:​


Chart21 bars45 bars
5-minute1h 45m3h 45m
15-minute5h 15m11h 15m
30-minute10h 30m22h 30m
1-hour21 hours45 hours

These are accumulated bar durations, not necessarily consecutive clock hours. The nested deviation calculation also reaches farther back than the median alone.
 
Nicely done — one of the best multi‑timeframe traffic‑light trend dashboards I’ve seen. Clean, stable, and far more robust than the typical EMA‑MTF versions.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
2896 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