듀얼 MA 주식 지표 컴보 거래 전략

저자:차오장, 날짜: 2023-09-12 14:44:56
태그:

이 전략은 유동 평균과 스톡 지표를 트렌드 추적 및 과잉 구매/ 과잉 판매 탐지 기능을 모두 갖춘 양적 거래 시스템으로 결합합니다. 체계적인 트렌드 식별 및 기회 포착을 위해 여러 지표의 장점을 통합합니다.

전략 논리:

  1. 트렌드 방향을 결정하기 위해 장기 MA와 단기 EMA를 계산합니다.

  2. 과잉 구매/ 과잉 판매 수준을 확인하기 위해 주식 K 및 D 값을 계산합니다.

  3. CLOSE가 MA를 넘어서고 K&D가 과잉 매수선 위에 있을 때,

  4. CLOSE가 EMA 아래로 넘어갈 때, 그리고 K&D가 과잉판매 라인 아래로 넘어갈 때,

  5. 결정된 무역 방향을 표시하기 위해 COLOR를 사용하세요.

장점:

  1. 이중 MAs는 트렌드 정확성을 향상시키고 잘못된 신호를 피합니다.

  2. 스톡은 높은 확률의 구매/판매 구역을 식별합니다.

  3. 지표를 결합하면 검증을 통해 신뢰성을 향상시킵니다.

위험성:

  1. 패러미터 조정이 안되면 신호가 너무 많거나 불일치합니다.

  2. MAs와 Stoch 모두 지연이 있을 수 있어 조기 또는 지연된 출입을 유발할 수 있습니다.

  3. 더 많은 지표는 신뢰성 향상에도 불구하고 더 복잡한 것을 의미합니다.

요약하자면, 이 전략은 트렌드를 위한 MAs와 과잉 구매/ 과잉 판매 수준을 위한 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)
    





더 많은