PROTECTED SOURCE SCRIPT
Trend Stretch Meter(Expansion/Compression(MTF))[NETSGAIN]

[Description]
"Trend Stretch Meter(Expansion/Compression(MTF))[NETSGAIN]" is a visual tool to read the market’s flow around a moving average — like a “magnetic middle.”
Most markets don’t move in one direction forever. Price tends to stretch away from the average, then compress back toward it.
This indicator helps you see that behavior clearly using:
-Duration (how long price stayed on one side of the MA)
-Max distance reached during that run
-Current distance now
-A simple State label: Expansion / Flat / Compression
It’s not a buy/sell signal. It’s context.
[Core idea (the “MA magnet” principle)]
Look back at any chart: price often moves up and down around a central average.
Think of the MA as the “middle line” price naturally revisits:
After a long bullish stretch, momentum usually fades → pullback risk rises
After a long bearish stretch, selling pressure often weakens → bounce risk rises
This tool helps you measure how stretched the market is, and whether it’s still expanding or already compressing back toward the MA.
[What the panel shows (MTF)]
Each timeframe row is calculated inside that timeframe:
✅ Duration
Number of consecutive candles price stayed above or below the MA
1H duration = counted in 1H candles
4H duration = counted in 4H candles
Same for 5m / 15m / 1D
✅ Distance
Max = the farthest distance (%) from the MA during the current run
Now = current distance (%) from the MA
✅ State
A simple ratio check:
Let:
ratio = |NowDist| / |MaxDist|
Expansion if ratio >= Expansion threshold
Compression if ratio <= Compression threshold
Otherwise Flat
So if price was once far from the MA, but is now much closer → Compression = momentum fading.
[How to use it (practical interpretation)]
Use it as a “market condition” dashboard:
When you often get “late trend / flip conditions”
Long Duration + High MaxDist + Compression
The move stretched far and lasted long, but now it’s compressing
Often a sign momentum is weakening → mean reversion risk rises
When trend is still healthy
Duration + MaxDist rising + Expansion
Price remains near its max extension → momentum still strong
Multi-timeframe confirmation (simple)
If several TFs show Compression, the move is likely losing force
If several TFs show Expansion, trend strength is still alive
Again: not a signal, but great context for trade management.
[EXAMPLE]

In the first chart, observe the market after a prolonged extended move away from the MA.
The higher timeframe shows long duration
1H: Compression
4H: Flat state with extended duration (~50 bars)
Meanwhile, lower timeframes (5m / 15m) begin to shift into bearish expansion
This combination indicates that although the move lasted long, momentum is no longer strengthening. Lower timeframes turn first, signaling internal weakness.

In the next chart, price loses momentum and changes direction, returning toward the MA.
This pattern appears frequently across markets:
Long duration
Large distance from the MA
Followed by compression or lower-TF expansion against the prior move
The key idea is simple:
Price tends to revert back toward the middle.
When a move stays extended for too long and distance stops expanding, momentum fades and a reversal or deeper pullback becomes increasingly likely.
[Recommended setup (defaults)]
<Recommended MA>
✅ MA Length: 50
Type: MA (default)
Why MA50?
It’s responsive enough for crypto and intraday flows, but still acts like a “middle” reference.
Note:
This is a recommendation, not a rule.
You can freely adjust the MA length to match your market, timeframe, or trading style.
<Recommended thresholds>
✅ Expansion threshold: 0.70
✅ Compression threshold: 0.30
How to think about it:
Expansion 0.70 means: “price is still at least 70% of its max stretch”
Compression 0.30 means: “price has pulled back close to the MA relative to its max”
If you want earlier “momentum fading” detection:
Expansion: 0.65–0.70
Compression: 0.30–0.45
[Web vs Mobile setup]
TradingView cannot auto-detect device reliably, so this script provides a manual toggle:
<Desktop / Web>
Mobile Compact Mode: OFF
Bigger panel text + multi-line distance display
<Mobile>
Mobile Compact Mode: ON
Shortened distance strings to prevent panel overflow
Tip: Click panel position and set it to bottom
[Summary]
Trend Stretch Meter(Expansion/Compression(MTF))[NETSGAIN] is built to answer:
“How long has price been stretched on this side?”
“How far did it extend from the mean?”
“Is momentum still expanding… or already compressing back?”
Use it to read the flow and manage trades with better context — especially when moves start to get “too extended for too long.”
[Disclaimer]
This indicator is provided for informational and educational purposes only.
It does not constitute financial, investment, or trading advice.
All trading decisions made using this indicator are the sole responsibility of the user.
Past performance is not indicative of future results. Trading involves risk.
"Trend Stretch Meter(Expansion/Compression(MTF))[NETSGAIN]" is a visual tool to read the market’s flow around a moving average — like a “magnetic middle.”
Most markets don’t move in one direction forever. Price tends to stretch away from the average, then compress back toward it.
This indicator helps you see that behavior clearly using:
-Duration (how long price stayed on one side of the MA)
-Max distance reached during that run
-Current distance now
-A simple State label: Expansion / Flat / Compression
It’s not a buy/sell signal. It’s context.
[Core idea (the “MA magnet” principle)]
Look back at any chart: price often moves up and down around a central average.
Think of the MA as the “middle line” price naturally revisits:
After a long bullish stretch, momentum usually fades → pullback risk rises
After a long bearish stretch, selling pressure often weakens → bounce risk rises
This tool helps you measure how stretched the market is, and whether it’s still expanding or already compressing back toward the MA.
[What the panel shows (MTF)]
Each timeframe row is calculated inside that timeframe:
✅ Duration
Number of consecutive candles price stayed above or below the MA
1H duration = counted in 1H candles
4H duration = counted in 4H candles
Same for 5m / 15m / 1D
✅ Distance
Max = the farthest distance (%) from the MA during the current run
Now = current distance (%) from the MA
✅ State
A simple ratio check:
Let:
ratio = |NowDist| / |MaxDist|
Expansion if ratio >= Expansion threshold
Compression if ratio <= Compression threshold
Otherwise Flat
So if price was once far from the MA, but is now much closer → Compression = momentum fading.
[How to use it (practical interpretation)]
Use it as a “market condition” dashboard:
When you often get “late trend / flip conditions”
Long Duration + High MaxDist + Compression
The move stretched far and lasted long, but now it’s compressing
Often a sign momentum is weakening → mean reversion risk rises
When trend is still healthy
Duration + MaxDist rising + Expansion
Price remains near its max extension → momentum still strong
Multi-timeframe confirmation (simple)
If several TFs show Compression, the move is likely losing force
If several TFs show Expansion, trend strength is still alive
Again: not a signal, but great context for trade management.
[EXAMPLE]
In the first chart, observe the market after a prolonged extended move away from the MA.
The higher timeframe shows long duration
1H: Compression
4H: Flat state with extended duration (~50 bars)
Meanwhile, lower timeframes (5m / 15m) begin to shift into bearish expansion
This combination indicates that although the move lasted long, momentum is no longer strengthening. Lower timeframes turn first, signaling internal weakness.
In the next chart, price loses momentum and changes direction, returning toward the MA.
This pattern appears frequently across markets:
Long duration
Large distance from the MA
Followed by compression or lower-TF expansion against the prior move
The key idea is simple:
Price tends to revert back toward the middle.
When a move stays extended for too long and distance stops expanding, momentum fades and a reversal or deeper pullback becomes increasingly likely.
[Recommended setup (defaults)]
<Recommended MA>
✅ MA Length: 50
Type: MA (default)
Why MA50?
It’s responsive enough for crypto and intraday flows, but still acts like a “middle” reference.
Note:
This is a recommendation, not a rule.
You can freely adjust the MA length to match your market, timeframe, or trading style.
<Recommended thresholds>
✅ Expansion threshold: 0.70
✅ Compression threshold: 0.30
How to think about it:
Expansion 0.70 means: “price is still at least 70% of its max stretch”
Compression 0.30 means: “price has pulled back close to the MA relative to its max”
If you want earlier “momentum fading” detection:
Expansion: 0.65–0.70
Compression: 0.30–0.45
[Web vs Mobile setup]
TradingView cannot auto-detect device reliably, so this script provides a manual toggle:
<Desktop / Web>
Mobile Compact Mode: OFF
Bigger panel text + multi-line distance display
<Mobile>
Mobile Compact Mode: ON
Shortened distance strings to prevent panel overflow
Tip: Click panel position and set it to bottom
[Summary]
Trend Stretch Meter(Expansion/Compression(MTF))[NETSGAIN] is built to answer:
“How long has price been stretched on this side?”
“How far did it extend from the mean?”
“Is momentum still expanding… or already compressing back?”
Use it to read the flow and manage trades with better context — especially when moves start to get “too extended for too long.”
[Disclaimer]
This indicator is provided for informational and educational purposes only.
It does not constitute financial, investment, or trading advice.
All trading decisions made using this indicator are the sole responsibility of the user.
Past performance is not indicative of future results. Trading involves risk.
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.