
이 전략은 상대적으로 약한 지수 ((RSI) 를 기반으로 한 지능형 거래 시스템으로, 여러 가지 이동 평균과 브린 밴드 지표를 결합하여 시장의 과매매 과매매 영역을 식별하여 선택 시 거래합니다. 전략의 핵심은 RSI의 돌파구 및 역전 신호를 통해 다양한 유형의 이동 평균과 함께 트렌드 확인을 수행하여 효율적인 진영을 수행합니다. 이 전략은 강력한 적응력을 가지고 있으며, 다른 시장 환경에 따라 파라미터를 조정할 수 있습니다.
이 전략은 14주기 RSI를 핵심 지표로 사용하고 RSI와 30/70의 두 가지 핵심 수준이 교차하는 상황을 모니터링하여 거래 신호를 생성합니다. RSI가 30을 넘어서면, 시스템은 시장이 과매매에서 낙점으로 전환되었다고 판단하여 다중 신호를 유발합니다. RSI가 70을 넘어서면, 시스템은 시장이 과매에서 낙점으로 전환되었다고 판단하여 평지 신호를 유발합니다. 동시에, 전략은 여러 가지 평균선 (SMA, EMA, SMMA, WMA, VMA) 과 부린 밴드를 보조 지표로 도입하여 트렌드 방향과 시장 변동성을 확인합니다.
이 전략은 RSI 지표를 통해 시장의 과매매 기회를 포착하고, 여러 가지 기술 지표와 결합하여 신호 확인을 수행하며, 실용성과 신뢰성을 갖는다. 전략 설계는 위험 제어를 충분히 고려하고, 매개 변수 최적화 및 지표 조합을 통해 다양한 시장 환경에 적응할 수 있다. 거래자는 실제 사용 전에 충분한 피드백 검증을 수행하고, 특정 시장 특성에 따라 매개 변수 설정을 조정하는 것이 좋습니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="Demo GPT - Relative Strength Index", shorttitle="RSI Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_value=0.1, slippage=3)
// Inputs
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
calculateDivergence = input.bool(false, title="Calculate Divergence", group="RSI Settings", tooltip="Calculating divergences is needed in order for divergence alerts to fire.")
// RSI Calculation
change = ta.change(rsiSourceInput)
up = ta.rma(math.max(change, 0), rsiLengthInput)
down = ta.rma(-math.min(change, 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
// RSI Plots
rsiPlot = plot(rsi, "RSI", color=#7E57C2)
rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
plot(50, color=na, editable=false, display=display.none)
// Moving Averages
maTypeInput = input.string("SMA", "Type", options=["None", "SMA", "SMA + Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Moving Average")
maLengthInput = input.int(14, "Length", group="Moving Average")
bbMultInput = input.float(2.0, "BB StdDev", minval=0.001, maxval=50, step=0.5, group="Moving Average")
enableMA = maTypeInput != "None"
isBB = maTypeInput == "SMA + Bollinger Bands"
// MA Calculation
ma(source, length, MAtype) =>
switch MAtype
"SMA" => ta.sma(source, length)
"SMA + Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
smoothingMA = enableMA ? ma(rsi, maLengthInput, maTypeInput) : na
smoothingStDev = isBB ? ta.stdev(rsi, maLengthInput) * bbMultInput : na
plot(smoothingMA, "RSI-based MA", color=color.yellow, display=enableMA ? display.all : display.none)
bbUpperBand = plot(smoothingMA + smoothingStDev, title="Upper Bollinger Band", color=color.green, display=isBB ? display.all : display.none)
bbLowerBand = plot(smoothingMA - smoothingStDev, title="Lower Bollinger Band", color=color.green, display=isBB ? display.all : display.none)
fill(bbUpperBand, bbLowerBand, color=isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill", display=isBB ? display.all : display.none)
// Trade Logic
longCondition = ta.crossover(rsi, 30)
exitCondition = ta.crossunder(rsi, 70)
// Start Date & End Date
startDate = input(timestamp("2018-01-01 00:00"), "Start Date", group="Date Range")
endDate = input(timestamp("2069-12-31 23:59"), "End Date", group="Date Range")
inDateRange = true
// Execute Trades
if (longCondition and inDateRange)
strategy.entry("Long", strategy.long)
if (exitCondition and inDateRange)
strategy.close("Long")