تم تحديثه

Directional Strength Oscillator

658
Directional Strength Oscillator

A signed trend-strength oscillator that reads the tug-of-war between upward and downward movement and prints one line — positive in uptrends, negative in downtrends, crossing zero at trend changes. Unlike a plain directional reading, it dims itself when price is only chopping, flags weakening trends through divergence, and scores its own signals forward on your chart in plain language.

Why these parts are combined (not a mashup for show). Each part answers what the previous one leaves open. Up-movement vs down-movement relative to true range gives a clean, bounded read of who's winning and by how much — but it can read "strong" inside noisy, non-trending chop. A trend-efficiency filter (net travel over total path) measures whether price is actually going somewhere; folding it into the line removes the false-strong chop. A divergence check (price makes a new extreme while strength does not) flags weakening trends the raw line would miss. Together they form one directional-strength tool.

How it works. Up-movement = |high − prior low|, down-movement = |low − prior high|; each is summed over the length and divided by summed true range to get the up and down lines. Their difference is the raw strength; it's standardized, soft-bounded to ±100, then scaled by a 0–1 trend-efficiency factor. Signals are zero-crosses gated by a minimum quality, plus divergence against price (measured on the undimmed strength). Each signal is then labelled by a triple barrier — a profit target and equal stop in ATR units plus a time limit — so a "win" means the target hit before the stop. Results split into in-sample and recent out-of-sample, with a confidence interval and a multiple-testing check.

How to use. Read the Verdict row (Long/Short signal, Watch, or Wait) and the Conviction row, which reads "High" only when that signal type shows a positive edge that survives the test on this symbol. Green line above zero = uptrend in control, red below = downtrend; shaded bands = strong trend; the trend-quality % tells you how clean the move is. Best used with your own entry and risk plan, not alone.

What's original. The trend-quality gate that removes false-strong chop, integrated divergence on the undimmed line, the forward triple-barrier calibration with an out-of-sample split, and a conviction read that openly admits when there's no proven edge.

Inputs. High/Low sources (change them for any market), reading mode (Simple/Pro), engine, quality-gate, divergence and full calibration settings, and an auto-adapting dashboard legible on dark or light charts. Defaults are tuned for NSE:NIFTY1! intraday.

Honesty & limitations. Edge figures are computed on this chart's own history with overlapping windows and no costs — context, not a guaranteed backtest; past behaviour doesn't predict the future.

Disclaimer: for research and education only. Not financial advice. Trading carries risk of loss; manage your own positions.
ملاحظات الأخبار
Directional Strength Oscillator — v2
Three changes in this update:

Performance: the forward-calibration engine now computes its triple-barrier outcome once per bar and reuses it, instead of recomputing the identical result three times — faster loading and lower runtime, outputs byte-for-byte unchanged.

New (optional, off by default): whipsaw filter. The zero-cross signal can require the trend flip to hold for N bars before firing — fewer false flips in transitions, slightly later entries. It flows through the calibration, so the Edge row tells you whether it helps on your instrument.

Overlay: the weakening-trend divergence warnings now also print on the price chart (×-marks), not just the sub-pane. Existing behaviour is unchanged until you turn the filter on.
ملاحظات الأخبار
v1.1 — Correctness + finishing pass

- Correctness (important): with "Require trend flip to hold" enabled, the hold-timing test called
ta.barssince from inside a toggle branch and behind a short-circuiting AND, so the counter was
skipped on most bars and the "held for N bars" check could fire at the wrong bar or miss. That
counter now advances on every bar as Pine requires, so the whipsaw filter times signals correctly.
- Added a Data Window (EXP_) export bus so the oscillator can feed other scripts via input.source().
- Added a cost model: a new "Round-trip cost (R)" input and a Net R row. Conviction now requires a
signal to BOTH beat its base rate (Wilson) AND survive costs — a gross edge that costs eat through
is not tradeable, and the panel now says so.

Descriptive research tooling, in-sample statistics, not investment advice.
ملاحظات الأخبار
v1.2 — Two additive normalization options over v1.1: a robust MAD z-score and an optional 3-window extreme consensus. The signed directional-strength engine, the trend-quality gate, the divergence check and the entire forward-calibration harness (triple-barrier, out-of-sample split, Wilson stars, Bonferroni, Net-R cost model) are unchanged — set Normalization method = "Classic (mean/stdev)" to reproduce the exact v1.1 read.

1. Robust MAD normalization (default on). The directional-strength spread is itself sensitive to single violent bars, so a mean/stdev z on top lets one outlier stretch the whole scale. The spread can now be standardized with a median/MAD z-score (median absolute deviation ×1.4826, so MAD ≈ σ under a Gaussian) — outlier-resistant, so the +/−100 scale and the strong-trend zones keep a stable meaning across regimes. Selectable via "Normalization method"; set "Classic (mean/stdev)" for the original.

2. 3-window extreme consensus (opt-in, default off). The z can be taken as the MEDIAN of the z at half, one and double the normalization window — a reading is extreme only when short, medium and long windows agree, removing the arbitrariness of a single lookback. "Extreme normalization" = "Single window" (the default) reproduces v1.1 exactly.

What is unchanged. The up-movement / down-movement over true-range strength pair, the standardize-and-soft-bound to +/−100, the trend-efficiency quality gate, the optional hold-to-confirm whipsaw filter, the confirmed-pivot divergence, and the full forward-calibration layer (triple-barrier outcomes, non-overlapping sampling, out-of-sample window, Wilson interval, Bonferroni multi-test, round-trip cost → Net R) are byte-for-byte v1.1. Every export (EXP_Oscillator, EXP_UpLine, EXP_DownLine, EXP_TrendQuality, EXP_BuySignal, EXP_SellSignal, EXP_Signal, EXP_Divergence, EXP_LongEdge, EXP_ShortEdge, EXP_LongNetR, EXP_ShortNetR) is retained. The new layers only re-standardize an existing series.

Still context, not a standalone trigger — edge figures are computed on this chart's own overlapping history and are not a guaranteed backtest. Non-repaint: reads confirmed closes; the calibration logs and resolves only on confirmed bars. Concept credits unchanged (directional-movement / true-range strength; trend-efficiency filter; price-vs-oscillator divergence; López de Prado triple-barrier; Wilson; Bonferroni), plus the median/MAD robust z-score for the new normalization.
ملاحظات الأخبار
v1.3 — R1 honest-stats standardization. Robust-z and the Wilson-lower-bound math (star rating and the deflated z=2.24 survivorship gate) now come from the published calibration libraries (ml_robuststats/2, ml_calib/2), byte-identical to the prior local helpers — signals, marks and calibration numbers unchanged. Shared calibration engine across the divergence family.

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

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