A strategy for crypto futures that combines a Hurst exponent estimate with a z-score, ADX, RSI and ATR to separate trending from mean-reverting conditions.
// QuantiFine v6 - TradingView Strateji
// Pivot Point R2/S2 Entry, S1/R1 Stop
//@version=5
strategy("QuantiFine v6 Pivot R2/S2", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.04)
// ═══════════════════════════════════════════════════════════
// AYARLAR
// ═══════════════════════════════════════════════════════════
grp1 = "═══ İndikatör Ayarları ═══"
atrLength = input.int(14, "ATR Periyodu", group=grp1)
adxLength = input.int(14, "ADX Periyodu", group=grp1)
rsiLength = input.int(14, "RSI Periyodu", group=grp1)
hurstLength = input.int(20, "Hurst Penceresi", group=grp1)
zScoreLength = input.int(20, "Z-Score Penceresi", group=grp1)
grp2 = "═══ Sinyal Eşikleri ═══"
adxThreshold = input.float(20, "ADX Eşiği", group=grp2)
zScoreLongThreshold = input.float(2.0, "Z-Score Long Eşiği", group=grp2)
zScoreShortThreshold = input.float(-2.0, "Z-Score Short Eşiği", group=grp2)
hurstReversionThreshold = input.float(0.48, "Hurst Reversion Eşiği (<)", group=grp2)
hurstTrendThreshold = input.float(0.52, "Hurst Trend Eşiği (>)", group=grp2)
atrDeadZoneMultiplier = input.float(0.5, "ATR Ölü Bölge Çarpanı", group=grp2)
grp3 = "═══ Kelly Pozisyon Boyutu ═══"
kellyWinRate = input.float(0.55, "Win Rate", minval=0.1, maxval=0.9, group=grp3)
kellyAvgWin = input.float(1.5, "Avg Win Ratio", group=grp3)
kellyAvgLoss = input.float(1.0, "Avg Loss Ratio", group=grp3)
// ═══════════════════════════════════════════════════════════
// İNDİKATÖR HESAPLAMALARI
// ═══════════════════════════════════════════════════════════
// ATR & ADX
atrValue = ta.atr(atrLength)
atrAvg = ta.sma(atrValue, 50)
[diplus, diminus, adxValue] = ta.dmi(adxLength, adxLength)
// RSI
rsiValue = ta.rsi(close, rsiLength)
// Z-Score
zScoreMean = ta.sma(close, zScoreLength)
zScoreStd = ta.stdev(close, zScoreLength)
zScore = (close - zScoreMean) / zScoreStd
// Hurst Üsteli
hurstCalc() =>
float sumTau = 0.0
int count = 0
for lag = 2 to 10
diff = close - close[lag]
stdDiff = ta.stdev(diff, hurstLength)
if stdDiff > 0
sumTau := sumTau + math.sqrt(stdDiff)
count := count + 1
avgTau = count > 0 ? sumTau / count : 0.5
math.max(0.01, math.min(0.99, avgTau / 10))
hurstValue = hurstCalc()
// ═══════════════════════════════════════════════════════════
// S/R REFERANSLARI (DONCHIAN 50)
// ═══════════════════════════════════════════════════════════
// Düz çizgiler için Rolling 50 High/Low
res = ta.highest(high, 50)[1]
sup = ta.lowest(low, 50)[1]
mid = (res + sup) / 2
// Görselleştirme
plot(res, "Resistance", color=color.green, linewidth=1)
plot(sup, "Support", color=color.red, linewidth=1)
plot(mid, "Mid Line", color=color.gray, linewidth=1)
// ═══════════════════════════════════════════════════════════
// KELLY CRİTERİON
// ═══════════════════════════════════════════════════════════
kellyFraction() =>
r = kellyAvgWin / kellyAvgLoss
kelly = kellyWinRate - ((1 - kellyWinRate) / r)
math.max(0.01, math.min(0.25, kelly * 0.5))
positionSize = kellyFraction() * 100
// ═══════════════════════════════════════════════════════════
// SİNYAL HESAPLAMALARI
// ═══════════════════════════════════════════════════════════
isDeadZone = atrValue < (atrAvg * atrDeadZoneMultiplier)
isReversionZone = hurstValue < hurstReversionThreshold
isTrendZone = hurstValue > hurstTrendThreshold
// TREND Sinyalleri (Breakout)
// Fiyat direnci kırarsa Long, desteği kırarsa Short
trendLong = isTrendZone and rsiValue > 50 and adxValue > adxThreshold and close > res
trendShort = isTrendZone and rsiValue < 50 and adxValue > adxThreshold and close < sup
// REVERSION Sinyalleri (Fade / Dönüş)
// Fiyat çok yüksekse (Z>2) dirençten dönünce Short (veya direnç üzerindeyken)
// Fiyat çok düşükse (Z<-2) destekten dönünce Long
reversionShort = isReversionZone and zScore > zScoreLongThreshold and adxValue > adxThreshold and close > res
reversionLong = isReversionZone and zScore < zScoreShortThreshold and adxValue > adxThreshold and close < sup
// Final Sinyaller
longSignal = not isDeadZone and (reversionLong or trendLong)
shortSignal = not isDeadZone and (reversionShort or trendShort)
// ═══════════════════════════════════════════════════════════
// TRAILING STOP MANTIĞI
// ═══════════════════════════════════════════════════════════
var float trailingStop = na
// STRATEJİ GİRİŞ/ÇIKIŞ
if longSignal and strategy.position_size == 0
strategy.entry("Long", strategy.long, qty=positionSize, comment=reversionLong ? "Rev Long" : "Trend Long")
// Stop Belirleme
// Trend Long: Alt kanal (SUP) stop.
// Rev Long: Alt kanalın biraz altı (Esneklik payı)
trailingStop := reversionLong ? sup - (atrValue * 2) : sup
if shortSignal and strategy.position_size == 0
strategy.entry("Short", strategy.short, qty=positionSize, comment=reversionShort ? "Rev Short" : "Trend Short")
// Stop Belirleme
// Trend Short: Üst kanal (RES) stop.
// Rev Short: Üst kanalın biraz üstü (Esneklik payı)
trailingStop := reversionShort ? res + (atrValue * 2) : res
// Trailing Stop Güncelleme (Donchian Takibi)
if strategy.position_size > 0
// Long pozisyonda stop (SUP) yukarı çıkabilir ama aşağı inmez
if sup > trailingStop
trailingStop := sup
if close < trailingStop
strategy.close("Long", comment="Stop Hit")
if strategy.position_size < 0
// Short pozisyonda stop (RES) aşağı inebilir ama yukarı çıkmaz
if res < trailingStop
trailingStop := res
if close > trailingStop
strategy.close("Short", comment="Stop Hit")
// Trailing Stop çizgisi
plot(strategy.position_size != 0 ? trailingStop : na, "Trailing Stop", color=color.fuchsia, style=plot.style_stepline, linewidth=2)
// Sinyal işaretleri
plotshape(longSignal and strategy.position_size == 0, "Long", shape.triangleup, location.belowbar, color.lime, size=size.small)
plotshape(shortSignal and strategy.position_size == 0, "Short", shape.triangledown, location.abovebar, color.red, size=size.small)
bgcolor(isDeadZone ? color.new(color.gray, 90) : na, title="Ölü Bölge")
// ═══════════════════════════════════════════════════════════
// BİLGİ PANELİ
// ═══════════════════════════════════════════════════════════
var table panel = table.new(position.top_right, 2, 9, bgcolor=color.new(color.black, 80), border_width=1)
if barstate.islast
table.cell(panel, 0, 0, "QuantiFine v6 S/R", text_color=color.cyan, text_size=size.normal)
table.cell(panel, 1, 0, "DONCHIAN", text_color=color.yellow)
table.cell(panel, 0, 1, "RES / SUP", text_color=color.white)
table.cell(panel, 1, 1, str.tostring(res, "#.##") + " / " + str.tostring(sup, "#.##"), text_color=color.yellow)
table.cell(panel, 0, 2, "Hurst", text_color=color.white)
table.cell(panel, 1, 2, str.tostring(hurstValue, "#.##"), text_color=hurstValue > 0.5 ? color.green : color.orange)
table.cell(panel, 0, 3, "Rejim", text_color=color.white)
table.cell(panel, 1, 3, isTrendZone ? "TREND" : "REVERSION", text_color=isTrendZone ? color.green : color.orange)
table.cell(panel, 0, 4, "ADX", text_color=color.white)
table.cell(panel, 1, 4, str.tostring(adxValue, "#.#"), text_color=adxValue > adxThreshold ? color.green : color.gray)
table.cell(panel, 0, 5, "RSI", text_color=color.white)
table.cell(panel, 1, 5, str.tostring(rsiValue, "#.#"), text_color=rsiValue > 50 ? color.green : color.red)
table.cell(panel, 0, 6, "Z-Score", text_color=color.white)
table.cell(panel, 1, 6, str.tostring(zScore, "#.##"), text_color=zScore > 2 ? color.lime : zScore < -2 ? color.red : color.gray)
table.cell(panel, 0, 7, "ATR Filter", text_color=color.white)
table.cell(panel, 1, 7, isDeadZone ? "ÖLÜ BÖLGE" : "AKTİF", text_color=isDeadZone ? color.gray : color.green)
table.cell(panel, 0, 8, "Kelly %", text_color=color.white)
table.cell(panel, 1, 8, str.tostring(positionSize, "#.#") + "%", text_color=color.yellow)
Overview
QuantiFine v6 Pivot R2 S2 plots a 50-bar high and low as resistance and support lines and uses pivot-style levels for entries and stops, according to its header comments. A Kelly-style sizing input uses assumed win rate and average win and loss ratios. The inputs and labels are in Turkish, and the visible code shows no explicit stop.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
ATR Periyodu
int
14
atrLength
ADX Periyodu
int
14
adxLength
RSI Periyodu
int
14
rsiLength
Hurst Penceresi
int
20
hurstLength
Z-Score Penceresi
int
20
zScoreLength
ADX Eşiği
float
20
adxThreshold
Z-Score Long Eşiği
float
2.0
zScoreLongThreshold
Z-Score Short Eşiği
float
-2.0
zScoreShortThreshold
Hurst Reversion Eşiği (<)
float
0.48
hurstReversionThreshold
Hurst Trend Eşiği (>)
float
0.52
hurstTrendThreshold
ATR Ölü Bölge Çarpanı
float
0.5
atrDeadZoneMultiplier
Win Rate
float
0.55
kellyWinRate
Show all 14 settings
Setting
Type
Default
Variable
Avg Win Ratio
float
1.5
kellyAvgWin
Avg Loss Ratio
float
1.0
kellyAvgLoss
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
The Chained Linear Regression Reversal Strategy plots linear regression channels with upper and lower standard deviation bands directly on the price chart across a user-defined time window. When price breaks out of the static channel for a confirmed number of
RG Structure v2.0 [Visual Edition] is a strategy that identifies pivot points over a lookback window to construct trendlines. It evaluates breaks and retests of these trendlines using scoring weights, violation penalties, and regime detection to generate entry
This strategy identifies pivot-based Darvas Box levels on the price chart and trades re-entries following box sweeps. A long position arms when the price dips below the lower boundary and triggers when it closes back inside, provided the price is above a highe
This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr
This strategy calculates Bollinger Bands and Aroon oscillator values to identify mean-reversion opportunities. It enters a long position using full equity when the closing price crosses below the lower Bollinger Band while Aroon Up remains above a user-specifi
Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish