
이동 평균 및 상대적으로 약한 지표 전략 (영어: Moving Average Relative Strength Index Strategy) 은 이동 평균과 상대적으로 강한 지표를 동시에 거래 신호로 사용하는 정량 거래 전략이다. 이 전략은 가격의 이동 평균과 상대적으로 강한 지표의 수치를 비교하여 거래 신호를 생성하여 시장 추세에서 기회를 잡는다.
이 전략은 크게 두 가지 지표에 기반을 두고 있습니다.
이 전략의 핵심 논리는 다음과 같습니다.
RSI 지표선이 이동 평균보다 낮으면 과매매 지역으로 간주되며, 주식이 과소 평가되어 구매 신호를 발생시킵니다. RSI 지표선이 이동 평균보다 높으면 과매매 지역으로 간주되며, 주식이 과대 평가되어 판매 신호를 발생시킵니다.
즉, 이동 평균은 주식의 공정 가치를 어느 정도 반영하고 RSI 지표는 주식의 현재 강점을 나타냅니다. RSI 지표는 이동 평균보다 높거나 낮다는 것은 역전 가능성이 있음을 의미합니다.
특히, 이 전략은 다음과 같은 단계를 통해 거래 신호를 생성합니다.
이 전략은 이동 평균의 트렌드 판단과 RSI 지표의 과매매 판단을 결합하여, 서로 다른 지표의 장점을 종합적으로 활용하여 시장의 전환점을 효과적으로 판단할 수 있다.
주요 장점은:
이 전략에는 몇 가지 위험도 있습니다.
위험을 통제하기 위해, 다음과 같은 방법으로 최적화할 수 있습니다.
이 전략은 다음과 같은 방향으로 더 개선될 수 있습니다.
매개 변수 최적화, 지표 최적화, 위험 관리 최적화 등을 통해 전략의 안정성과 수익성을 지속적으로 향상시킬 수 있다.
이동 평균과 상대적으로 강한 지표 전략은 가격 경향 판단과 과매매 과매매 판단을 동시에 활용하여 시장 전환점을 효과적으로 판단하고 역전 기회를 잡을 수 있습니다. 이 전략은 간단하고 실용적이며, 위험이 제어 가능하며, 실용적인 양적 거래 전략입니다. 지속적인 최적화를 통해 더 뛰어난 효과를 얻을 수 있습니다.
/*backtest
start: 2023-11-20 00:00:00
end: 2023-11-24 06:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy(title = "RSI versus SMA", shorttitle = "RSI vs SMA", overlay = false, pyramiding = 0, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, currency = currency.GBP)
// Revision: 1
// Author: @JayRogers
//
// *** USE AT YOUR OWN RISK ***
// - Nothing is perfect, and all decisions by you are on your own head. And stuff.
//
// Description:
// - It's RSI versus a Simple Moving Average.. Not sure it really needs much more description.
// - Should not repaint - Automatically offsets by 1 bar if anything other than "open" selected as RSI source.
// === INPUTS ===
// rsi
rsiSource = input(defval = open, title = "RSI Source")
rsiLength = input(defval = 8, title = "RSI Length", minval = 1)
// sma
maLength = input(defval = 34, title = "MA Period", minval = 1)
// invert trade direction
tradeInvert = input(defval = false, title = "Invert Trade Direction?")
// risk management
useStop = input(defval = false, title = "Use Initial Stop Loss?")
slPoints = input(defval = 25, title = "Initial Stop Loss Points", minval = 1)
useTS = input(defval = true, title = "Use Trailing Stop?")
tslPoints = input(defval = 120, title = "Trail Points", minval = 1)
useTSO = input(defval = false, title = "Use Offset For Trailing Stop?")
tslOffset = input(defval = 20, title = "Trail Offset Points", minval = 1)
// === /INPUTS ===
// === BASE FUNCTIONS ===
// delay for direction change actions
switchDelay(exp, len) =>
average = len >= 2 ? sum(exp, len) / len : exp[1]
up = exp > average
down = exp < average
state = up ? true : down ? false : up[1]
// === /BASE FUNCTIONS ===
// === SERIES and VAR ===
// rsi
shunt = rsiSource == open ? 0 : 1
rsiUp = rma(max(change(rsiSource[shunt]), 0), rsiLength)
rsiDown = rma(-min(change(rsiSource[shunt]), 0), rsiLength)
rsi = (rsiDown == 0 ? 100 : rsiUp == 0 ? 0 : 100 - (100 / (1 + rsiUp / rsiDown))) - 50 // shifted 50 points to make 0 median
// sma of rsi
rsiMa = sma(rsi, maLength)
// self explanatory..
tradeDirection = tradeInvert ? 0 <= rsiMa ? true : false : 0 >= rsiMa ? true : false
// === /SERIES ===
// === PLOTTING ===
barcolor(color = tradeDirection ? green : red, title = "Bar Colours")
// hlines
medianLine = hline(0, title = 'Median', color = #996600, linewidth = 1)
limitUp = hline(25, title = 'Limit Up', color = silver, linewidth = 1)
limitDown = hline(-25, title = 'Limit Down', color = silver, linewidth = 1)
// rsi and ma
rsiLine = plot(rsi, title = 'RSI', color = purple, linewidth = 2, style = line, transp = 50)
areaLine = plot(rsiMa, title = 'Area MA', color = silver, linewidth = 1, style = area, transp = 70)
// === /PLOTTING ===
goLong() => not tradeDirection[1] and tradeDirection
killLong() => tradeDirection[1] and not tradeDirection
strategy.entry(id = "Buy", long = true, when = goLong())
strategy.close(id = "Buy", when = killLong())
goShort() => tradeDirection[1] and not tradeDirection
killShort() => not tradeDirection[1] and tradeDirection
strategy.entry(id = "Sell", long = false, when = goShort())
strategy.close(id = "Sell", when = killShort())
if (useStop)
strategy.exit("XSL", from_entry = "Buy", loss = slPoints)
strategy.exit("XSS", from_entry = "Sell", loss = slPoints)
// if we're using the trailing stop
if (useTS and useTSO) // with offset
strategy.exit("XSL", from_entry = "Buy", trail_points = tslPoints, trail_offset = tslOffset)
strategy.exit("XSS", from_entry = "Sell", trail_points = tslPoints, trail_offset = tslOffset)
if (useTS and not useTSO) // without offset
strategy.exit("XSL", from_entry = "Buy", trail_points = tslPoints)
strategy.exit("XSS", from_entry = "Sell", trail_points = tslPoints)