Chiến lược giao dịch đột phá xu hướng chính xác

Tác giả:ChaoZhang, Ngày: 2023-11-02 16:26:22
Tags:

img

Tổng quan

Chiến lược giao dịch đột phá xu hướng chính xác sử dụng các chỉ số xu hướng và các mẫu nến cụ thể để nắm bắt chính xác các đột phá xu hướng. Nó kết hợp các đường trung bình động để xác định hướng xu hướng, chỉ số RSI để đánh giá mức mua quá mức và bán quá mức và các mẫu nến tiên tiến để xác định các điểm nhập đột phá, cho phép xác định xu hướng chính xác cho giao dịch đột phá vào những thời điểm thuận lợi cho lợi nhuận quá lớn.

Chiến lược logic

  1. Sử dụng EMA 8 giai đoạn và EMA 80 giai đoạn để xác định hướng xu hướng. EMA 8 giai đoạn trên EMA 80 giai đoạn chỉ ra xu hướng tăng, và ngược lại cho xu hướng giảm. Chỉ xem xét tín hiệu giao dịch khi hướng xu hướng đồng ý.

  2. Xác định hình thành 3 nến cụ thể nơi Nến 1 thấp < Nến 2 thấp và Nến 3 thấp < Nến 2 thấp.

  3. Nến thứ ba hình thành bên trong thanh với giá đóng trong phạm vi của nến trước cho thấy điểm nhập khẩu tối ưu.

  4. Nhập dài ở mức cao của nến thứ ba và ngắn ở mức thấp của nến thứ ba. Đặt dừng lỗ ở mức thấp của nến 2 (nhập dài) hoặc cao của nến 2 (nhập ngắn). Lợi nhuận với rủi ro 2x.

  5. Đặt lệnh breakout khi xu hướng, mô hình, chỉ số đồng ý cho giao dịch có khả năng cao.

Phân tích lợi thế

Chiến lược có những lợi thế chính sau:

  1. Các EMA kép xác định hướng xu hướng tổng thể để tránh giao dịch chống lại xu hướng.

  2. Mô hình nến sẽ kiểm tra các hình thành đột phá có khả năng cao.

  3. Sự đồng thuận giữa các xu hướng, mô hình, chỉ số đảm bảo chất lượng tín hiệu.

  4. Cột bên trong tăng độ tin cậy tín hiệu và đảm bảo thêm thời gian nhập cảnh.

  5. Đặt trước stop loss và take profit quản lý rủi ro giao dịch cá nhân.

  6. Các thử nghiệm ngược xác nhận tỷ lệ thắng trên 65% cho lợi thế thống kê.

Tóm lại, chiến lược sử dụng phân tích xu hướng, mô hình và chỉ số toàn diện để xác định thời gian đột phá chính xác, mang lại lợi thế rủi ro-lợi nhuận ổn định.

Phân tích rủi ro

Những rủi ro chính xuất phát từ:

  1. Các cuộc gọi xu hướng không chính xác tạo ra các tín hiệu sai trong điều kiện hỗn loạn.

  2. Khoảng cách dừng lỗ / lấy lợi nhuận tĩnh không phù hợp hoàn hảo với mọi biến động giá.

  3. Nhận dạng mẫu nến phụ thuộc vào điều chỉnh tham số đòi hỏi tối ưu hóa rộng rãi.

  4. Các sự kiện thiên nga đen vẫn không thể đoán trước với tác động nghiêm trọng đến thương mại.

  5. Kết quả thử nghiệm ngược có thể quá phù hợp và diễn tả sai hiệu suất trực tiếp.

  6. Tần suất giao dịch cao hơn làm tăng chi phí giao dịch. Tỷ lệ thắng và tỷ lệ rủi ro / phần thưởng nên trang trải đầy đủ chi phí.

Tối ưu hóa tham số thích hợp, kích thước tín hiệu bổ sung và kích thước vị trí có thể giảm thiểu rủi ro và tăng tính nhất quán hiệu suất.

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

Các chiều kích tối ưu hóa chính bao gồm:

  1. Kiểm tra các thông số thời gian nến bổ sung để tăng sự ổn định.

  2. Thêm xác nhận âm lượng để tránh phát sóng sai.

  3. Kết hợp các số liệu như tỷ lệ Sharpe cho độ bền của tham số.

  4. Đưa ra các cơ chế theo dõi lợi nhuận để kiểm soát lợi nhuận năng động.

  5. Bộ lọc tín hiệu theo mức hoảng loạn VIX để tránh sự không chắc chắn.

  6. Tối ưu hóa thời gian giữ cho thời gian giao dịch lý tưởng.

  7. Cải thiện cơ chế dừng lỗ ngoài dừng tĩnh.

Các biện pháp này có thể tiếp tục cải thiện tính ổn định, linh hoạt và lợi nhuận của chiến lược.

Kết luận

Chiến lược giao dịch đột phá xu hướng chính xác kết hợp thành công xu hướng, mô hình, phân tích dừng lỗ / lấy lợi nhuận để nắm bắt xu hướng đột phá có khả năng cao. Với các tín hiệu giao dịch rõ ràng, xác nhận chỉ số mạnh mẽ và rủi ro được kiểm soát, đây là một chiến lược hiệu quả phù hợp với các thị trường xu hướng. Với các tối ưu hóa và cải tiến liên tục, chiến lược hứa hẹn là một công cụ mạnh mẽ để theo dõi đột phá xu hướng và quản lý vị trí, mang lại giá trị to lớn cho các nhà giao dịch tìm kiếm lợi nhuận lớn.


/*backtest
start: 2022-11-01 00:00:00
end: 2023-10-14 05:20: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/
// © julianossilva

//@version=5
strategy(title="J2S Backtest: 123-Stormer Strategy",
         shorttitle="J2S Backtest: 123-Stormer Strategy",
         overlay=true, initial_capital=1000, default_qty_value=10,
         default_qty_type = strategy.percent_of_equity, pyramiding=0)

// Initial Backtest Date Range
useStartDate = timestamp("01 Jan 2020 21:00:00")
useEndDate   = timestamp("01 Jan 2023 21:00:00")

// User Inputs
SIGNAL_CONFIG          = "BACKTEST: STORMER STRATEGY (123)"
longEntryInput         = input.bool(defval=true,         title="Long Entry",                     group=SIGNAL_CONFIG)
shortEntryInput        = input.bool(defval=true,         title="Short entry",                    group=SIGNAL_CONFIG)
thresholdForEntryInput = input.int(defval=3,             title="Threshold on clandes for entry", group=SIGNAL_CONFIG)
insideBarStrategyTitle = "Only third candle inside bar is valid"
insideBarStrategyTip   = "According to Stomer, it would be the best signal for the strategy"
insideBarStrategyInput = input.bool(defval=true,         title=insideBarStrategyTitle,           group=SIGNAL_CONFIG, tooltip=insideBarStrategyTip)
EMA_CONFIG             = "BACKTEST: EXPONENTIAL MOVING AVERAGES"
sourceInput            = input.source(defval=close,      title="Source",           inline="01",  group=EMA_CONFIG)
emaTimeframeInput      = input.timeframe("1W",           title="Timeframe",        inline="01",  group=EMA_CONFIG)
emaOffsetInput         = input.int(defval=8,             title="Offset",           inline="01",  group=EMA_CONFIG)
fastEMALengthInput     = input.int(defval=8,             title="Fast EMA Length",  inline="02",  group=EMA_CONFIG)
useFastEMAInput        = input.bool(defval=true,         title="Use Fast EMA",     inline="02",  group=EMA_CONFIG)
slowEMALengthInput     = input.int(defval=80,            title="Slow EMA Length",  inline="03",  group=EMA_CONFIG)
useSlowEMAInput        = input.bool(defval=true,         title="Use Slow EMA",     inline="03",  group=EMA_CONFIG)
PERIOD_CONFIG          = "BACKTEST: TIME PERIOD"
useDateFilterInput     = input.bool(defval=true,         title="Filter Date Range of Backtest",  group=PERIOD_CONFIG)
backtestStartDateInput = input(defval=useStartDate, title="Start Date",                     group=PERIOD_CONFIG)
backtestEndDateInput   = input(defval=useEndDate,   title="End Date",                       group=PERIOD_CONFIG)

// Colors
bbBackgroundColor  = color.rgb(33, 150, 243, 90)
candleColorDown    = color.rgb(239, 83, 80, 80)
candleColorUp      = color.rgb(38, 166, 154, 70)
insideBarColorDown = color.rgb(239, 83, 80, 40)
insideBarColorUp   = color.rgb(38, 166, 154, 20)
downTrendColor     = color.rgb(239, 83, 80, 80)
sidewaysTrendColor = color.rgb(252, 232, 131, 80)
upTrendColor       = color.rgb(38, 166, 154, 80)
buySignalColor     = color.lime
sellSignalColor    = color.orange

// Candles
isCandleUp()   => close > open
isCandleDown() => close <= open
barcolor(isCandleUp() ? candleColorUp : isCandleDown() ? candleColorDown : na)

// Exponential Moving Averages
fastEMA         = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput),    barmerge.gaps_on,  barmerge.lookahead_on)
currentFastEMA  = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput),    barmerge.gaps_off, barmerge.lookahead_on)
previousFastEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], fastEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)
slowEMA         = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput),    barmerge.gaps_on,  barmerge.lookahead_on)
currentSlowEMA  = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput),    barmerge.gaps_off, barmerge.lookahead_on)
previousSlowEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], slowEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)

// Trend Rules for Exponential Moving Averages
isSlowEMAUp()   => currentSlowEMA > previousSlowEMA
isSlowEMADown() => currentSlowEMA < previousSlowEMA
isFastEMAUp()   => currentFastEMA > previousFastEMA
isFastEMADown() => currentFastEMA < previousFastEMA

// Exponential Moving Average Colors
fastEMAColor = isFastEMAUp() ? upTrendColor : isFastEMADown() ? downTrendColor : sidewaysTrendColor
slowEMAColor = isSlowEMAUp() ? upTrendColor : isSlowEMADown() ? downTrendColor : sidewaysTrendColor

// Display Exponential Moving Averages
plot(useFastEMAInput ? fastEMA : na, offset=emaOffsetInput, color=fastEMAColor, title="Fast EMA", style=plot.style_line, linewidth=4)
plot(useSlowEMAInput ? slowEMA : na, offset=emaOffsetInput, color=slowEMAColor, title="Slow EMA", style=plot.style_line, linewidth=7)

// Price Trend
pricesAboveFastEMA() => low[2] > currentFastEMA and low[1] > currentFastEMA and low > currentFastEMA
pricesAboveSlowEMA() => low[2] > currentSlowEMA and low[1] > currentSlowEMA and low > currentSlowEMA
pricesBelowFastEMA() => high[2] < currentFastEMA and high[1] < currentFastEMA and high < currentFastEMA
pricesBelowSlowEMA() => high[2] < currentSlowEMA and high[1] < currentSlowEMA and high < currentSlowEMA

// Market in Bullish Trend
isBullishTrend() =>
    if useFastEMAInput and useSlowEMAInput
        pricesAboveFastEMA() and pricesAboveSlowEMA()
    else if useFastEMAInput
        pricesAboveFastEMA()
    else if useSlowEMAInput
        pricesAboveSlowEMA()
    else
        na

// Market in Bearish Trend
isBearishTrend() =>
    if useFastEMAInput and useSlowEMAInput
        pricesBelowFastEMA() and pricesBelowSlowEMA()
    else if useFastEMAInput
        pricesBelowFastEMA()
    else if useSlowEMAInput
        pricesBelowSlowEMA()
    else
        na

// Stormer Strategy (123)
isFirstCandleUp()   => high[2] > high[1] and low[2] > low[1]
isFirstCandleDown() => high[2] < high[1] and low[2] < low[1]
isThirdCandleUp()   => low > low[1]
isThirdCandleDown() => high < high[1]
isThirdCandleInsideBar() => high < high[1] and low > low[1]

// Buy Signal
isStormer123Buy() =>
    if insideBarStrategyInput
        longEntryInput and isFirstCandleUp() and isThirdCandleInsideBar() and isBullishTrend()
    else
        longEntryInput and isFirstCandleUp() and isThirdCandleUp() and isBullishTrend()

// Sell Signal
isStormer123Sell() =>
    if insideBarStrategyInput
        shortEntryInput and isFirstCandleDown() and isThirdCandleInsideBar() and isBearishTrend()
    else
        shortEntryInput and isFirstCandleDown() and isThirdCandleDown() and isBearishTrend()

// Backtest Time Period
inTradeWindow             = true
isInTradeWindow()         => inTradeWindow
isBacktestDateRangeOver() => not inTradeWindow and inTradeWindow[1]

// Backtest Price Parameters
highestPrice = ta.highest(high, 3)
lowestPrice  = ta.lowest(low,3)
priceRange   = highestPrice - lowestPrice

// Stormer Strategy (123): LONG
var myLongOrders = array.new_int(0)
longtEntryID     = "Long Entry:\n" + str.tostring(bar_index)
longExitID       = "Long Exit:\n" + str.tostring(bar_index)
stopLossInLong   = lowestPrice + 0.01
takeProfitInLong = priceRange + high

longEntryHasBeenMet = isInTradeWindow() and isBullishTrend() and isStormer123Buy()

// Scheduling LONG entry
if longEntryHasBeenMet
    array.push(myLongOrders, bar_index)
    strategy.order(longtEntryID, strategy.long, stop=high)
    strategy.exit(longExitID, longtEntryID, stop=stopLossInLong, limit=takeProfitInLong)

// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myLongOrders) == 0 ? na : array.size(myLongOrders) - 1)
    myLongOrder = array.get(myLongOrders, myOrderIndex)
    if bar_index - myLongOrder == thresholdForEntryInput
        longEntryID = "Long Entry:\n" + str.tostring(myLongOrder)
        strategy.cancel(longEntryID)

// Stormer Strategy (123): SHORT
var myShortOrders = array.new_int(0)
shortEntryID      = "Short Entry:\n" + str.tostring(bar_index)
shortExitID       = "Short Exit:\n" + str.tostring(bar_index)
stopLossInShort   = highestPrice + 0.01
takeProfitInShort = low - priceRange

shortEntryHasBeenMet = isInTradeWindow() and isBearishTrend() and isStormer123Sell()

// Scheduling SHORT entry
if shortEntryHasBeenMet
    array.push(myShortOrders, bar_index)
    strategy.order(shortEntryID, strategy.short, stop=low)
    strategy.exit(shortExitID, shortEntryID, stop=stopLossInShort, limit=takeProfitInShort)

// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myShortOrders) == 0 ? na : array.size(myShortOrders) - 1)
    myShortOrder = array.get(myShortOrders, myOrderIndex)
    if bar_index - myShortOrder == thresholdForEntryInput
        shortEntryID := "Short Entry:\n" + str.tostring(myShortOrder)
        strategy.cancel(shortEntryID)

// Close all positions at the end of the backtest period
if isBacktestDateRangeOver()
    strategy.cancel_all()
    strategy.close_all(comment="Date Range Exit")

// Display Signals
plotshape(series=longEntryHasBeenMet,  title="123 Buy",  style=shape.triangleup,   location=location.belowbar, color=buySignalColor,  text="123", textcolor=buySignalColor)
plotshape(series=shortEntryHasBeenMet, title="123 Sell", style=shape.triangledown, location=location.abovebar, color=sellSignalColor, text="123", textcolor=sellSignalColor)

Thêm nữa