Tren Darvas Box Strategi Perdagangan Kuantitatif

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

img

Gambaran umum

Strategi Trending Darvas Box adalah strategi perdagangan jangka pendek yang menggunakan saluran kotak Darvas untuk menangkap tren pasar. Mekanisme inti bergantung pada indikator Darvas Box untuk menentukan momentum pasar dan menemukan peluang perdagangan.

Logika Strategi

  • Gunakan parameter panjang untuk mengatur ukuran kotak Darvas, yang adalah 5 bar secara default dalam strategi ini.
  • Tentukan arah tren berdasarkan high/low breakout, dan ambil posisi long/short yang sesuai.
  • Ketika harga pecah di atas box top, garis TopBox hijau digambarkan.
  • Ketika harga pecah di bawah box bottom, garis BottomBox merah digambarkan.
  • Gunakan sistem Moving Average sebagai indikator tambahan. pergi panjang ketika harga di atas MAs, dan pergi pendek ketika di bawah MAs.
  • Gunakan RVI untuk mengidentifikasi zona overbought/oversold. RVI di atas garis sinyal menunjukkan overbought; RVI di bawah menunjukkan oversold.

Entri diambil ketika semua indikator di atas memberikan persetujuan. Stop loss diatur di band berlawanan dari kotak Darvas. Exits dikelola dengan arah RVI.

Analisis Keuntungan

  • Saluran kotak Darvas secara efektif menangkap tren pasar.
  • Sinyal keluar kotak yang sering, frekuensi masuk yang bagus.
  • Kotak yang masuk akal menghentikan pengaturan kerugian.
  • Indikator bantu meningkatkan akurasi.

Analisis Risiko

  • Jangkauan stop loss kotak yang luas. Risiko lebih besar per perdagangan.
  • Perdagangan panjang dapat dihentikan selama penarikan kecil.
  • Destinasi kotak tidak selalu benar.
  • Pengaturan halus diperlukan untuk indikator bantu untuk menyelaraskan dengan kotak.

Dapat memperketat stop loss untuk mengurangi risiko. Parameter tambahan juga perlu dioptimalkan untuk menyaring sinyal secara efektif.

Arahan Optimasi

  • Uji panjang kotak untuk menemukan ukuran yang optimal.
  • Optimalkan parameter tambahan agar sesuai dengan kotak.
  • Cobalah indikator tambahan lainnya untuk verifikasi sinyal lebih lanjut, misalnya KDJ, MACD.
  • Uji pengaturan stop loss dan take profit untuk stabilitas yang lebih tinggi.

Kesimpulan

Singkatnya, strategi Trending Darvas Box adalah strategi perdagangan yang agresif yang menargetkan tren jangka pendek. Ini menangkap perubahan tren dengan cepat dengan saluran kotak Darvas, sementara indikator tambahan membantu meningkatkan akurasi. Profil risiko / imbalan positif untuk strategi ini, layak diadopsi dan optimasi berkelanjutan.


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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © xxy_theone
// https://www.youtube.com/watch?v=YYxlnFOX9sQ
// This strategy script has been made to backtest the strategy explained in the video above


//@version=5
strategy(shorttitle = "Darvas Box Test", title="TradeIQ Darvas Box Test", overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100, currency=currency.USD)

// === INPUT BACKTEST RANGE ===
var GRP1 = "Backtest Range"
fromDate = input(timestamp("7 Mar 2022 00:00 +0000"), "From", group=GRP1)
toDate = input(timestamp("19 Mar 2022 23:59 +0000"), "To", group=GRP1)
window() =>  true


var GRP3 = "Darvas Box"
boxp=input(5, "Box Length", group=GRP3)

LL = ta.lowest(low,boxp)
k1=ta.highest(high,boxp)
k2=ta.highest(high,boxp-1)
k3=ta.highest(high,boxp-2)

NH =  ta.valuewhen(high>k1[1],high,0)
box1 =k3<k2
TopBox = ta.valuewhen(ta.barssince(high>k1[1])==boxp-2 and box1, NH, 0)
BottomBox = ta.valuewhen(ta.barssince(high>k1[1])==boxp-2 and box1, LL, 0)


plot(TopBox, linewidth=3, color=color.green, title="TBbox") 
plot(BottomBox, linewidth=3, color=color.red, title="BBbox")


var GRP4 = "MavilimW"

fmal=input(3,"First Moving Average length", group=GRP4)
smal=input(5,"Second Moving Average length", group=GRP4)
tmal=fmal+smal
Fmal=smal+tmal
Ftmal=tmal+Fmal
Smal=Fmal+Ftmal

M1= ta.wma(close, fmal)
M2= ta.wma(M1, smal)
M3= ta.wma(M2, tmal)
M4= ta.wma(M3, Fmal)
M5= ta.wma(M4, Ftmal)
MAVW= ta.wma(M5, Smal)
col1= MAVW>MAVW[1]
col3= MAVW<MAVW[1]
colorM = col1 ? color.blue : col3 ? color.red : color.yellow

plot(MAVW, color=colorM, linewidth=2, title="MAVW")


var GRP5 = "Relative Vigor Index"
len = input.int(10, title="Length", minval=1, group=GRP5)
rvi = math.sum(ta.swma(close-open), len)/math.sum(ta.swma(high-low),len)
sig = ta.swma(rvi)
offset = input.int(0, "Offset", minval = -500, maxval = 500, group=GRP5)
//plot(rvi, color=#008000, title="RVGI", offset = offset)
//plot(sig, color=#FF0000, title="Signal", offset = offset)


var longStopSet = false

long = ta.crossover(close,TopBox) and close > MAVW ? true : false
longClose = strategy.opentrades.profit(strategy.opentrades-1)>0 and ta.crossunder(rvi,sig) ? true : false
strategy.entry("Long Position", strategy.long, when = long and window() and strategy.position_size==0 and strategy.closedtrades<100)
if(longStopSet==false and strategy.position_size > 0)
    strategy.exit("exit", "Long Position", stop=BottomBox)
    longStopSet := true
if(strategy.position_size==0)
    longStopSet := false
strategy.close("Long Position", when = longClose)

var shortStopSet = false

short = ta.crossunder(close,BottomBox) and close < MAVW ? true : false
shortClose = strategy.opentrades.profit(strategy.opentrades-1)>0 and ta.crossover(rvi,sig) ? true : false
strategy.entry("Short Position", strategy.short, when = short and window() and strategy.position_size==0 and strategy.closedtrades<100)
if(shortStopSet==false and strategy.position_size < 0)
    strategy.exit("exit", "Short Position", stop=TopBox)
    shortStopSet := true
if(strategy.position_size==0)
    shortStopSet := false
strategy.close("Short Position", when = shortClose)


Lebih banyak