Penulis:ChaoZhang, Tarikh: 2024-01-26 16:04:26
Tag:

img

Ringkasan

Logika Strategi

  1. Ambil keuntungan / Hentikan kerugian: Apabila harga mencapai harga kemasukan + ambil mata keuntungan apabila panjang, ambil keuntungan; Apabila harga mencapai harga kemasukan - ambil mata keuntungan apabila pendek, ambil keuntungan; Apabila harga mencetuskan titik stop loss selepas panjang / pendek, hentikan kerugian.

Kelebihan

  1. Perdagangan automatik tanpa campur tangan manual mengurangkan kos perdagangan dan meningkatkan kecekapan.

Risiko

  1. Subjektiviti dalam pengenalan corak candlestick boleh membawa kepada pertimbangan yang salah.

  2. Tetapan titik mengambil keuntungan / berhenti rugi yang tidak betul mungkin terlepas daripada trend yang lebih besar atau menghentikan kerugian lebih awal.

Arahan pengoptimuman

  1. Mengoptimumkan keadaan pengenalan candlestick dengan lebih banyak penunjuk untuk meningkatkan ketepatan.

  2. Uji pada instrumen perdagangan yang berbeza, menyesuaikan titik mengambil keuntungan / berhenti kerugian, mengoptimumkan parameter.

  3. Menguatkan logik strategi dengan menambah algoritma untuk mengenal pasti lebih banyak isyarat perdagangan.

  4. Tambah modul pengukuran kedudukan untuk menyesuaikan kedudukan secara dinamik berdasarkan penunjuk rujukan.

Kesimpulan


/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-25 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 30/01/2019
//   This is a candlestick where the open and close are the same. 
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title = "Doji Backtest", overlay = true)
input_takeprofit = input(10, title="Take Profit pip", step=0.01)
input_stoploss = input(10, title="Stop Loss pip", step=0.01)
input_minsizebody = input(0.5, title="Min. Size Body pip", step=0.01)
barcolor(abs(close - open) <= input_minsizebody ? open == close ? yellow : na : na)
possell = 0.0
posbuy = 0.0
pospricebuy = 0.0
pospricesell = 0.0
barcolornow = blue
pospricesell := close< close[2] ? abs(close - open) <= input_minsizebody ? open == close ? close : nz(pospricesell[1], 0) : nz(pospricesell[1], 0) : nz(pospricesell[1], 0) 
possell := iff(pospricesell > 0 , -1, 0)
barcolornow := possell == -1 ? red: posbuy == 1 ? green : blue 
pospricesell := iff(low <= pospricesell - input_takeprofit and pospricesell > 0, 0 ,  nz(pospricesell, 0))
pospricesell := iff(high >= pospricesell + input_stoploss and pospricesell > 0, 0 ,  nz(pospricesell, 0))
pospricebuy := close > close[2] ? abs(close - open) <= input_minsizebody ? open == close ? close : nz(pospricebuy[1], 0) : nz(pospricebuy[1], 0) : nz(pospricebuy[1], 0) 
posbuy := iff(pospricebuy > 0 , 1, 0)
barcolornow := posbuy == 1 ? green: barcolornow
pospricebuy := iff(high >= pospricebuy + input_takeprofit and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
pospricebuy := iff(low <= pospricebuy - input_stoploss and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
barcolor(barcolornow)
if (posbuy == 0 and possell == 0) 
    strategy.close_all()
if (posbuy == 1)
    strategy.entry("Long", strategy.long)
if (possell == -1)
    strategy.entry("Short", strategy.short)	   	    
pospricebuy := iff(high <= pospricebuy + input_takeprofit and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
pospricebuy := iff(low >= pospricebuy - input_stoploss and pospricebuy > 0, 0 ,  nz(pospricebuy, 0))
pospricesell := iff(low <= pospricesell - input_takeprofit and pospricesell > 0, 0 ,  nz(pospricesell, 0))
pospricesell := iff(high >= pospricesell + input_stoploss and pospricesell > 0, 0 ,  nz(pospricesell, 0))


Lebih lanjut