Chiến lược đầu da cá sấu của Williams

Tác giả:ChaoZhang, Ngày: 2023-09-25 17:42:27
Tags:

Tổng quan

Chiến lược này dựa trên chỉ số Bill Williams Alligator nhưng sử dụng nến Heiken Ashi làm đầu vào giá.

Chiến lược logic

Các nguyên tắc giao dịch chính của chiến lược là:

  1. Sử dụng nến Heiken Ashi thay vì nến thông thường cho hành động giá.

  2. Áp dụng ba đường trung bình di chuyển từ Bill Williams Alligator - Miệng, Răng và Môi. Chúng hoạt động như trung bình di chuyển để xác định hướng xu hướng.

  3. Khi các đường được xếp chồng lên nhau như Jaw (tối thấp), Teeth (trung tâm), Lips (cao nhất), nó báo hiệu xu hướng tăng. Khi đảo ngược với Jaw (cao nhất), Teeth (trung tâm), Lips (tối thấp), nó báo hiệu xu hướng giảm.

  4. Các mục được dựa trên hướng nến Heiken Ashi + đường thẳng Alligator. Các mục dài trên nến tăng và thiết lập bò; các mục ngắn trên nến giảm và thiết lập gấu.

  5. Ra khi các đường Alligator vượt qua, báo hiệu đảo ngược xu hướng.

  6. Các điểm cố định lấy lợi nhuận, dừng lỗ được sử dụng để quản lý rủi ro. Có thể cấu hình các điểm mục tiêu, điểm dừng lỗ, dừng lại, vv

Kết hợp hai bộ lọc của Heiken Ashi và Alligator tạo ra một chiến lược giao dịch ngắn hạn có khả năng cao.

Ưu điểm

Những lợi thế chính của chiến lược là:

  1. Bộ lọc chỉ số kép giảm thiểu tín hiệu sai.

  2. Định dạng xu hướng rõ ràng và trực quan. Các đường cá sấu có các tín hiệu tăng / giảm rõ ràng.

  3. Hiệu quả cho đầu óc ngắn hạn, ghi lại biến động giá trên biểu đồ 1 phút đến 5 phút.

  4. Các thông số đơn giản, không cần tối ưu hóa phức tạp.

  5. Quản lý rủi ro nghiêm ngặt thông qua điểm lấy lợi nhuận, dừng lỗ.

  6. Các quy tắc nhập cảnh/ra khỏi được xác định dựa trên các đường băng Alligator.

  7. Dễ thực hiện và sao chép, thân thiện với người mới bắt đầu.

Rủi ro

Những rủi ro chính cần xem xét là:

  1. Rủi ro rút tiền từ những cú đập, tín hiệu cá sấu thường xuyên có thể làm tăng giao dịch và chi phí.

  2. Rủi ro thị trường giới hạn phạm vi.

  3. Rủi ro tối ưu hóa quá mức.

  4. Rủi ro thất bại chỉ số.

  5. Rủi ro trượt dừng lỗ. Khoảng cách có thể kích hoạt dừng lại gây ra tổn thất không hợp lý.

  6. Rủi ro tần suất giao dịch cao.

Phân tích kỳ vọng, dừng tối ưu, tần suất được kiểm soát v.v. có thể giải quyết nhiều rủi ro này.

Cơ hội gia tăng

Một số cách để cải thiện chiến lược là:

  1. Kết hợp các bộ lọc bổ sung như RSI cho tỷ lệ thắng cao hơn.

  2. Sử dụng dừng ATR năng động để kiểm soát lỗ cho mỗi giao dịch.

  3. Thêm các quy tắc kích thước vị trí để tối ưu hóa kích thước đặt cược. Tăng theo sức mạnh xu hướng.

  4. Kết hợp các mô hình biểu đồ hoặc phân tích kỹ thuật khác cho thời gian nhập cảnh.

  5. Tối ưu hóa các tham số dựa trên loại công cụ (cổ phiếu, ngoại hối v.v.).

  6. Giới thiệu máy học để tối ưu hóa tham số thích nghi.

  7. Thực hiện phân tích kỳ vọng để điều chỉnh tỉ lệ lợi nhuận so với tỷ lệ dừng lỗ.

Với những cải tiến liên tục, chiến lược có thể trở thành một hệ thống giao dịch ngắn hạn mạnh mẽ.

Kết luận

Chiến lược này kết hợp Heiken Ashi với Williams Alligator để tạo ra một chiến lược giao dịch ngắn hạn có xác suất cao. Nó được hưởng lợi từ việc lọc chỉ số kép, các tham số đơn giản và cơ chế vào / ra được xác định tốt để làm giảm hiệu quả xu hướng và đảo ngược.


/*backtest
start: 2022-09-18 00:00:00
end: 2023-09-24 00:00:00
period: 4d
basePeriod: 1d
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/
// © 03.freeman
//Scalping strategy based on Bill Williams Alligator technique but applied to heikin ashi candles
//This strategy has to be applied to standard candles and low time frames (1min to 5min)
//@version=4
strategy("Bill Williams Alligator improved", shorttitle="Scalping alligator",overlay=true)
//source = input(close)
useHA = input (true,"Use heikin ashi candle?")

// ----------MA calculation - ChartArt-------------
smoothinput = input(1, minval=1, maxval=5, title='Moving Average Calculation: (1=SMA), (2=EMA), (3=WMA), (4=Linear), (5=VWMA)')

calc_ma(src,l) => 
    smoothinput == 1 ? sma(src, l):smoothinput == 2 ? ema(src, l):smoothinput == 3 ? wma(src, l):smoothinput == 4 ? linreg(src, l,0):smoothinput == 5 ? vwma(src,l):na
//----------------------------------------------

heikinashi_close = security(heikinashi(syminfo.tickerid), timeframe.period, close)
heikinashi_open = security(heikinashi(syminfo.tickerid), timeframe.period, open)
heikinashi_hl2 = security(heikinashi(syminfo.tickerid), timeframe.period, hl2)

direzione=heikinashi_close>heikinashi_open and heikinashi_close[1]>heikinashi_open[1]? 1 : heikinashi_close<heikinashi_open and heikinashi_close[1]<heikinashi_open[1]? -1 : 0

jawLength = input(13, minval=1, title="Jaw Length")
teethLength = input(8, minval=1, title="Teeth Length")
lipsLength = input(5, minval=1, title="Lips Length")
jawOffset = input(8, title="Jaw Offset")
teethOffset = input(5, title="Teeth Offset")
lipsOffset = input(3, title="Lips Offset")
jaw = calc_ma(heikinashi_hl2, jawLength)
teeth = calc_ma(heikinashi_hl2, teethLength)
lips = calc_ma(heikinashi_hl2, lipsLength)
plot(jaw, title="jaw",offset = jawOffset, color=#3BB3E4)
plot(teeth, title="teeth",offset = teethOffset, color=#FF006E)
plot(lips, title="lips",offset = lipsOffset, color=#36C711)

longCondition = direzione[0]==1 and jaw<teeth and jaw<lips and teeth<lips 
shortCondition = direzione[0]==-1 and jaw>teeth and jaw>lips and teeth>lips


//  Strategy: (Thanks to JayRogers)
// === STRATEGY RELATED INPUTS ===
//tradeInvert     = input(defval = false, title = "Invert Trade Direction?")
// the risk management inputs
inpTakeProfit   = input(defval = 0, title = "Take Profit Points", minval = 0)
inpStopLoss     = input(defval = 0, title = "Stop Loss Points", minval = 0)
inpTrailStop    = input(defval = 0, title = "Trailing Stop Loss Points", minval = 0)
inpTrailOffset  = input(defval = 0, title = "Trailing Stop Loss Offset Points", minval = 0)

// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit   = inpTakeProfit  >= 1 ? inpTakeProfit  : na
useStopLoss     = inpStopLoss    >= 1 ? inpStopLoss    : na
useTrailStop    = inpTrailStop   >= 1 ? inpTrailStop   : na
useTrailOffset  = inpTrailOffset >= 1 ? inpTrailOffset : na

// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() => direzione[0]==1 and jaw<teeth and jaw<lips and teeth<lips // functions can be used to wrap up and work out complex conditions
exitLong() => jaw>teeth or jaw>lips or teeth>lips
strategy.entry(id = "Buy", long = true, when = enterLong() )    // use function or simple condition to decide when to get in
strategy.close(id = "Buy", when = exitLong() )                  // ...and when to get out

// === STRATEGY - SHORT POSITION EXECUTION ===
enterShort() => direzione[0]==-1 and jaw>teeth and jaw>lips and teeth>lips
exitShort() => jaw<teeth or jaw<lips or teeth<lips
strategy.entry(id = "Sell", long = false, when = enterShort())
strategy.close(id = "Sell", when = exitShort() )

// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
strategy.exit("Exit Buy", from_entry = "Buy", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Sell", from_entry = "Sell", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)

// === Backtesting Dates === thanks to Trost

testPeriodSwitch = input(false, "Custom Backtesting Dates")
testStartYear = input(2020, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testStartHour = input(0, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(31, "Backtest Stop Day")
testStopHour = input(23, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
isPeriod = true
// === /END

if not isPeriod
    strategy.cancel_all()
    strategy.close_all()

Thêm nữa