ATRTrendChannel
- Indicatori
-
Shi Yuan Wang
Sviluppo indicatori personalizzati, Expert Advisor (EA), script e strumenti di trading per MetaTrader 4 e MetaTrader 5, nonché indicatori per TradingView (Pine Script).
Cosa posso fare per te: - Versione: 1.0
ATR Trend Channel — Adaptive ATR-Based Trend Channel Indicator
For MetaTrader 5 · Main chart window indicator
Overview
ATR Trend Channel is an adaptive trend channel indicator drawn directly on the price chart.
It builds an upper band and a lower band around the median price of each bar, using ATR (Average True Range) as the scaling unit. Unlike a regular moving-average channel, this channel does not slide smoothly from bar to bar. It stays anchored to a specific bar and is re-anchored — and the trend is flipped — only when the closing price actually breaks out of a band. This stepped structure keeps the trend boundary clear and the flip points unambiguous, instead of having the channel constantly reshape itself during choppy conditions.
Beyond the channel itself, the indicator puts three things on the chart:
- Trend direction — only the upper band (green) is shown during an uptrend; only the lower band (red) during a downtrend.
- Flip trigger level — a dashed projection extending to the right of the latest bar, showing the price that would trigger a trend flip.
- Trend strength — candles are colored by the close position inside the channel; the closer the price is to the trend-side band, the more the color shifts toward the trend color.
The indicator places no orders and contains no automated trading logic. It is a pure visualization tool for market structure and trend state.
Key Features
- ATR-adaptive channel — the channel width scales with volatility, so the same settings can be used across instruments with very different price ranges.
- Stepped anchoring and flips — a close above the upper band is a bullish flip, a close below the lower band is a bearish flip; the channel is re-anchored to the current bar only on a flip.
- Inner buffer bands — gray dashed inner bands are drawn inside the visible band; their offset equals half of the average range of the last 50 bars, helping to separate a normal pullback from a weakening trend.
- Gradient candles — in an uptrend, the closer the close is to the upper band, the more bullish the candle color; in a downtrend, the closer the close is to the lower band, the more bearish the color; mid-channel candles fade into the transition color.
- Flip arrows — an up arrow below the bar marks a bullish flip, a down arrow above the bar marks a bearish flip; both can be switched off.
- Last-bar projection — a dashed line extending about 10 bars to the right of the latest bar, together with a text label showing the exact flip trigger price.
- Status table — a compact table in the lower-right corner showing the current trend direction (UP / DOWN) and the latest price.
- Fully configurable — ATR period, ATR multiplier, three colors and three display switches.
Chart Elements at a Glance
Element | When it appears | Meaning |
|---|---|---|
Green solid line (Upper Band) | During an uptrend | Channel upper band; reference for bullish targets / resistance |
Red solid line (Lower Band) | During a downtrend | Channel lower band; reference for bearish targets / support |
Gray dashed line (Upper / Lower Inner) | Together with the visible band | Inner buffer band separating normal pullbacks from trend weakening |
Gradient candles | Always | Colored by the close position inside the channel; reflects trend momentum |
Up arrow | Bullish flip (close breaks above the upper band) | Point where the trend turns bullish |
Down arrow | Bearish flip (close breaks below the lower band) | Point where the trend turns bearish |
Dashed line + text label to the right | Right of the latest bar | Flip trigger level: the lower band during an uptrend (bearish flip level), the upper band during a downtrend (bullish flip level) |
Table in the lower-right corner | Always | Current trend direction and latest price |
How It Works (Plain Description)
- The median price of each bar, (high + low) / 2 , is used as the channel reference base.
- A distance of ATR × multiplier is applied upward and downward to obtain the upper and lower bands.
- The channel stays anchored to one bar and is re-anchored to the current bar only when the close breaks out of a band — this is a flip.
- On every flip, the buffer-band offset is recalculated from the average range of the last 50 bars.
- Candles are colored according to the relative position of the close between the lower band (0) and the upper band (1), producing the gradient.
All calculations use only data that has already been produced. Nothing on closed bars changes afterwards (no repainting); only the state on the latest, still-forming bar updates as price moves.
Input Parameters
=== Channel Settings ===
Parameter | Default | Description |
|---|---|---|
ATR Length | 100 | Period used for the ATR calculation, which sets the base of the channel width. Higher values give a smoother channel with fewer flips; lower values make it more sensitive |
ATR Multiplier | 2.5 | Channel radius = ATR × multiplier. Higher values widen the channel and make flips less frequent |
=== Colors ===
Parameter | Default | Description |
|---|---|---|
Bullish color | C'12,190,137' | Used for the strongest-bullish end of the candle gradient, and for the projection line and table during an uptrend |
Bearish color | C'233,52,52' | Used for the strongest-bearish end of the candle gradient, and for the projection line and table during a downtrend |
Transition color | Yellow | Middle color of the candle gradient, representing neutral momentum / mid-channel price |
Note: these color parameters affect the gradient candles, the projection line and the status table. The color of the channel lines and arrows can be changed separately in the chart's Colors tab.
=== Display ===
Parameter | Default | Description |
|---|---|---|
Show flip arrows | true | Draw arrows at flip points |
Show last-bar projection | true | Draw the flip-trigger projection line and price label to the right of the latest bar |
Show trend table | true | Show the trend and price table in the lower-right corner |
Suggested Settings
Trading style | Suggested timeframe | ATR Length | ATR Multiplier |
|---|---|---|---|
Scalping / short term | M5 – M15 | 30 – 50 | 1.8 – 2.2 |
Intraday | M30 – H1 | 60 – 100 | 2.0 – 2.5 |
Swing / position | H4 – D1 | 100 – 200 | 2.5 – 3.5 |
These are only common starting ranges; please test and adjust them for the volatility of your instrument and your own style.
How to Use It
- Define the direction — use a channel flip as the trend-direction switch: during an uptrend, plan only long-side trades; during a downtrend, plan only short-side trades.
- Reference targets — the upper band during an uptrend and the lower band during a downtrend can serve as a first target area for the trend move.
- Reference risk levels — during an uptrend, the projected lower band to the right of the latest bar is the bearish-flip level; if price reaches it, the trend structure has changed, which can be used as an exit or reduction reference.
- Filter noise — pullbacks that stay inside the inner buffer band are normal within a trend; attention is warranted when price enters the buffer zone and approaches the flip level.
- Detect ranging markets — frequent flip arrows over a short period usually mean the market is in a range, where channel signals are less reliable.
- Multi-timeframe use — a common approach is to define the main direction on a higher timeframe (H4, D1) and use the channel on a lower timeframe (M15, H1) to time entries and exits.
Instruments and Timeframes
- Instruments: currency pairs, precious metals, energies, index and commodity CFDs, cryptocurrency CFDs — any instrument available in MetaTrader 5.
- Timeframes: all timeframes (M1 to MN). The default settings (ATR 100 / multiplier 2.5) suit H1 and above; for lower timeframes, reduce the ATR period accordingly.
Installation and Usage
- After obtaining the indicator from the Market, MetaTrader 5 installs it into the MQL5/Indicators folder automatically; you can also copy the file manually and refresh the Navigator.
- Find ATR Trend Channel under Navigator → Indicators and double-click it or drag it onto the chart.
- Set the ATR period, ATR multiplier and colors in the Inputs tab.
- To see the original candles, set the Candles plot to None in the Colors tab; the channel line and arrow colors are adjusted in the same tab.
- You can load the indicator several times with different settings on the same or different charts — each instance keeps its own parameters.
Notes
- The indicator provides visualization of trend and volatility structure only. It is not a complete trading system and contains no automated trading functions. Always apply your own risk management and make your own trading decisions.
- Arrows, colors and the projection level on the latest, still-forming bar update as price moves and are fixed only when the bar closes. Everything on closed bars remains unchanged.
- The chart needs at least ATR period + 50 bars before the indicator starts drawing, so please allow enough history.
- The default ATR period of 100 produces very few flips on M1–M15; lower the parameter for short timeframes.
- The indicator redraws candles on the main chart with gradient colors. This is a display effect only and does not affect the underlying price data.
- After switching off the projection or table display, reload the indicator to remove the objects already drawn.
Risk Disclaimer
Trading financial markets involves risk and may not be suitable for all investors. This indicator offers technical analysis and market-structure visualization only; it does not guarantee or imply any profit. Past behavior of any indicator does not represent future results. All outcomes of trading decisions made with this indicator are the sole responsibility of the user.
