Chiến lược Stochastic nhiều khung thời gian

Tác giả:ChaoZhang, Ngày: 2024-02-29 12:11:23
Tags:

img

Tổng quan

Chiến lược logic

Chiến lược này sử dụng các chỉ số chứng khoán trên hai khung thời gian để xác nhận tín hiệu và lọc tiếng ồn.

Phân tích lợi thế

Bằng cách kết hợp các chỉ số nhiều khung thời gian và động lực hiện tại, chiến lược này có thể lọc hiệu quả tiếng ồn thị trường và nắm bắt các giao dịch có lợi nhuận có khả năng cao.

Phân tích rủi ro

Có một số rủi ro cần xem xét với chiến lược này:

  1. Chỉ số khung thời gian hiện tại có thể quá nhạy cảm, làm tăng tần suất giao dịch và chi phí.
  2. Mặc dù stochastic kép tăng độ chính xác, nhưng nó cũng làm chậm thời gian phản ứng.

Hướng dẫn tối ưu hóa

Các hướng tối ưu hóa chính bao gồm:

  1. Tối ưu hóa khung thời gian cao hơn để điều chỉnh nhanh hơn cho các xu hướng mới.
  2. Điều chỉnh các thông số khung thời gian hiện tại và ngưỡng đột phá để giảm tín hiệu sai.
  3. Bao gồm các chiến lược dừng lỗ để kiểm soát rủi ro giảm theo giao dịch.

Kết luận


/*backtest
start: 2023-02-22 00:00:00
end: 2024-02-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("MTF stochastic strategy", overlay=false,pyramiding=3,default_qty_type=strategy.percent_of_equity,default_qty_value=100,currency=currency.USD)
//
//this strategy is inspired to bobby thread in forexfactory forum
//
len = input(11, minval=1, title="Length for Main Stochastic") 
smoothK = input(3, minval=1, title="SmoothK for Main Stochastic")
smoothD = input(3, minval=1, title="SmoothD for Main Stochastic")
upLine = input(80, minval=50, maxval=90, title="Upper Line Value?")
lowLine = input(20, minval=10, maxval=50, title="Lower Line Value?")
trailStep=input(50,minval=10,title="Trialing step value")

// current stochastic calculation
k = sma(stoch(close, high, low, len), smoothK)
d = sma(k, smoothD)

//mtf stochastic calculation smoothed with period

mtfK= sma(stoch(close, high, low, len), smoothK*3)
mtfD= sma(k, smoothD*3)

plot(k,"current TF k",black,style=linebr)
plot(d,"current TF d",gray,style=linebr)
plot(mtfK,"MTF TF k",red,style=line)
plot(mtfD,"Multi TF d",green,style=line)
hline(upLine)
hline(50)
hline(lowLine)

longCondition = crossover(mtfK, 50) and k>50 and change(k,1)>0 and k>d and mtfK>mtfD
if (longCondition)
    strategy.entry("Lungo", strategy.long)

shortCondition = crossunder(mtfD, 50) and k<50 and change(k,1)<0 and k<d and mtfK<mtfD
if (shortCondition)
    strategy.entry("Corto", strategy.short)
    
exitlong=crossunder(mtfD, upLine)
exitshort=crossover(mtfK, lowLine)

if (exitlong)
    strategy.exit("Esci lungo","Lungo",trail_points=trailStep)
if (exitshort)
    strategy.exit("Esci corto","Corto",trail_points=trailStep)
    



Thêm nữa