Bollinger + RSI, Strategi Ganda v1.1

Penulis:ChaoZhang, Tarikh: 2022-05-07 14:59:50
Tag:RSI

Strategi ini menggunakan penunjuk RSI bersama dengan Bollinger Bands untuk menjual apabila harga berada di atas Bollinger Band atas (dan untuk membeli apabila nilai ini berada di bawah band bawah).

Kemas kiniDalam versi 1.1 yang dikemas kini ini strategi kedua-dua dipermudahkan untuk pengguna (kurang input) dan dibuat lebih berjaya dalam backtesting dengan kini menggunakan tempoh 200 untuk SMA yang merupakan asas untuk Bollinger Band.

Dan sama seperti versi pertama strategi ini tidak menggunakan harga penutupan dari bingkai masa yang lebih tinggi dan tidak boleh mewarnai semula selepas lilin semasa telah ditutup.

Semua perdagangan melibatkan risiko yang tinggi; prestasi masa lalu tidak semestinya menunjukkan hasil masa depan. Hasil prestasi hipotetik atau simulasi mempunyai batasan semula jadi tertentu. Tidak seperti rekod prestasi sebenar, hasil simulasi tidak mewakili perdagangan sebenar. Juga, kerana dagangan tidak benar-benar dilaksanakan, hasilnya mungkin kurang atau terlalu dikompensasi untuk kesan, jika ada, faktor pasaran tertentu, seperti kekurangan kecairan. Program perdagangan simulasi pada umumnya juga tertakluk kepada fakta bahawa mereka direka dengan manfaat pandangan belakang. Tidak ada perwakilan yang dibuat bahawa mana-mana akaun akan atau mungkin mencapai keuntungan atau kerugian yang serupa dengan yang ditunjukkan.

P.S. Untuk pengguna lanjutan jika anda ingin mengakses lebih banyak fungsi skrip strategi ini, maka sila gunakan versi 1.0:Ujian semula img


/*backtest
start: 2022-04-06 00:00:00
end: 2022-05-05 23:59:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Bollinger + RSI, Double Strategy (by ChartArt) v1.1", shorttitle="CA_-_RSI_Bol_Strat_1.1", overlay=true)

// ChartArt's RSI + Bollinger Bands, Double Strategy - Update
//
// Version 1.1
// Idea by ChartArt on January 18, 2015.
//
// This strategy uses the RSI indicator 
// together with the Bollinger Bands 
// to sell when the price is above the
// upper Bollinger Band (and to buy when
// this value is below the lower band).
//
// This simple strategy only triggers when
// both the RSI and the Bollinger Bands
// indicators are at the same time in
// a overbought or oversold condition.
//
// In this version 1.1 the strategy was
// both simplified for the user and
// made more successful in backtesting. 
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 


///////////// RSI
RSIlength = input(6,title="RSI Period Length") 
RSIoverSold = 50
RSIoverBought = 50
price = close
vrsi = rsi(price, RSIlength)


///////////// Bollinger Bands
BBlength = input(200, minval=1,title="Bollinger Period Length")
BBmult = 2 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
buyEntry = crossover(source, BBlower)
sellEntry = crossunder(source, BBupper)
plot(BBbasis, color=aqua,title="Bollinger Bands SMA Basis Line")
p1 = plot(BBupper, color=silver,title="Bollinger Bands Upper Line")
p2 = plot(BBlower, color=silver,title="Bollinger Bands Lower Line")
//fill(p1, p2)


///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")
TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? green : na
///barcolor(switch1?TrendColor:na)
//bgcolor(switch2?TrendColor:na,transp=50)


///////////// RSI + Bollinger Bands Strategy
if (not na(vrsi))

    if (crossover(vrsi, RSIoverSold) and crossover(source, BBlower))
        strategy.entry("RSI_BB_L", strategy.long, stop=BBlower,  comment="RSI_BB_L")
        
    if (crossunder(vrsi, RSIoverBought) and crossunder(source, BBupper))
        strategy.entry("RSI_BB_S", strategy.short, stop=BBupper,  comment="RSI_BB_S")

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

Berkaitan

Lebih lanjut