OPEN-SOURCE SCRIPT

Dominant DATR [CHE]

281
Dominant DATR [CHE] — Directional ATR stream with dominant-side EMA, bands, labels, and alerts

Summary

Dominant DATR builds two directional volatility streams from the true range, assigns each bar’s range to the up or down side based on the sign of the close-to-close move, and then tracks the dominant side through an exponential average. A rolling band around the dominant stream defines recent extremes, while optional gradient coloring reflects relative magnitude. Swing-based labels mark new higher highs or lower lows on the dominant stream, and alerts can be enabled for swings, zero-line crossings, and band breakouts. The result is a compact pane that highlights regime bias and intensity without relying on price overlays.

Motivation: Why this design?

Conventional ATR treats all range as symmetric, which can mask directional pressure, cause late regime shifts, and produce frequent false flips during noisy phases. This design separates the range into up and down contributions, then emphasizes whichever side is stronger. A single smoothed dominant stream clarifies bias, while the band and swing markers help distinguish continuation from exhaustion. Optional normalization by close makes the metric comparable across instruments with different price scales.

What’s different vs. standard approaches?

Reference baseline: Classic ATR or a basic EMA of price.
Architecture differences:

Directional weighting of range using positive and negative close-to-close moves.
Separate moving averages for up and down contributions combined into one dominant stream.
Rolling highest and lowest of the dominant stream to form a band.
Optional normalization by close, window-based scaling for color intensity, and gamma adjustment for visual contrast.
Event logic for swing highs and lows on the dominant stream, with label buffering and pruning.
Configurable alerts for swings, zero-line crossings, and band breakouts.
Practical effect: You see when volatility is concentrated on one side, how strong that bias currently is, and when the dominant stream pushes through or fails at its recent envelope.

How it works (technical)

Each bar’s move is split into an up component and a down component based on whether the close increased or decreased relative to the prior close. The bar’s true range is proportionally assigned to up or down using those components as weights.
Each side is smoothed with a Wilder-style moving average. The dominant stream is the side with the larger value, recorded as positive for up dominance and negative for down dominance.
The dominant stream is then smoothed with an exponential moving average to reduce noise and provide a responsive yet stable signal line.
A rolling window tracks the highest and lowest values of the dominant EMA to form an envelope. Crossings of these bounds indicate unusual strength or weakness relative to recent history.
For visualization, the absolute value of the dominant EMA is scaled over a lookback window and passed through a gamma curve to modulate gradient intensity. Colors are chosen separately for up and down regimes.
Swing events are detected by comparing the dominant EMA to its recent extremes over a short lookback. Labels are placed when a prior bar set an extreme and the current bar confirms it. A managed array prunes older labels when the user-defined maximum is exceeded.
Alerts mirror these events and also include zero-line crossings and band breakouts. The script does not force closed-bar confirmation; users should configure alert execution timing to suit their workflow.
There are no higher-timeframe requests and no security calls. State is limited to simple arrays for labels and persistent color parameters.

Parameter Guide

Parameter — Effect — Default — Trade-offs/Tips

ATR Length — Smoothing of directional true range streams — fourteen — Longer reduces noise and may delay regime shifts; shorter increases responsiveness.
EMA Length — Smoothing of the dominant stream — twenty-five — Lower values react faster; higher values reduce whipsaw.
Band Length — Window for recent highs and lows of the dominant stream — ten — Short windows flag frequent breakouts; long windows emphasize only exceptional moves.
Normalize by Close — Divide by close price to produce a percent-like scale — false — Useful across assets with very different price levels.
Enable gradient color — Turn on magnitude-based coloring — true — Visual aid only; can be disabled for simplicity.
Gradient window — Lookback used to scale color intensity — one hundred — Larger windows stabilize the color scale.
Gamma (lines) — Adjust gradient intensity curve — zero point eight — Lower values compress variation; higher values expand it.
Gradient transparency — Transparency for gradient plots — zero, between zero and ninety — Higher values mute colors.
Up dark / Up neon — Base and peak colors for up dominance — green tones — Styling only.
Down dark / Down neon — Base and peak colors for down dominance — red tones — Styling only.
Show zero line / Background tint — Visual references for regime — true and false — Background tint can help quick scanning.
Swing length — Bars used to detect swing highs or lows — two — Larger values demand more structure.
Show labels / Max labels / Label offset — Label visibility, cap, and vertical offset — true, two hundred, zero — Increase cap with care to avoid clutter.
Alerts: HH/LL, Zero Cross, Band Break — Toggle alert rules — true, false, false — Enable only what you need.

Reading & Interpretation

The dominant EMA above zero indicates up-side dominance; below zero indicates down-side dominance.
Band lines show recent extremes of the dominant EMA; pushes through the band suggest unusual momentum on the dominant side.
Gradient intensity reflects local magnitude of dominance relative to the chosen window.
HH/LL labels appear when the dominant stream prints a new local extreme in the current regime and that extreme is confirmed on the next bar.
Zero-line crosses suggest regime flips; combine with structure or filters to reduce noise.

Practical Workflows & Combinations

Trend following: Consider entries when the dominant EMA is on the regime side and expands away from zero. Band breakouts add confirmation; structure such as higher highs or lower lows in price can filter signals.
Exits and stops: Tighten exits when the dominant stream stalls near the band or fades toward zero. Opposite swing labels can serve as early caution.
Multi-asset and multi-timeframe: Works across liquid assets and common timeframes. For lower noise instruments, reduce smoothing slightly; for high noise, increase lengths and swing length.

Behavior, Constraints & Performance

Repaint and confirmation: No security calls and no future-looking references. Swing labels confirm one bar later by design. Real-time crosses can change intra-bar; use bar-close alerts if needed.
Resources: `max_bars_back` is two thousand. The script uses an array for labels with pruning, gradient color computations, and a simple while loop that runs only when the label cap is exceeded.
Known limits: The EMA can lag at sharp turns. Normalization by close changes scale and may affect thresholds. Extremely gappy data can produce abrupt shifts in the dominant side.

Sensible Defaults & Quick Tuning

Starting point: ATR Length fourteen, EMA Length twenty-five, Band Length ten, Swing Length two, gradient enabled.
Too many flips: Increase EMA Length and swing length, or enable only swing alerts.
Too sluggish: Decrease EMA Length and Band Length.
Inconsistent scales across symbols: Enable Normalize by Close.
Visual clutter: Disable gradient or reduce label cap.

What this indicator is—and isn’t

This is a volatility-bias visualization and signal layer that highlights directional pressure and intensity. It is not a complete trading system and does not produce position sizing or risk management. Use it with market structure, context, and independent risk controls.

Disclaimer

The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.

Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.

By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.

Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.

Best regards and happy trading

Chervolino

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.