
이 전략은 RSI와 MACD 이중 기술 지표에 기반한 자동화 거래 전략이다. 이 전략은 오버 바이 오버 셀 신호와 트렌드 확인을 결합하여 잠재적인 거래 기회를 식별하여 시장에 대한 정확한 파악을 가능하게 한다. 이 전략은 비율 포지션 관리를 채택하고, 슬라이드 포인트 방지 메커니즘이 내장되어 있어 실용성과 적응성이 강하다.
이 전략의 핵심 논리는 다음과 같은 핵심 요소에 기반합니다.
이 전략은 RSI와 MACD의 연동 작용을 통해 비교적 안정적인 거래 시스템을 구축한다. 약간의 뒤처진 위험이 있지만, 합리적인 위험 제어와 매개 변수 최적화를 통해 전략은 여전히 좋은 실용적 가치를 가지고 있다. 실제 적용 전에 충분한 재검토를 수행하고 특정 시장 특성에 따라 타겟팅 된 최적화를 수행하는 것이 좋습니다.
//@version=6
strategy("Debugging Demo GPT",
overlay=true,
initial_capital=100,
default_qty_type=strategy.percent_of_equity,
default_qty_value=3,
pyramiding=1,
calc_on_order_fills=true,
calc_on_every_tick=true,
slippage=3)
// -----------------------------------------------------------------------
// (1) Inputs: Start and End Date
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// (2) Indicators (RSI, MACD)
// -----------------------------------------------------------------------
// === RSI ===
rsiLen = input.int(14, "RSI Length")
rsiOB = input.int(80, "RSI Overbought")
rsiOS = input.int(20, "RSI Oversold")
rsiVal = ta.rsi(close, rsiLen)
// === MACD ===
fastLen = input.int(12, "MACD Fast Length")
slowLen = input.int(26, "MACD Slow Length")
sigLen = input.int(9, "MACD Signal Length")
[macdLine, sigLine, histLine] = ta.macd(close, fastLen, slowLen, sigLen)
// -----------------------------------------------------------------------
// (3) Trading Logic: LONG/SHORT Filters
// -----------------------------------------------------------------------
bool rsiLongOk = (rsiVal < rsiOB)
bool rsiShortOk = (rsiVal > rsiOS)
bool macdLongOk = (macdLine > sigLine)
bool macdShortOk = (macdLine < sigLine)
bool longCondition = rsiLongOk and macdLongOk
bool shortCondition = rsiShortOk and macdShortOk
// -----------------------------------------------------------------------
// (4) Entry Conditions
// -----------------------------------------------------------------------
// Debugging: Visualizing the conditions
plotshape(series=longCondition, location=location.belowbar, color=color.blue, style=shape.circle, title="LongCondition", size=size.tiny)
plotshape(series=shortCondition, location=location.abovebar, color=color.orange, style=shape.circle, title="ShortCondition", size=size.tiny)
// Entries only when all conditions are met
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
// -----------------------------------------------------------------------
// (5) Plotting for Visualization
// -----------------------------------------------------------------------
// RSI Plots
hline(rsiOB, "RSI Overbought", color=color.red, linestyle=hline.style_dotted)
hline(rsiOS, "RSI Oversold", color=color.green, linestyle=hline.style_dotted)
plot(rsiVal, title="RSI", color=color.purple)
// MACD Plots
plot(macdLine, color=color.teal, title="MACD Line")
plot(sigLine, color=color.orange, title="MACD Signal")
plot(histLine, style=plot.style_histogram, color=(histLine >= 0 ? color.lime : color.red), title="MACD Histogram")