Market Structure Trend Matrix [BigBeluga] is a comprehensive technical analysis framework engineered for traders who demand precision in identifying market regimes and trend expansions. By integrating automated Market Structure (MS) detection with volatility-adjusted risk parameters, this indicator provides a systematic roadmap for navigating complex price action.
NOTE: I CHANGED THE TARGET LEVELS FROM THE ORIGINAL INDICATOR. TOS DOESN'T CONVERT THE ORIGINAL TARGETS.
In the below picture of META on 4 hr chart, price hit the T3 target three times.
The tool focuses on the Change of Character (ChoCh)—the critical moment when a previous trend structure breaks and a new directional bias begins.
ARCHITECTURE & CORE LOGIC
CONCLUSION
Market Structure Trend Matrix [BigBeluga] is more than a signal tool; it is a visual framework for objective decision-making. By anchoring your trading to structural pivots and volatility-based targets, you remove the guesswork from trend following. Whether you are looking for a clean "ChoCh" entry or a systematic way to trail your profits during a massive expansion, the Trend Matrix provides the data and clarity required to trade like a professional.
NOTE: I CHANGED THE TARGET LEVELS FROM THE ORIGINAL INDICATOR. TOS DOESN'T CONVERT THE ORIGINAL TARGETS.
In the below picture of META on 4 hr chart, price hit the T3 target three times.
The tool focuses on the Change of Character (ChoCh)—the critical moment when a previous trend structure breaks and a new directional bias begins.
- Automated Structure Mapping: The engine uses a sophisticated pivot-detection algorithm (MS Length) to scan for institutional-grade swing highs and lows. It ignores minor retail noise, drawing structural lines only when significant supply or demand zones are breached.
- The ChoCh Engine: When price crosses a recent pivot high or low, the indicator prints a "ChoCh" label. This represents a fundamental shift in market sentiment, signaling that the current trend has likely terminated and a new cycle has begun.
Market Structure Trend Matrix [BigBeluga] is more than a signal tool; it is a visual framework for objective decision-making. By anchoring your trading to structural pivots and volatility-based targets, you remove the guesswork from trend following. Whether you are looking for a clean "ChoCh" entry or a systematic way to trail your profits during a massive expansion, the Trend Matrix provides the data and clarity required to trade like a professional.
Code:
# Market_Structure_Trend_Matrix
# Converted from "Market Structure Trend Matrix [BigBeluga]": https://www.tradingview.com/script/EdtttXPC-Market-Structure-Trend-Matrix-BigBeluga/
# Converted by Chewie 5/5/2026
# ═══════════════════════════════════════════════════════
# INPUTS
# ═══════════════════════════════════════════════════════
input msLen = 10;
input atrLength = 14;
input atrMult = 4.0;
input TatrMult = 2.0;
input targetStepMult = 2.0;
input showStop = yes;
input bubble = yes;
input alerts = yes;
# Colors — defined as defs using CreateColor so they can be reused anywhere
# Bull = green (52, 230, 126) | Bear = magenta (255, 82, 241)
DefineGlobalColor("Bull", CreateColor(52, 230, 126));
DefineGlobalColor("Bear", CreateColor(255, 82, 241));
# ═══════════════════════════════════════════════════════
# PIVOT DETECTION
# ═══════════════════════════════════════════════════════
def ph = if high[msLen] == Highest(high, 2 * msLen + 1)[msLen] then high[msLen] else Double.NaN;
def pl = if low[msLen] == Lowest(low, 2 * msLen + 1)[msLen] then low[msLen] else Double.NaN;
def phVal = if !IsNaN(ph) then ph else phVal[1];
def plVal = if !IsNaN(pl) then pl else plVal[1];
# ═══════════════════════════════════════════════════════
# ATR
# ═══════════════════════════════════════════════════════
def atr = Average(TrueRange(high, close, low), atrLength);
# ═══════════════════════════════════════════════════════
# DIRECTION & STRUCTURE BREAKS (ChoCh)
# ═══════════════════════════════════════════════════════
def bullBreak = close crosses above phVal;
def bearBreak = close crosses below plVal;
def direction;
def entryPrice;
if bullBreak and !direction[1] {
direction = 1;
entryPrice = phVal;
} else if bearBreak and direction[1] {
direction = 0;
entryPrice = plVal;
} else {
direction = direction[1];
entryPrice = entryPrice[1];
}
def directionChanged = direction != direction[1];
# ═══════════════════════════════════════════════════════
# ATR TRAILING STOP
# Bull: ratchet up → max(prev, close - atr*mult)
# Bear: ratchet down → min(prev, close + atr*mult)
# ═══════════════════════════════════════════════════════
def atrTS;
if bullBreak and !direction[1] {
atrTS = close - atr * atrMult;
} else if bearBreak and direction[1] {
atrTS = close + atr * atrMult;
} else if direction {
atrTS = Max(CompoundValue(1, atrTS[1], close - atr * atrMult),
close - atr * atrMult);
} else {
atrTS = Min(CompoundValue(1, atrTS[1], close + atr * atrMult),
close + atr * atrMult);
}
# ═══════════════════════════════════════════════════════
# PLOTS — TRAILING STOP
# ═══════════════════════════════════════════════════════
plot TrailingStop = if showStop and !directionChanged then atrTS else Double.NaN;
TrailingStop.SetLineWeight(2);
TrailingStop.AssignValueColor(if direction then GlobalColor("Bull") else GlobalColor("Bear"));
plot PriceLine = if showStop then close else Double.NaN;
PriceLine.Hide();
AddCloud(PriceLine, TrailingStop, GlobalColor("Bull"), GlobalColor("Bear"));
# ═══════════════════════════════════════════════════════
# TARGET LEVELS
# Projected from entryPrice at atrMult * targetStepMult increments.
# Held until the next direction change clears them.
# ═══════════════════════════════════════════════════════
def targetStep = atr * TatrMult * targetStepMult;
def t1;
def t2;
def t3;
if directionChanged {
t1 = if direction then entryPrice + 1 * targetStep
else entryPrice - 1 * targetStep;
t2 = if direction then entryPrice + 2 * targetStep
else entryPrice - 2 * targetStep;
t3 = if direction then entryPrice + 3 * targetStep
else entryPrice - 3 * targetStep;
} else {
t1 = CompoundValue(1, t1[1], Double.NaN);
t2 = CompoundValue(1, t2[1], Double.NaN);
t3 = CompoundValue(1, t3[1], Double.NaN);
}
plot Target1 = t1;
plot Target2 = t2;
plot Target3 = t3;
Target1.SetStyle(Curve.SHORT_DASH);
Target2.SetStyle(Curve.SHORT_DASH);
Target3.SetStyle(Curve.SHORT_DASH);
Target1.SetLineWeight(1);
Target2.SetLineWeight(1);
Target3.SetLineWeight(2);
Target1.AssignValueColor(if direction then GlobalColor("Bull") else GlobalColor("Bear"));
Target2.AssignValueColor(if direction then GlobalColor("Bull") else GlobalColor("Bear"));
Target3.AssignValueColor(if direction then GlobalColor("Bull") else GlobalColor("Bear"));
AddChartBubble(directionChanged, if direction then t1 else t1, "T1", Color.WHITE, direction);
AddChartBubble(directionChanged, if direction then t2 else t2, "T2", Color.WHITE, direction);
AddChartBubble(directionChanged, if direction then t3 else t3, "T3", Color.WHITE, direction);
# ═══════════════════════════════════════════════════════
# PLOTS — ChoCh SIGNALS
# ═══════════════════════════════════════════════════════
plot ChoCh_Bull = if bullBreak and !direction[1] then low else Double.NaN;
ChoCh_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ChoCh_Bull.SetDefaultColor(GlobalColor("Bull"));
ChoCh_Bull.SetLineWeight(3);
plot ChoCh_Bear = if bearBreak and direction[1] then high else Double.NaN;
ChoCh_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ChoCh_Bear.SetDefaultColor(GlobalColor("Bear"));
ChoCh_Bear.SetLineWeight(3);
AddChartBubble(bubble and bullBreak and !direction[1], low, "ChoChUP", GlobalColor("Bull"), no);
AddChartBubble(bubble and bearBreak and direction[1], high, "ChoChDN", GlobalColor("Bear"), yes);
# ═══════════════════════════════════════════════════════
# ALERTS
# ═══════════════════════════════════════════════════════
Alert(alerts and bullBreak and !direction[1], "ChoCh Up - Bullish Structure Break", Alert.BAR, Sound.Chimes);
Alert(alerts and bearBreak and direction[1], "ChoCh Down - Bearish Structure Break", Alert.BAR, Sound.Bell);