다중 지표 컨버전스 거래 전략

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

멀티 인디케이터 컨버전스 트레이딩 전략은 RSI, TD 서열, MACD 및 볼링거 밴드 신호를 결합하여 트렌딩 시장에서 높은 확률의 세팅을 식별합니다.

전략 논리:

  1. 14주기 RSI를 계산합니다. 구매/판매 신호의 문턱으로 RSI차별 매개 변수를 사용하십시오. RSI (50 - RSI차별) 이하는 구매 신호를 제공합니다. RSI (50 + RSI차별) 이상은 판매 신호를 제공합니다.

  2. MACD 지표를 계산합니다. 5개의 연속적인 긍정적인 MACD 히스토그램 바는 구매 신호를 제공합니다. 5개의 연속적인 부정적인 바는 판매 신호를 제공합니다.

  3. TD 계열을 계산합니다. 2개의 연속적인 TD 바가 구매 신호를 줍니다. 2개의 연속적인 TS 바가 판매 신호를 줍니다.

  4. 20주기 볼링거 밴드를 계산합니다. 상위 밴드 이상의 가격 파업은 구매를 제안합니다. 하위 밴드 이하의 가격 파업은 판매를 제안합니다.

  5. RSI, MACD 및 TD Sequential가 방향에 동의하고 볼링거 밴드가 모순되지 않을 때만 거래를 수행합니다.

  6. 입력 매개 변수에 따라 수익 목표를 설정하고 손실을 멈추십시오.

이 전략은 잘못된 신호를 피하기 위해 여러 지표의 강점을 결합합니다. 볼링거 밴드는 트렌드 중에 높은 확률 설정을 필터링하는 데 도움이됩니다. 그러나 지표 매개 변수는 철저한 최적화가 필요하며, 모든 4 지표가 과도한 거래를 피하기 위해 동의 할 때 신호는 비교적 드물어야합니다.

전체적으로, 이 다중 지표 전략은 강한 트렌드 중에 높은 확률 설정을 포착할 수 있지만, 과도한 거래를 피하기 위해 신중한 매개 변수 조정과 보수적인 지표 신호 사용이 필요합니다.


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

//@version=2
strategy("RSI, TD Seq, MACD, BB Strategy - Calculation",overlay=true)



RSIDifference = input(-7, minval=-50, maxval=50, title="RSI Difference") 


TD = close > close[4] ?nz(TD[1])+1:0
TS = close < close[4] ?nz(TS[1])+1:0
TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
TDcheckUP = iff(TD == 2, true, false)
TDCheckDOWN = iff(TS == 2, true, false)

[_, _, histLine] = macd(close, 12, 26, 9)
MACDCheckDown = iff(histLine > 0 and histLine[1] > 0 and histLine[2] > 0 and histLine[3] > 0  and histLine[4] > 0, true, false)
MACDCheckUp = iff(histLine < 0 and histLine[1] < 0 and histLine[2] < 0 and histLine[3] < 0 and histLine[4] < 0, true, false)

RSICal = rsi(close, 14)
RSICalNewUp = 50 + RSIDifference
RSICalNewDown = 50 - RSIDifference
RSICheckUp = iff(RSICal <= RSICalNewUp, true, false)
RSICheckDown = iff(RSICal >= RSICalNewDown, true, false)

basis = sma(close, 20)
dev = 2 * stdev(close, 20)
upperBB = basis + dev
lowerBB = basis - dev
BBCheckUp = iff(close > upperBB, true, false)
BBCheckDown = iff(close < lowerBB, true, false)
//BBCheckUp = false
//BBCheckDown = false


BuyCheck = iff(TDcheckUP == true and MACDCheckUp == true and RSICheckUp == true and BBCheckUp == false, true, false)
SellCheck = iff(TDCheckDOWN == true and MACDCheckDown == true and RSICheckDown == true and BBCheckDown == false, true, false)


ProfitStratA = input(50, minval=0, maxval=10000, title="Profit", step=0.5) 
useStopLoss = input(false, title="Use Stop Loss?")
LossstratA = input(145, minval=0, maxval=10000, title="Stop Loss", step=0.5) 

ProfitStrat = ProfitStratA * 10
Lossstrat = useStopLoss ? LossstratA * 10 : 1000000

if (strategy.position_size > 0)
    strategy.exit("BuyClose", "Buy", profit=ProfitStrat, loss=Lossstrat)
    
    
if (strategy.position_size < 0)   
    strategy.exit("SellClose", "Sell", profit=ProfitStrat, loss=Lossstrat) 
    

if (BuyCheck == true and strategy.position_size == 0)
    strategy.entry("Buy", strategy.long, comment="Long Entry")
    


if (SellCheck == true and strategy.position_size == 0)
    strategy.entry("Sell", strategy.short, comment="Short Entry")
    
    
 
    

//plotshape(BuyCheck, color=blue, transp=0, style=shape.arrowup, text="Buy\n", location=location.belowbar)
//plotshape(SellCheck, color=orange, transp=0, style=shape.arrowdown, text="Sell\n", location=location.abovebar)













더 많은