Strategi perdagangan konvergensi multi-indikator

Penulis:ChaoZhang, Tanggal: 2023-09-12 14:27:41
Tag:

Strategi Trading Convergence Multi-Indicator menggabungkan sinyal dari RSI, TD Sequential, MACD dan Bollinger Bands untuk mengidentifikasi pengaturan probabilitas tinggi selama pasar tren.

Logika Strategi:

  1. Menghitung RSI 14 periode. Gunakan parameter RSIdifference sebagai ambang untuk sinyal beli/jual. RSI di bawah (50 - RSIdifference) memberikan sinyal beli. RSI di atas (50 + RSIdifference) memberikan sinyal jual.

  2. Menghitung indikator MACD. 5 bar histogram MACD positif berturut-turut memberikan sinyal beli. 5 bar negatif berturut-turut memberikan sinyal jual.

  3. Menghitung TD Sequential. 2 bar TD berturut-turut ke atas memberikan sinyal beli. 2 bar TS berturut-turut ke bawah memberikan sinyal jual.

  4. Menghitung 20 periode Bollinger Bands. harga melanggar di atas band atas menunjukkan membeli. harga melanggar di bawah band bawah menunjukkan menjual.

  5. Hanya masukkan perdagangan ketika RSI, MACD dan TD Sequential menyetujui arah, dan Bollinger Bands tidak bertentangan.

  6. Tetapkan target keuntungan dan stop loss berdasarkan parameter input.

Strategi ini menggabungkan kekuatan dari beberapa indikator untuk menghindari sinyal palsu. Bollinger Bands membantu menyaring pengaturan probabilitas tinggi selama tren. Namun, parameter indikator perlu dioptimalkan secara menyeluruh, dan sinyal harus relatif jarang terjadi ketika semua 4 indikator setuju untuk menghindari perdagangan berlebihan.

Secara keseluruhan, strategi multi-indikator ini dapat menangkap pengaturan probabilitas tinggi selama tren yang kuat, tetapi membutuhkan penyesuaian parameter yang cermat, dan penggunaan sinyal indikator yang konservatif untuk menghindari perdagangan yang berlebihan.


/*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)













Lebih banyak