Chiến lược giao dịch với quản lý tiền

Tác giả:ChaoZhang, Ngày: 2023-12-12 17:32:08
Tags:

img

Tổng quan

Đây là một chiến lược giao dịch chứng khoán dài dựa trên chỉ số Ichimoku Kinko Hyo. Chiến lược sử dụng các nguyên tắc cơ bản của Ichimoku để xác định các bước vào và ra.

Chiến lược logic

Chiến lược đầu tiên tính toán các thành phần của Ichimoku, bao gồm Tenkan-Sen, Kijun-Sen, Senkou Span A và Senkou Span B.

Nhập dài nếu đáp ứng các điều kiện sau:

  • Tenkan chéo trên Kijun, chỉ ra MA ngắn hạn chéo trên MA dài hạn, đó là một tín hiệu chéo vàng
  • Giá trên đám mây Kumo, cho thấy giá tìm thấy hỗ trợ và bắt đầu tăng
  • Kumo tương lai màu đỏ, cho thấy xu hướng tương lai là lên
  • Khoảng cách giá từ Tenkan < 2 x ATR, cho thấy giá không bị kéo dài quá mức cho chiến lược theo đuổi
  • Khoảng cách giá từ Kijun < 3 x ATR, cho thấy giá không quá xa cho chiến lược theo đuổi
  • Tenkan và Kijun trên đám mây Kumo, cho thấy Ichimoku đang tăng

Ra khỏi nếu đáp ứng các điều kiện sau:

  • Thập giá Tenkan bên dưới Kijun, cho thấy thập giá chết
  • Sự thâm nhập của giá Kumo, cho thấy sự mất hỗ trợ
  • Lợi nhuận > 30%, thực hiện chiến lược thu lợi nhuận
  • Loss > 3%, thực hiện chiến lược dừng lỗ

Phân tích lợi thế

  • Sử dụng Ichimoku để xác định xu hướng giá với độ chính xác cao
  • Tích hợp ATR để kiểm soát theo đuổi, tránh mua quá nhiều và bán quá nhiều
  • Bộ lọc tín hiệu với nhiều xác nhận, tránh tín hiệu sai
  • Chiến lược bổ sung có thể tăng lợi nhuận

Phân tích rủi ro

  • Các tín hiệu của Ichimoku có thể bị trì hoãn, đòi hỏi xác nhận từ các chỉ số khác.
  • Các thông số ATR sai có thể dẫn đến mua quá mức và bán quá mức
  • Chiến lược bổ sung có thể làm tăng nguy cơ mất mát
  • Các thông số cần phải được điều chỉnh bằng tay cho các cổ phiếu khác nhau

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

  • Bao gồm các chỉ số khác như MACD, KDJ để xác nhận tín hiệu
  • Tăng mức lấy lợi nhuận, giảm mức dừng lỗ
  • Tự động điều chỉnh các thông số ATR dựa trên dữ liệu lịch sử
  • Sự khác biệt trong các tham số nghiên cứu cho các lĩnh vực khác nhau, xây dựng hồ sơ tham số

Tóm lại

Đây là một chiến lược giao dịch chứng khoán rất thực tế, sử dụng Ichimoku cho xu hướng và ATR để kiểm soát rủi ro, lợi nhuận từ chiến lược theo đuổi với dừng lỗ. Những lợi thế là hiển nhiên.


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

// Author Obarut
//@version=5
strategy("İchimoku Strategy With Money Management",overlay=true)

//Inputs
ts_period = input.int(9, minval=1, title="Tenkan-Sen Period")
ks_period = input.int(26, minval=1, title="Kijun-Sen Period")
ssb_period = input.int(52, minval=1, title="Senkou-Span B Period")
cs_offset = input.int(26, minval=1, title="Chikou-Span Offset")
ss_offset = input.int(26, minval=1, title="Senkou-Span Offset")


// Back Testing Period

fromday = input.int(defval=1,title="Start Date",minval=1,maxval=31) 
frommonth = input.int(defval=1,title="Start Month",minval=1,maxval=12)
fromyear = input.int(defval=1980,title="Start Year",minval=1800, maxval=2100)
today = input.int(defval=1,title="En Date",minval=1,maxval=31)
tomonth = input.int(defval=1,title="End Month",minval=1,maxval=12)
toyear =input.int(defval=2100,title="End Year",minval=1800,maxval=2200)


start=timestamp(fromyear,frommonth,fromday,00,00)
finish=timestamp(toyear,tomonth,today,00,00)
timewindow= time>=start and time<=finish

middle(len) => math.avg(ta.lowest(len), ta.highest(len))

// Ichimoku Components

tenkan = middle(ts_period)
kijun = middle(ks_period)
senkouA = math.avg(tenkan, kijun)
senkouB = middle(ssb_period)


atr = ta.atr(14)
ss_above = math.max(senkouA[ss_offset-1], senkouB[ss_offset-1])
ss_below = math.min(senkouA[ss_offset-1], senkouB[ss_offset-1])

// Price Distance From Tenkan

distance = close - tenkan

// Price Distance from Kijun

distancek = close - kijun

// Entry/Exit Signals

tk_cross_kijun_bull = tenkan >= kijun
tk_cross_kijun_bear = tenkan <= kijun
cs_cross_bull = ta.mom(close, cs_offset-1) > 0
cs_cross_bear = ta.mom(close, cs_offset-1) < 0
price_above_kumo = close > ss_above
pbsenkA = close < ss_above
pasenkB = close > ss_below
price_below_kumo = close < ss_above
future_kumo_bull = senkouA > senkouB
future_kumo_bear = senkouA < senkouB
// Price Distance From Tenken
disbull = distance < 2*atr
//Price Distance From Kijun
disbullk = distancek < 3*atr
//Price Above Tenkan Condition
patk = close > tenkan
// Kijun Above Senkou Span Condition
kjasenkA = kijun > ss_above
// Price Below Kijun Condition
pbkijun = close < kijun

//Bullish Condition

bullish= tk_cross_kijun_bull and cs_cross_bull and price_above_kumo and future_kumo_bull and patk and disbull and disbullk 
     and (tenkan>ss_above) and (kijun>ss_above)

if(bullish and timewindow )
    strategy.entry("Long Entry", strategy.long)

// Bearish Condition

bearish=tk_cross_kijun_bear and pbsenkA and cs_cross_bear  
      or pbkijun or price_below_kumo 

lastentryprice = strategy.opentrades.entry_price(strategy.opentrades - 1)

// Take Profit or Stop Loss in Bearish

if(bearish and timewindow or (close>1.30*lastentryprice and close<kijun ) or (close< 0.93*lastentryprice))
    strategy.close("Long Entry")




if(time>finish)
    strategy.close_all("time up")


plot(tenkan, color=#0496ff, title="Tenkan-Sen")
plot(kijun, color=#991515, title="Kijun-Sen")
plot(close, offset=-cs_offset+1, color=#2e640e, title="Chikou-Span")
sa=plot(senkouA, offset=ss_offset-1, color=color.rgb(17, 122, 21), title="Senkou-Span A")
sb=plot(senkouB, offset=ss_offset-1, color=color.rgb(88, 8, 8), title="Senkou-Span B")
fill(sa, sb, color = senkouA > senkouB ? color.rgb(198, 234, 198) : color.rgb(208, 153, 153), title="Cloud color")

Thêm nữa