Strategy · Pine Script v5 · On the chart

QuantiFine v6 Pivot R2 S2

by cinarunver

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.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code186
Settings14inputs
LicenceMIT
Last update4 months ago6 Jun 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

186 lines of Pine Script v5 from v6_oyun_alanı/quantifine_v6_strategy.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

quantifine_v6_strategy.pine
// 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.

Details

Published by

cinarunver on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Mean reversion, Trend, Support & resistance

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
ATR Periyoduint14atrLength
ADX Periyoduint14adxLength
RSI Periyoduint14rsiLength
Hurst Penceresiint20hurstLength
Z-Score Penceresiint20zScoreLength
ADX Eşiğifloat20adxThreshold
Z-Score Long Eşiğifloat2.0zScoreLongThreshold
Z-Score Short Eşiğifloat-2.0zScoreShortThreshold
Hurst Reversion Eşiği (<)float0.48hurstReversionThreshold
Hurst Trend Eşiği (>)float0.52hurstTrendThreshold
ATR Ölü Bölge Çarpanıfloat0.5atrDeadZoneMultiplier
Win Ratefloat0.55kellyWinRate
Show all 14 settings
SettingTypeDefaultVariable
Avg Win Ratiofloat1.5kellyAvgWin
Avg Loss Ratiofloat1.0kellyAvgLoss
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.

Similar Pine Scripts

1 stars

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

Strategy v6 Support & resistanceBreakout
Updated 2 months ago · None stated GitHub repository of TN Sovereign Darvas Box v6

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

Strategy v6 BreakoutTrend
Updated yesterday · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout
330 stars

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

Strategy v5 Mean reversionVolatility & bands
Updated 2 months ago · None stated GitHub repository of Bollinger bands + Aroon [Alorse]
285 stars

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

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers