MSL Trend FollowMSL Trend Follow is a market-structure trend-following indicator designed to help traders identify when price may be shifting from one directional phase to another, and then follow that phase using an ATR-based trailing stop.
The indicator combines two core ideas:
1. Market structure break logic
2. Adaptive ATR trailing stop management
Instead of plotting a large number of separate signals, MSL Trend Follow focuses on a cleaner workflow: detect a structural trend change, display the direction, and then provide a dynamic trailing stop line that follows the active trend.
How it works
The script identifies confirmed swing highs and swing lows using a pivot-based structure model. When price closes above the most recent confirmed swing high, the indicator marks a potential bullish trend shift. When price closes below the most recent confirmed swing low, it marks a potential bearish trend shift.
After a trend signal appears, the indicator plots an ATR-based trailing stop:
- In an uptrend, the green trailing stop line is plotted below price.
- In a downtrend, the red trailing stop line is plotted above price.
The trailing stop uses a ratchet mechanism. During an uptrend, the stop can only move upward. During a downtrend, the stop can only move downward. This helps the line follow the active trend without constantly moving back and forth with every minor price fluctuation.
What makes it useful
MSL Trend Follow is not designed to predict every candle or call every market turn. Its purpose is to give traders a structured way to read trend direction and manage the active phase after a structural breakout.
The indicator may help traders answer three practical questions:
- Has price shifted above or below an important structural level?
- Is the current trend phase still active?
- How far is price from the current trailing stop?
The chart output is intentionally simple:
- Green Trend signal: bullish structure shift
- Red Trend signal: bearish structure shift
- Green line: bullish trailing stop
- Red line: bearish trailing stop
- Dashboard: current trend state, signal age, and distance to stop
Dashboard
The dashboard gives a compact view of the current state:
Trend
Shows the current directional state:
UP, DOWN, or NEUTRAL.
Signal Age
Shows how many bars have passed since the most recent trend signal. A small number means the signal is relatively fresh. A larger number means the trend phase has already been active for a longer period.
To Stop
Shows the current distance between price and the trailing stop as a percentage. This helps traders understand how much room price has before reaching the active stop line.
How to use it
A bullish scenario appears when the indicator prints a green Trend signal and starts plotting a green trailing stop below price. This means price has broken above the latest confirmed structural high and the indicator has shifted into an upward trend state.
A bearish scenario appears when the indicator prints a red Trend signal and starts plotting a red trailing stop above price. This means price has broken below the latest confirmed structural low and the indicator has shifted into a downward trend state.
The trailing stop can be used as a visual reference for trend continuation or trend invalidation. As long as price respects the active trailing stop, the current trend phase remains structurally intact according to the indicator logic. If price moves through the trailing stop area, the current trend phase may be weakening or ending.
Suggested interpretation
Stronger bullish context:
- Trend state is UP
- Price remains above the green trailing stop
- The green stop line continues to move upward
- The signal is not extremely old
- The broader market context supports upward continuation
Stronger bearish context:
- Trend state is DOWN
- Price remains below the red trailing stop
- The red stop line continues to move downward
- The signal is not extremely old
- The broader market context supports downward continuation
Weaker or more cautious context:
- Price is very close to the trailing stop
- The signal is very old
- Market is moving sideways
- Price repeatedly crosses back and forth around structural levels
- Higher-timeframe direction conflicts with the current signal
Settings
Pivot Length
Controls how major or minor the detected structure points are. Lower values make the indicator more reactive, but may create more noise. Higher values focus on larger structural swings and may produce fewer signals.
Min Bars Between Signals
Adds a minimum bar distance between trend signals. This can help reduce rapid flip-flopping in choppy markets.
ATR Length
Controls the ATR calculation used for the trailing stop.
ATR Multiplier
Controls how far the trailing stop sits from price. A higher multiplier creates a wider stop and fewer stop-outs. A lower multiplier creates a tighter stop and faster reaction.
Signal Offset ATR
Controls how far the signal label is placed from the trailing stop line. This is a visual setting only and does not change the signal logic.
Best use cases
MSL Trend Follow is best suited for traders who want a clean trend-following tool based on market structure and dynamic stop tracking. It can be used on different markets, including stocks, crypto, forex, indices, and commodities, but the settings should be adjusted to the asset and timeframe.
Suggested timeframes:
- H1 for more active trading
- H4 for intraday and short swing context
- D1 for broader swing trend structure
The indicator is not intended to be used as a standalone trading system. It should be combined with broader market context, support and resistance, volatility conditions, risk management, and the trader’s own trading plan.
Important notes
This indicator does not guarantee future performance.
It does not predict the market.
It does not replace risk management.
It is designed for market analysis and educational use.
All signals should be interpreted in context. A trend signal shows that a structural condition has been met according to the indicator logic, not that a trade must be opened automatically.
Markets can remain volatile, choppy, or unpredictable, and any technical tool can produce false signals.
Индикатор Pine Script®






















