다중 지표 통합에 기반한 전략에 따른 경향

저자:차오장, 날짜: 2023-09-13 17:16:51
태그:

이 전략은 Trend Following Strategy Based on Multiple Indicator Integration (다중 지표 통합에 기반한 트렌드 다음 전략) 라고 불립니다. 이는 RSI, ADX 및 MACD 지표를 결합하여 상승 추세를 확인한 후 오랫동안 이동하고 하락 추세를 확인한 후 포지션을 닫습니다.

RSI 지표는 과잉 구매/ 과잉 판매 상태를 결정합니다. RSI가 30을 넘으면 긴 진입을 고려하여 과잉 판매의 끝을 나타냅니다. RSI가 70 플래그 이하를 넘으면 포지션 폐쇄를 고려하여 과잉 구매의 끝을 나타냅니다.

ADX 지표는 트렌드 강도를 측정합니다. ADX가 25을 넘으면 트렌드에 들어가는 것을 의미하며, 25을 넘으면 트렌드가 끝나는 것을 나타냅니다.

MACD는 단기 트렌드를 판단합니다. DIFF가 DEA를 넘으면 긴 진입을 고려하여 단기 상승 추세를 나타냅니다. 깃발 아래를 넘으면 단기 하락 추세를 나타냅니다.

RSI, ADX 및 MACD가 모두 상승 시그널을 표시하면 긴 거래가 이루어집니다. 모든 것이 트렌드 종료를 표시하면 포지션은 닫습니다.

장점은 확인을 위해 여러 지표를 사용하는 것이 잘못된 신호를 효과적으로 방지 할 수 있습니다. 그러나 매개 변수는 개별 최적화가 필요하며 중지 손실은 필수적입니다.

요약하자면, 지표 통합은 판단의 효과를 향상시키지만, 거래자는 여전히 실제 조건에 따라 전략 매개 변수를 조정하고 검증할 수 있는 재량력이 필요합니다.


/*backtest
start: 2023-09-05 00:00:00
end: 2023-09-08 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// RSI
//@version=3
// strategy("Femi Strategy", overlay=true)
strategy("Femi Strategy", overlay=false)
RSIlength = input( 14 )
overSold = input( 30 )
overBought = input( 70 )
price = close

vrsi = rsi(price, RSIlength)



//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)





// ADX

//@version=3
adxlen = input(14)
dilen = input(14)
adxThreshold = input( 25 )
dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

sig = adx(dilen, adxlen)


// MACD
//@version=3
MACDZero = input(0)
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)

MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD



source = close
length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50)

basis = sma(source, length)
dev = mult * stdev(source, length)

upper = basis + dev
lower = basis - dev

if (not na(vrsi))
    if (crossover(delta, MACDZero))
        strategy.entry("FEMIMACDLE", strategy.long, comment="FEMIMACDLE")
    else
        strategy.cancel(id="FEMIMACDLE")
        
    
    if (crossunder(vrsi, overSold))
        strategy.entry("FEMIRSILE", strategy.long, comment="FEMIRSILE")
    else
        strategy.cancel(id="FEMIRSILE")
        
        
    // if(crossover(sig, adxThreshold)) // crossover(sig, adxThreshold) crossover(delta, MACDZero) crossunder(vrsi, overSold)
    //     strategy.entry("FEMIADXLE", strategy.long, comment="FEMIADXLE")
    // else
    //     strategy.cancel(id="FEMIADXLE")
        
        
    // if (crossover(source, lower))
    //     strategy.entry("FEMIBBLE", strategy.long, comment="FEMIBBLE")
    // else
    //     strategy.cancel(id="FEMIBBLE")
        
    // if(crossunder(sig, adxThreshold))
        // strategy.cancel(id="FEMILE")
        // strategy.exit(id="FEMILE")
        
    // if (crossunder(delta, MACDZero))
        // strategy.entry("FEMIMACDSE", strategy.short, comment="FEMIMACDSE")
    if (crossover(vrsi, overBought))
        // strategy.entry("FEMIRSISE", strategy.short, comment="FEMIRSISE")
        strategy.close("FEMIRSILE")
        strategy.close("FEMIMACDLE")
        strategy.close("FEMIADXLE")
        strategy.close("FEMIBBLE")
    
    if (crossunder(sig, adxThreshold) and crossunder(delta, MACDZero) and crossunder(source, upper)) // crossover(delta, MACDZero) crossover(vrsi, overSold) crossover(sig, adxThreshold)
        strategy.close("FEMIRSILE")
        strategy.close("FEMIMACDLE")
        strategy.close("FEMIADXLE")
        strategy.close("FEMIBBLE")
        
    // if(crossunder(source, upper))
    //     strategy.close("FEMIRSILE")
    //     strategy.close("FEMIMACDLE")
    //     strategy.close("FEMIADXLE")
    //     strategy.close("FEMIBBLE")
        // strategy.entry("FEMIADXSE", strategy.short, comment="FEMIADXSE")
    // else
    //     strategy.cancel(id="FEMISE")

// plot(sig, color=red, title="ADX", linewidth=2, style=areabr)
// plot(adxThreshold, color=blue, title="ADX")


// plot(vrsi, color=green, title="RSI", linewidth=2, style=areabr)
// plot(overSold, color=blue, title="RSI")
// plot(overBought, color=red, title="RSI")

// plot(delta, color=green, title="MACD", linewidth=2, style=areabr)
// plot(MACDZero, color=blue, title="MACD")
// plot(overBought, color=red, title="MACD")
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

더 많은