OPEN-SOURCE SCRIPT
تم تحديثه

Directional Strength Oscillator

281
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.

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

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