Indicator · Pine Script v6 · Own pane

MTF Structure Bias [WavesUnchained]

by casoon

MTF Structure Bias classifies market structure across four timeframes by comparing rolling highest highs and lowest lows N bars ago.

View on GitHub

GitHub stars9on the repository
Pine versionv6current
Lines of code132
Settings6inputs
LicenceMIT
Last update3 days ago27 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

132 lines of Pine Script v6 from indicators/market_structure/mtf_structure_bias/mtf_structure_bias.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

mtf_structure_bias.pine
//@version=6
// ============================================================================
// MTF Structure Bias [WavesUnchained]
// Version: 1.1.3
// Author: WavesUnchained
// Build: 2026-10-02 00:00:00
// ============================================================================
// Classifies market structure across four timeframes by comparing the rolling
// highest high and lowest low against their values N bars ago — no
// oscillators, pure price geometry.
// Each TF: both rising = bullish (+1), both falling = bearish (−1), else mixed (0).
//
// Features:
//   ✓ Structural state per TF: Bull (HH+HL), Bear (LH+LL), Mixed
//   ✓ Weighted confluence score −100 to +100 (higher TFs weighted more)
//   ✓ Three configurable higher timeframes (defaults: 60m, 240m, Daily)
//   ✓ Configurable structure lookback period
//   ✓ Dashboard: per-TF state + weighted score
//   ✓ Alerts on bull/bear zone entry (score crossing ±60)
//
// ============================================================================

indicator("MTF Structure Bias [WavesUnchained]", "MTF Struct [WU]", format=format.price, precision=2, overlay=false)

// ─── Inputs ───────────────────────────────────────────────────────────────────

grTF     = "Timeframes"
tf2      = input.timeframe("60",  "HTF 1", group=grTF)
tf3      = input.timeframe("240", "HTF 2", group=grTF)
tf4      = input.timeframe("D",   "HTF 3", group=grTF)

grStr    = "Structure"
pivLen   = input.int(20, "Lookback Period", minval=5, maxval=100, group=grStr,
     tooltip="Bars used to define the recent highest high and lowest low. Also the comparison offset (HH now vs HH pivLen bars ago).")

grD      = "Display"
showDash = input.bool(true, "Show Dashboard", group=grD)

// ─── Structural state ─────────────────────────────────────────────────────────
// +1 = bullish (HH+HL), −1 = bearish (LH+LL), 0 = mixed

f_struct(len) =>
    hh   = ta.highest(high, len)
    ll   = ta.lowest(low,   len)
    hhUp = hh > hh[len]
    llUp = ll  > ll[len]
    hhUp and llUp ? 1 : not hhUp and not llUp ? -1 : 0

// ─── Per-TF state ─────────────────────────────────────────────────────────────

s1 = f_struct(pivLen)
s2 = request.security(syminfo.tickerid, tf2, f_struct(pivLen), lookahead=barmerge.lookahead_off)
s3 = request.security(syminfo.tickerid, tf3, f_struct(pivLen), lookahead=barmerge.lookahead_off)
s4 = request.security(syminfo.tickerid, tf4, f_struct(pivLen), lookahead=barmerge.lookahead_off)

// ─── Weighted score ───────────────────────────────────────────────────────────
// Weights: current=0.5, HTF1=1.0, HTF2=1.5, HTF3=2.0 → total 5.0

score = (s1 * 0.5 + s2 * 1.0 + s3 * 1.5 + s4 * 2.0) / 5.0 * 100.0

// ─── Colors & helpers ─────────────────────────────────────────────────────────

bullC = color.new(#00c853, 0)
bearC = color.new(#d50000, 0)
neutC = color.new(color.gray, 30)

scoreColor = score > 20 ? bullC : score < -20 ? bearC : neutC

f_stateStr(s) =>
    s == 1 ? "Bull ▲" : s == -1 ? "Bear ▼" : "Mixed ─"
f_stateColor(s) =>
    s == 1 ? bullC : s == -1 ? bearC : neutC

// ─── Plots ────────────────────────────────────────────────────────────────────

hline(0,   "Zero", color=color.new(color.gray, 50))
hline(60,  "Bull", color=color.new(#00c853, 60), linestyle=hline.style_dotted)
hline(-60, "Bear", color=color.new(#d50000, 60), linestyle=hline.style_dotted)

plot(score, "Structure Score", color=scoreColor, linewidth=2)

// ─── Dashboard ────────────────────────────────────────────────────────────────

color tc = color.new(color.gray, 20)
color hd = color.new(color.gray, 90)

var table t = table.new(position.top_right, 3, 7,
     bgcolor=color.new(color.white, 5),
     border_color=color.new(color.gray, 60), border_width=1,
     frame_color=color.new(color.gray, 40), frame_width=1)

if showDash and barstate.islast
    table.cell(t, 0, 0, "MTF Structure",   text_color=tc, bgcolor=hd, text_size=size.small)
    table.cell(t, 1, 0, "State",           text_color=tc, bgcolor=hd, text_size=size.small)
    table.cell(t, 2, 0, "Wt.",             text_color=tc, bgcolor=hd, text_size=size.small)

    table.cell(t, 0, 1, timeframe.period,  text_color=tc,               text_size=size.small)
    table.cell(t, 1, 1, f_stateStr(s1),   text_color=f_stateColor(s1), text_size=size.small)
    table.cell(t, 2, 1, "0.5×",           text_color=tc,               text_size=size.small)

    table.cell(t, 0, 2, tf2,              text_color=tc,               text_size=size.small)
    table.cell(t, 1, 2, f_stateStr(s2),   text_color=f_stateColor(s2), text_size=size.small)
    table.cell(t, 2, 2, "1.0×",           text_color=tc,               text_size=size.small)

    table.cell(t, 0, 3, tf3,              text_color=tc,               text_size=size.small)
    table.cell(t, 1, 3, f_stateStr(s3),   text_color=f_stateColor(s3), text_size=size.small)
    table.cell(t, 2, 3, "1.5×",           text_color=tc,               text_size=size.small)

    table.cell(t, 0, 4, tf4,              text_color=tc,               text_size=size.small)
    table.cell(t, 1, 4, f_stateStr(s4),   text_color=f_stateColor(s4), text_size=size.small)
    table.cell(t, 2, 4, "2.0×",           text_color=tc,               text_size=size.small)

    table.cell(t, 0, 5, "", bgcolor=color.new(color.gray, 80))
    table.cell(t, 1, 5, "", bgcolor=color.new(color.gray, 80))
    table.cell(t, 2, 5, "", bgcolor=color.new(color.gray, 80))

    scoreStr = str.tostring(math.round(score)) + " / 100"
    scoreC   = score > 20 ? bullC : score < -20 ? bearC : tc
    table.cell(t, 0, 6, "Score",           text_color=tc,     text_size=size.small)
    table.cell(t, 1, 6, scoreStr,          text_color=scoreC, text_size=size.small)
    table.cell(t, 2, 6, "",               text_color=tc,     text_size=size.small)

// ─── Alerts ───────────────────────────────────────────────────────────────────

bool bullZoneEntry = ta.crossover(score, 60)
bool bearZoneEntry = ta.crossunder(score, -60)

bool alertsOnBarClose = input.bool(true, "Alerts only on bar close (confirmed)", group="Alerts")
bool alertOk = not alertsOnBarClose or barstate.isconfirmed

alertcondition(alertOk and (bullZoneEntry), "Bull Zone Entry", "MSB · Bull Zone Entry · {{ticker}} {{interval}}")
alertcondition(alertOk and (bearZoneEntry), "Bear Zone Entry", "MSB · Bear Zone Entry · {{ticker}} {{interval}}")

Overview

Each timeframe receives a bullish (+1), bearish (-1), or mixed (0) state based on whether highs and lows are rising or falling. A weighted confluence score from -100 to +100 combines these states, giving higher weight to higher timeframes. The script plots the score in a separate pane and displays a dashboard with per-timeframe states. Users configure three higher timeframes, the lookback period for structure, and dashboard visibility. Alerts trigger on score crossing bullish or bearish zones of 60.

Details

Published by

casoon on GitHub

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pine-scriptpinescripttechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
HTF 1timeframe60tf2
HTF 2timeframe240tf3
HTF 3timeframeDtf4
Lookback Periodint20pivLen
Show DashboardbooltrueshowDash
Alerts only on bar close (confirmed)booltruealertsOnBarClose
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

FVG Screener TW

by gplee789-afk
1 stars

This indicator scans up to 40 symbols across a user-defined timeframe to identify Smart Money Concepts Fair Value Gaps, Inversion FVGs, displacement bars, and internal order blocks. It calculates a weighted quality score for each gap, monitors price proximity,

Indicator v6 SMC / ICT / price actionScreeners & dashboards
Updated 4 weeks ago · MPL-2.0 GitHub repository of FVG Screener TW
575 stars

This overlay indicator scans a pasted list of symbols for ICT liquidity sweep patterns using prior swing sweeps. The screening method looks back one, two, or three swings and can list long and short signals in a results table with adjustable rows, position, an

Indicator v5 SMC / ICT / price actionScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Sweep Pattern Scanner

Golden Bullet Strategy

by TradersPost
228 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy
56 stars

This indicator identifies fractal-based pivot highs and lows to map out market structure directly on the price chart. It detects bullish and bearish structure breaks, automatically labeling Break of Structure (BOS) and Change of Character (ChoCH) events when p

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · None stated GitHub repository of Market Structure (Fractal)
53 stars

Apex Trend & Liquidity Master calculates a trend cloud using customizable moving averages expanded by a volatility multiplier directly on the main price chart. It identifies dynamic support and resistance liquidity zones from swing high and low pivots, extendi

Indicator v6 TrendSupport & resistance
Updated 2 months ago · MPL-2.0 GitHub repository of Apex Trend & Liquidity Master

More SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers