OPEN-SOURCE SCRIPT
Quantile Drift Engine [forexobroker]

Quantile Drift Engine uses the rolling 25th and 75th percentiles of close as a robust analogue to mean and variance. The midpoint between Q25 and Q75 is the "interquartile median," which drifts directionally and is far less sensitive to spikes than a moving average. The drift, normalised by ATR, provides the regime gate; close cross of the midpoint provides the entry.
🔶 ALGORITHM
1. q25 = ta.percentile_linear_interpolation(close, N, 25); q75 = same at 75.
2. mid = (q25 + q75) / 2; drift = mid - mid[lag].
3. Trending regime when |drift| > k * ATR.
4. Buy entry: trending up AND close crosses mid up.
5. Sell entry: trending down AND close crosses mid down.
🔶 SIGNAL LOGIC
- Buy: trending up AND close crosses mid up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: trending down AND close crosses mid down.
- Position-lock state machine.
🔶 INPUTS
- Quantile Window (default 40)
- Drift Lag (default 5 bars)
- Drift Threshold x ATR (default 0.10)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, quantile bands, buy / sell colors
🔶 ALERTS
QDE Buy, QDE Sell, QDE Any Signal, QDE Drift Up, QDE Drift Down, QDE Mid Cross Up, QDE Mid Cross Dn, QDE Outside IQR, QDE Webhook JSON.
🔶 LIMITATIONS
- Percentile estimators need >= ~10 samples to be meaningful; short windows produce step-like quantiles.
- Linear interpolation between samples introduces minor smoothing; raw ranking would be slightly more responsive.
- Drift lag of 5 bars dampens noise but causes slight delay during sharp directional moves.
- IQR midpoint is robust but ignores tail behaviour; for tail-driven instruments pair with a separate volatility filter.
🔶 ALGORITHM
1. q25 = ta.percentile_linear_interpolation(close, N, 25); q75 = same at 75.
2. mid = (q25 + q75) / 2; drift = mid - mid[lag].
3. Trending regime when |drift| > k * ATR.
4. Buy entry: trending up AND close crosses mid up.
5. Sell entry: trending down AND close crosses mid down.
🔶 SIGNAL LOGIC
- Buy: trending up AND close crosses mid up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: trending down AND close crosses mid down.
- Position-lock state machine.
🔶 INPUTS
- Quantile Window (default 40)
- Drift Lag (default 5 bars)
- Drift Threshold x ATR (default 0.10)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, quantile bands, buy / sell colors
🔶 ALERTS
QDE Buy, QDE Sell, QDE Any Signal, QDE Drift Up, QDE Drift Down, QDE Mid Cross Up, QDE Mid Cross Dn, QDE Outside IQR, QDE Webhook JSON.
🔶 LIMITATIONS
- Percentile estimators need >= ~10 samples to be meaningful; short windows produce step-like quantiles.
- Linear interpolation between samples introduces minor smoothing; raw ranking would be slightly more responsive.
- Drift lag of 5 bars dampens noise but causes slight delay during sharp directional moves.
- IQR midpoint is robust but ignores tail behaviour; for tail-driven instruments pair with a separate volatility filter.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.