이 전략은 평균선 지표와 스토흐 지표를 조합하여 트렌드 판단과 오버 바이 오버 셀 판단 기능을 갖춘 정량 거래 시스템을 설계합니다. 이 전략은 여러 지표의 장점을 통합하여 체계화된 트렌드 판단과 기회를 포착합니다.
전략적 원칙:
중장기 평균선 ((MA) 과 단기 평균선 ((EMA) 을 계산하여 트렌드 방향을 결정하는 기술 지표로 사용한다.
스토흐 K값과 D값을 계산하여 과매매 또는 과매매 상태가 아닌지 판단한다.
CLOSE가 MA를 아래에서 위로 돌파하고, Stoch K 값과 D 값이 모두 초매선보다 높을 때, 긴 선으로 입점할 때, 더 많이 한다.
CLOSE가 상향 하향으로 EMA를 돌파하고, Stoch K 값과 D 값이 초매매 라인보다 낮을 때, 짧은 라인 진입 시점으로 판단하고, 공백한다.
COLOR으로 판단되는 거래 방향
이 전략의 장점:
쌍평선 조합은 주 트렌드 방향을 판단하여 잘못된 신호를 피할 수 있다.
Stoch 지표는 과매도 지역을 식별하여 수익률을 높인다.
복합적으로 여러 지표를 사용해서 서로 검증할 수 있고, 신호의 신뢰성을 증가시킨다.
이 전략의 위험은:
변수 최적화가 잘못되면 거래 빈도나 신호 불일치가 발생할 수 있다.
평균선과 스토흐 모두 미지수 상태가 발생하여 초과 또는 늦은 진입이 발생할 수 있습니다.
다중 지표 조합은 신뢰성을 높이는 동시에 전략의 복잡성을 증가시킵니다.
요약하자면, 이 전략은 평균선 판단 경향을 적용하여, 스토흐 판단 과매매 과매매, 양적 거래를 한다. 매개 변수 조정 최적화를 전제로, 거래 시스템의 안정성과 신뢰성을 향상시킬 수 있다. 그러나 모든 양적 전략은 엄격한 위험 관리가 필요하며, 투자자는 여전히 신중한 판단을 사용해야 한다.
/*backtest
start: 2023-08-12 00:00:00
end: 2023-09-11 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
// strategy("PMB2", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 20, initial_capital=1000, currency=currency.USD)
//study(title="PMB2", overlay=true)
l_ma = input(50, title="MA (green)", type=input.integer)
l_ema = input(25, title="EMA (red)", type=input.integer)
MA = sma(close,l_ma)
EMA = ema(close,l_ema)
plot(MA, color=color.green)
plot(EMA, color=color.red)
//STOCH(14,3,3)
length = input(20, minval=1, title="STOCH - K")
smoothK = input(2, minval=1, title="STOCH - D")
smoothD = input(2 , minval=1, title="STOCH - Smooth")
StkLong= input(50 , minval=1, maxval=100, title="Long when Close > MA and Stoch > ")
StkShort= input(80 , minval=1, maxval=100, title="Short when Close < EMA and Stoch < ")
k = sma(stoch(close, high, low, length), smoothK)
d = sma(k, smoothD)
//plot(k, color=color.blue, title="STOCH - K")
//plot(d, color=color.orange, title="STOCH - D")
//band180 = hline(80, title="STOCH - Banda superior")
//band120 = hline(20, title="STOCH - Banda superior")
//band100 = hline(50, color=color.gray, editable=false, linestyle=hline.style_solid)
//fill(band180, band120, color=color.gray, transp=75, title="STOCH - Fundo")
BTStartY = input(title="Strategy Test Start Year", type=input.integer, defval=2019, minval=2010, maxval=2100)
BTStartM = input(title="Strategy Test Start Month", type=input.integer, defval=1, minval=1, maxval=12)
BTStartD = input(title="Strategy Test Start Day", type=input.integer, defval=1, minval=1, maxval=31)
BTStopY = input(title="Strategy Test Stop Year", type=input.integer, defval=2019, minval=2010, maxval=2100)
BTStopM = input(title="Strategy Test Stop Month", type=input.integer, defval=12, minval=1, maxval=12)
BTStopD = input(title="Strategy Test Stop Day", type=input.integer, defval=31, minval=1, maxval=31)
// set up min and max date for strategy test
TMin = timestamp(BTStartY, BTStartM, BTStartD, 00, 00)
TMax = timestamp(BTStopY, BTStopM, BTStopD, 00, 00)
InTime = true
bool long = false, short = false, trade = false
trade := trade[1]
long := long[1]
short := short[1]
if (crossover(close, MA) and k > StkLong and d > StkLong) // "LONG!"
//if (close > MA and k > StkLong and d > StkLong) // "LONG!"
short := false
long := true
trade := true // LONG
if (crossunder(close, EMA) and k < StkShort and d < StkShort) // "SHORT!""
//if (close < EMA and k < StkShort and d < StkShort) // "SHORT!""
long := false
short := true
trade := false // SHORT
//bgcolor(FL > SH ? color.green : FH < SL ? color.red : na, transp=80)
bgcolor(trade ? color.green : color.red, transp=90)
//alertcondition((crossover(close, MA) and k > 50 and d > 50) , title='Buy', message='Buy')
//alertcondition((crossunder(close, EMA) and k > 80 and d > 80) , title='Sell', message='Sell')
if ((crossover(close, MA) and k > StkLong and d > StkLong) and InTime)
//if ((close > MA and k > StkLong and d > StkLong) and InTime)
strategy.entry("Long", strategy.long)
if ((crossunder(close, EMA) and k < StkShort and d < StkShort) and InTime)
//if ((close < EMA and k < StkShort and d < StkShort) and InTime)
strategy.entry("Short", strategy.short)