OPEN-SOURCE SCRIPT
Trend Deviation Channel (Zeiierman)

█ Overview
Trend Deviation Channel (Zeiierman) is an adaptive trend channel designed to measure the prevailing trend and how far price is displaced from its expected trend path.
The channel is built around five main components:
• Trend Baseline = the expected price path derived from the regression trend
• Deviation Rails = +1D, +2D, +3D and -1D, -2D, -3D levels around the trend
• Trend State = bullish, bearish, or neutral classification of the center trendline
• Deviation Profile = a rolling distribution showing where price has historically spent time relative to the trend
• Deviation Events = confirmed 2D and 3D Expansion and Re-entry events highlighting significant movement through the outer channel structure

A reading of -2D means price is approximately two normalized downside deviations below trend.
A reading beyond +3D or -3D represents a major displacement from the expected trend path and is classified as Dislocated.

█ How It Works
█ How to Use
Trend Deviation Channel can be used for Trend Identification, Trend Pullbacks, Dislocation Analysis, Mean Reversion, and Deviation Profile Analysis.
⚪ Trend Identification
The centerline provides the directional framework of the indicator.
• Bullish centerline = active uptrend
• Bearish centerline = active downtrend
• Neutral centerline = insufficient directional strength

⚪ Trend Pullbacks
During an established uptrend, price can be evaluated by how deeply it pulls below the center trendline.
• 0D to -1D = normal movement around trend
• -1D to -2D = meaningful pullback from trend
• -2D to -3D = extreme downside displacement
• Below -3D = dislocation from the prevailing trend structure

The opposite interpretation can be applied during downtrends.
A deviation level should not automatically be treated as support, resistance, or a reversal point. Instead, it provides a standardized measurement of how far price has moved from its expected trend path.
⚪ Dislocation Analysis
A 3D move marks an unusually large deviation from the existing trend.
When price reaches 3D against a prolonged trend, it can signal that momentum has shifted strongly enough for a larger trend change to be developing.
The key is not the 3D touch itself, but whether price can hold the displacement or continue through it.

⚪ Mean Reversion
Price often reacts or temporarily bounces when reaching the outer 2D and 3D deviation bands.
These areas represent strong extension, so traders can watch for temporary pullbacks or mean-reversion moves when price reaches them.
A touch alone is not a reversal signal, but it highlights an area where a reaction may become more likely.

⚪ Deviation Profile Analysis
The Deviation Profile shows where price has spent the most time relative to the trend.
Wider areas represent deviation zones visited more frequently, while thinner areas represent less common displacement.
• A profile weighted toward the lower deviation bands can suggest persistent downside pressure and stronger seller control.
• A profile weighted toward the upper deviation bands can suggest persistent upside pressure and stronger buyer control.
A balanced profile around 0D suggests price is spending more time near trend equilibrium.

█ Settings
-----------------
Disclaimer
The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.
All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
Trend Deviation Channel (Zeiierman) is an adaptive trend channel designed to measure the prevailing trend and how far price is displaced from its expected trend path.
The channel is built around five main components:
• Trend Baseline = the expected price path derived from the regression trend
• Deviation Rails = +1D, +2D, +3D and -1D, -2D, -3D levels around the trend
• Trend State = bullish, bearish, or neutral classification of the center trendline
• Deviation Profile = a rolling distribution showing where price has historically spent time relative to the trend
• Deviation Events = confirmed 2D and 3D Expansion and Re-entry events highlighting significant movement through the outer channel structure
A reading of -2D means price is approximately two normalized downside deviations below trend.
A reading beyond +3D or -3D represents a major displacement from the expected trend path and is classified as Dislocated.
█ How It Works
⚪ Trend Model
The indicator builds a regression trend from completed historical bars and projects that structure forward.
The current candle does not pull the trend toward itself while its deviation is being measured, helping preserve a cleaner reading of how far price has moved from the established trend.Pine Script®
⚪ Trend State
The center 0 TREND line identifies the current environment as:
• Up Trend
• Down Trend
• Neutral
Trend direction is based on regression slope strength relative to ATR.
Separate Trend Enter Strength and Trend Exit Strength thresholds help prevent the trend state from constantly switching during borderline conditions.
⚪ Deviation Structure
Price displacement is measured relative to the projected trend rather than a horizontal average.
• ±1D = Stretch
• ±2D = Extreme
• ±3D = DislocatedPine Script®
Price near 0D is trading close to trend equilibrium.
As price reaches 1D, 2D, and 3D, displacement from the expected trend path becomes progressively more significant.
⚪ Deviation Profile
The profile beside the channel shows where price has historically spent the most time in deviation space, rather than price space.
For example, readings such as +0.4D, +1.2D, -0.7D, and -2.1D are grouped together to reveal the distribution of trend-relative displacement.
Wider areas show deviation zones visited more often, while thinner areas show less common displacement.
⚪ Expansion & Re-entry
Expansion events identify confirmed transitions into more extended deviation regions.Pine Script®
2D Expansion indicates price has moved into an extreme displacement.
3D Expansion indicates price has moved into the outer Dislocated region.
A Re-entry occurs when price later crosses back inside the corresponding deviation boundary.
These events can help identify:
• accelerating extension
• sustained displacement
• failed expansion
• movement back toward trend equilibrium
█ How to Use
Trend Deviation Channel can be used for Trend Identification, Trend Pullbacks, Dislocation Analysis, Mean Reversion, and Deviation Profile Analysis.
⚪ Trend Identification
The centerline provides the directional framework of the indicator.
• Bullish centerline = active uptrend
• Bearish centerline = active downtrend
• Neutral centerline = insufficient directional strength
⚪ Trend Pullbacks
During an established uptrend, price can be evaluated by how deeply it pulls below the center trendline.
• 0D to -1D = normal movement around trend
• -1D to -2D = meaningful pullback from trend
• -2D to -3D = extreme downside displacement
• Below -3D = dislocation from the prevailing trend structure
The opposite interpretation can be applied during downtrends.
A deviation level should not automatically be treated as support, resistance, or a reversal point. Instead, it provides a standardized measurement of how far price has moved from its expected trend path.
⚪ Dislocation Analysis
A 3D move marks an unusually large deviation from the existing trend.
When price reaches 3D against a prolonged trend, it can signal that momentum has shifted strongly enough for a larger trend change to be developing.
The key is not the 3D touch itself, but whether price can hold the displacement or continue through it.
⚪ Mean Reversion
Price often reacts or temporarily bounces when reaching the outer 2D and 3D deviation bands.
These areas represent strong extension, so traders can watch for temporary pullbacks or mean-reversion moves when price reaches them.
A touch alone is not a reversal signal, but it highlights an area where a reaction may become more likely.
⚪ Deviation Profile Analysis
The Deviation Profile shows where price has spent the most time relative to the trend.
Wider areas represent deviation zones visited more frequently, while thinner areas represent less common displacement.
• A profile weighted toward the lower deviation bands can suggest persistent downside pressure and stronger seller control.
• A profile weighted toward the upper deviation bands can suggest persistent upside pressure and stronger buyer control.
A balanced profile around 0D suggests price is spending more time near trend equilibrium.
█ Settings
- Source: Selects the price series used to construct the trend model and calculate deviation. Close is used by default.
- Trend Length: Controls how much historical data is used to estimate the regression trend. Higher values create a smoother, slower channel. Lower values react faster.
- Trend Enter Strength: Controls how much directional strength is required before the center trendline enters an Up or Down state.
- Trend Exit Strength: Controls how weak an established trend must become before returning to Neutral.
- Deviation Shape: Asymmetric estimates separate upside and downside deviation scales. Symmetric uses one shared scale for both sides.
- Residual Shock Cap (ATR): Limits how much an unusually large historical movement can influence the deviation width.
- Minimum Deviation Width (ATR): Prevents the deviation rails from becoming too narrow during low-volatility conditions.
- Minimum One-Side Samples: Controls how many observations are required before an independent upside or downside deviation estimate is used.
- Deviation 1: Controls the first deviation rail and separates the Core region from Stretch behavior.
- Deviation 2: Controls the second deviation rail and the threshold used for 2D Expansion and Re-entry events.
- Deviation 3: Controls the outer deviation rail and the threshold used for 3D Expansion and Re-entry events.
- Stretch Memory: Controls how slowly persistent displacement beyond the first deviation rail fades from the internal stretch state.
- Show Rail Labels: Shows or hides the +1D, +2D, +3D, 0 TREND, -1D, -2D, and -3D labels.
- Show Current Deviation: Shows or hides the live label displaying the current normalized deviation and displacement zone.
- Show 2D Expansion: Shows or hides confirmed 2D Expansion markers.
- Show 2D Re-entry: Shows or hides confirmed 2D Re-entry markers.
- Show 3D Expansion: Shows or hides confirmed 3D Expansion markers.
- Show 3D Re-entry: Shows or hides confirmed 3D Re-entry markers.
- Up Trend: Controls the center trendline color during an active uptrend.
- Down Trend: Controls the center trendline color during an active downtrend.
- Neutral Trend: Controls the center trendline color when no active directional trend is detected.
- Upper Deviation: Controls the color of positive deviation rails, upper channel areas, profile bins, and upside events.
- Lower Deviation: Controls the color of negative deviation rails, lower channel areas, profile bins, and downside events.
- Show Deviation Profile: Shows or hides the rolling trend-relative Deviation Profile.
- Bins: Controls the number of buckets used to construct the Deviation Profile.
- Profile Range (D): Controls the positive and negative deviation range displayed by the profile.
- Profile Gap: Controls the horizontal distance between the projected channel and the Deviation Profile.
- Profile Max Width: Controls the maximum width of the most populated profile area.
-----------------
Disclaimer
The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.
All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Access my indicators at: zeiierman.com
Join Our Free Discord: discord.gg/zeiiermantrading
Join Our Free Discord: discord.gg/zeiiermantrading
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Access my indicators at: zeiierman.com
Join Our Free Discord: discord.gg/zeiiermantrading
Join Our Free Discord: discord.gg/zeiiermantrading
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.