
이 전략은 QQE(Quick Quiet Exponent) 지표를 기반으로 하는 추세 추종 시스템과 동적 위험 관리 메커니즘을 결합한 것입니다. 전략의 핵심은 QQE 고속선과 저속선의 교차점을 통해 시장 동향을 포착하고 ATR(평균 진폭)을 사용하여 손절매와 이익실현 포지션을 동적으로 조정하여 최적의 위험-수익 구성을 달성하는 것입니다. 전략에는 계정 위험 관리 및 포지션 관리 기능도 포함되어 있으며, 이를 통해 계정 자본에 따라 개방형 포지션 수를 자동으로 조정할 수 있습니다.
이 전략은 주로 신호 생성, 위험 관리, 위치 제어라는 세 가지 핵심 모듈로 구성됩니다. 신호 생성 모듈은 QQE 지표를 기반으로 합니다. RSI의 지수 이동 평균(EMA)을 계산하여 빠른 라인(QQEF)을 얻고, ATRRSI와 결합하여 느린 라인(QQES)을 계산합니다. QQEF가 QQES를 위쪽으로 교차할 때 긴 신호가 생성되고, 아래쪽으로 교차할 때 짧은 신호가 생성됩니다. 위험 관리 모듈은 ATR을 사용하여 손절매 및 이익 실현 포지션을 동적으로 계산하고, 추적 손절매 메커니즘을 적용하여 수익을 보호합니다. 포지션 제어 모듈은 사전 설정된 위험 비율과 현재 계좌 자본금을 기준으로 개방 포지션 수를 계산합니다.
이 전략은 QQE 지표를 완전한 거래 시스템으로 전환하여 추세 추적과 위험 관리의 유기적인 결합을 실현합니다. 해당 전략은 합리적으로 설계되었으며 실용성과 확장성이 뛰어납니다. 합리적인 매개변수 최적화와 위험 관리를 통해 이 전략은 다양한 시장 환경에서 안정적인 성과를 유지할 수 있습니다. 실제 거래에서 이를 사용하는 경우, 거래자는 충분한 백테스팅과 매개변수 최적화를 수행하는 것이 좋습니다.
/*backtest
start: 2024-12-17 00:00:00
end: 2025-01-16 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © seckinduran
//@version=5
strategy("QQE Strategy with Risk Management", overlay=true)
// Girdi Parametreleri
src = input(close, title="Source")
length = input.int(14, title="RSI Length", minval=1)
SSF = input.int(5, title="SF RSI Smoothing Factor", minval=1)
riskPercentage = input.float(1.0, title="Risk Percentage per Trade", minval=0.1, maxval=10.0)
// Trailing Stop ve Stop Loss Parametreleri
stopLossMultiplier = input.float(title="Stop Loss Katsayısı", defval=1.5)
takeProfitMultiplier = input.float(title="Take Profit Katsayısı", defval=3)
trailStopMultiplier = input.float(title="Trailing Stop Katsayısı", defval=1.5)
// QQE Hesaplamaları
RSII = ta.ema(ta.rsi(src, length), SSF)
TR = math.abs(RSII - RSII[1])
wwalpha = 1 / length
WWMA = ta.ema(TR, length)
ATRRSI = ta.ema(WWMA, length)
QQEF = ta.ema(ta.rsi(src, length), SSF)
QUP = QQEF + ATRRSI * 4.236
QDN = QQEF - ATRRSI * 4.236
QQES = 0.0
QQES := QUP < nz(QQES[1]) ? QUP : QQEF > nz(QQES[1]) and QQEF[1] < nz(QQES[1]) ? QDN : QDN > nz(QQES[1]) ? QDN : QQEF < nz(QQES[1]) and QQEF[1] > nz(QQES[1]) ? QUP : nz(QQES[1])
// Çizgileri Görselleştirme
plot(QQEF, "FAST", color=color.maroon, linewidth=2)
plot(QQES, "SLOW", color=color.blue, linewidth=1)
// Alım ve Satım Koşulları
longCondition = ta.crossover(QQEF, QQES) // Hızlı çizgi yavaş çizgiyi yukarı keserse
shortCondition = ta.crossunder(QQEF, QQES) // Hızlı çizgi yavaş çizgiyi aşağı keserse
// ATR Hesaplaması
atrValue = ta.atr(14) // ATR hesaplaması burada
// Pozisyon Büyüklüğü Hesaplama
tradeSize = strategy.equity / close
riskSize = (strategy.equity * riskPercentage / 100) / close
leverageSize = math.max(1, riskSize) // Negatif değerleri engellemek için doğrulama
// Pozisyon Açma
if (longCondition)
strategy.entry("Buy", strategy.long, qty=leverageSize, stop=close - (atrValue * stopLossMultiplier), limit=close + (atrValue * takeProfitMultiplier), comment="Long Entry")
if (shortCondition)
strategy.entry("Sell", strategy.short, qty=leverageSize, stop=close + (atrValue * stopLossMultiplier), limit=close - (atrValue * takeProfitMultiplier), comment="Short Entry")
// Çıkış Koşulları: Trailing Stop
if (strategy.position_size > 0)
strategy.exit("Trail Exit Long", from_entry="Buy", trail_price=close - atrValue * trailStopMultiplier, trail_offset=atrValue * stopLossMultiplier, limit=close + atrValue * takeProfitMultiplier)
if (strategy.position_size < 0)
strategy.exit("Trail Exit Short", from_entry="Sell", trail_price=close + atrValue * trailStopMultiplier, trail_offset=atrValue * stopLossMultiplier, limit=close - atrValue * takeProfitMultiplier)
// Pozisyon Kapatma Koşulları
if (ta.crossunder(close, QQES))
strategy.close("Buy") // Long pozisyonu kapat
if (ta.crossover(close, QQEF))
strategy.close("Sell") // Short pozisyonu kapat
// Ekstra Görselleştirme (Trend Renkleri)
longFillColor = QQEF > QQES ? color.new(color.green, 80) : na
shortFillColor = QQEF < QQES ? color.new(color.red, 80) : na
fill(plot1=plot(QQEF, display=display.none), plot2=plot(QQES, display=display.none), color=longFillColor, title="Uptrend Fill")
fill(plot1=plot(QQEF, display=display.none), plot2=plot(QQES, display=display.none), color=shortFillColor, title="Downtrend Fill")