
이 전략은 무작위 지표 (Stochastic) 를 기반으로 한 이중 시간 주기의 동적 거래 시스템이다. 동적 원칙과 트렌드 추적 방법을 결합하여 더 정확한 시장 추세 판단과 거래 시기를 파악하는 동시에 다른 시간 주기에 무작위 지표의 교차 신호를 분석하여 잠재적 인 거래 기회를 식별합니다. 이 전략은 또한 더 나은 자금 관리를 위해 스톱 스톱 손실 설정을 포함한 위험 관리 메커니즘을 통합합니다.
전략의 핵심 논리는 다음과 같은 핵심 요소에 기초합니다.
이 전략의 장점은 여러 확인 메커니즘과 완벽한 위험 통제에 있습니다. 그러나 가짜 돌파구 및 변수 민감성 등의 위험에 주의를 기울여야 합니다. 지속적인 최적화 및 개선으로 이 전략은 더 나은 거래 효과를 달성 할 수 있습니다.
/*backtest
start: 2024-12-04 00:00:00
end: 2024-12-11 00:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced Stochastic Strategy", overlay=true)
// Input untuk Stochastic
length = input.int(14, title="Length", minval=1)
OverBought = input(80, title="Overbought Level")
OverSold = input(20, title="Oversold Level")
smoothK = input.int(3, title="Smooth %K")
smoothD = input.int(3, title="Smooth %D")
// Input untuk Manajemen Risiko
tpPerc = input.float(2.0, title="Take Profit (%)", step=0.1)
slPerc = input.float(1.0, title="Stop Loss (%)", step=0.1)
// Hitung Stochastic
k = ta.sma(ta.stoch(close, high, low, length), smoothK)
d = ta.sma(k, smoothD)
// Logika Sinyal
co = ta.crossover(k, d) // %K memotong %D ke atas
cu = ta.crossunder(k, d) // %K memotong %D ke bawah
longCondition = co and k < OverSold
shortCondition = cu and k > OverBought
// Harga untuk TP dan SL
var float longTP = na
var float longSL = na
var float shortTP = na
var float shortSL = na
if (longCondition)
longTP := close * (1 + tpPerc / 100)
longSL := close * (1 - slPerc / 100)
strategy.entry("Buy", strategy.long, comment="StochLE")
strategy.exit("Sell Exit", "Buy", limit=longTP, stop=longSL)
if (shortCondition)
shortTP := close * (1 - tpPerc / 100)
shortSL := close * (1 + slPerc / 100)
strategy.entry("Sell", strategy.short, comment="StochSE")
strategy.exit("Buy Exit", "Sell", limit=shortTP, stop=shortSL)
// Plot Stochastic dan Level
hline(OverBought, "Overbought", color=color.red, linestyle=hline.style_dotted)
hline(OverSold, "Oversold", color=color.green, linestyle=hline.style_dotted)
hline(50, "Midline", color=color.gray, linestyle=hline.style_dotted)
plot(k, color=color.blue, title="%K")
plot(d, color=color.orange, title="%D")
// Tambahkan sinyal visual
plotshape(longCondition, title="Buy Signal", location=location.belowbar, style=shape.labelup, color=color.new(color.green, 0), text="BUY")
plotshape(shortCondition, title="Sell Signal", location=location.abovebar, style=shape.labeldown, color=color.new(color.red, 0), text="SELL")