Chiến lược giao dịch hai chiều đột phá biến động lớn: hệ thống vào lệnh mua và bán dựa trên ngưỡng điểm

ATR SL TP
Ngày tạo: 2024-11-18 16:11:21 sửa đổi lần cuối: 2024-11-18 16:11:21
sao chép: 0 Số nhấp chuột: 576
1
tập trung vào
1617
Người theo dõi

Chiến lược giao dịch hai chiều đột phá biến động lớn: hệ thống vào lệnh mua và bán dựa trên ngưỡng điểm

Tổng quan

Chiến lược này là một hệ thống giao dịch hai chiều dựa trên đường K 30 phút để tìm kiếm cơ hội giao dịch bằng cách theo dõi mức độ biến động của giá. Cốt lõi của chiến lược là xác định sự biến động lớn bằng cách đặt ngưỡng điểm và giao dịch theo hướng tương ứng sau khi xác nhận phá vỡ. Chiến lược này bao gồm quản lý thời gian nghiêm ngặt, dừng lỗ và cơ chế quản lý giao dịch để thực hiện giao dịch tự động có thể kiểm soát rủi ro.

Nguyên tắc chiến lược

Chiến lược sử dụng nhiều cơ chế lọc để xác định tín hiệu giao dịch có hiệu quả. Đầu tiên, chiến lược tính toán phạm vi biến động của thực thể khi K-line đóng cửa mỗi 30 phút, và khi biến động vượt quá ngưỡng thiết lập, nó sẽ được đánh dấu là cơ hội giao dịch tiềm năng. Để đảm bảo hiệu quả của giao dịch, chiến lược đặt một điểm đệm bổ sung, chỉ khi giá vượt qua vùng đệm này sẽ kích hoạt tín hiệu giao dịch thực tế.

Lợi thế chiến lược

  1. Quản lý thời gian hoàn hảo: giới hạn cửa sổ thời gian giao dịch, tránh tín hiệu giả trong thời gian không hoạt động
  2. Cơ chế giao dịch hai chiều: nắm bắt cơ hội hai chiều của thị trường và cải thiện hiệu quả sử dụng vốn
  3. Kiểm soát rủi ro hoàn hảo: sử dụng điểm cố định để đánh giá và quản lý rủi ro
  4. Tự động hóa cao: Tự động hóa toàn bộ quá trình từ nhận dạng tín hiệu đến thực hiện giao dịch, giảm can thiệp của con người
  5. Cài đặt tham số linh hoạt: Các tham số quan trọng có thể được điều chỉnh để thích ứng với các môi trường thị trường khác nhau

Rủi ro chiến lược

  1. Rủi ro phá vỡ giả: có thể xảy ra phá vỡ giả sau khi biến động mạnh, dẫn đến dừng lỗ
  2. Tính nhạy cảm của tham số: Thiết lập ngưỡng không đúng có thể dẫn đến cơ hội bị bỏ lỡ hoặc giao dịch quá mức
  3. Tùy thuộc vào môi trường thị trường: có thể thường xuyên kích hoạt dừng lỗ trong thị trường bất ổn
  4. Tác động điểm trượt: Trong thời gian có biến động cao, giá giao dịch thực tế có thể có sai lệch lớn so với giá tín hiệu
  5. Rủi ro quản lý vốn: Không có cơ chế quản lý vị trí có thể dẫn đến lỗ hổng rủi ro quá lớn

Hướng tối ưu hóa chiến lược

  1. Tăng bộ lọc xu hướng: kết hợp với các chỉ số xu hướng có chu kỳ dài hơn, cải thiện chất lượng tín hiệu
  2. Tối ưu hóa tham số động: Điều chỉnh tự động tham số giảm giá và dừng lỗ theo biến động thị trường
  3. Tiếp tục xác nhận số lượng giao dịch: tăng điều kiện lọc số lượng giao dịch, nâng cao độ tin cậy đột phá
  4. Tối ưu hóa dừng lỗ: thực hiện dừng lỗ động, thích ứng với các môi trường thị trường khác nhau
  5. Tham gia quản lý vị trí: điều chỉnh vị trí theo cường độ tín hiệu và biến động thị trường

Tóm tắt

Đây là một chiến lược giao dịch tự động được thiết kế đầy đủ, logic rõ ràng. Chiến lược có tính thực tế tốt thông qua lọc điều kiện và kiểm soát rủi ro nghiêm ngặt. Tuy nhiên, vẫn cần được thử nghiệm và tối ưu hóa đầy đủ trong môi trường thực tế, đặc biệt là khi thiết lập tham số và kiểm soát rủi ro cần được điều chỉnh theo tình hình thị trường thực tế.

Mã nguồn chiến lược
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Big Candle Breakout Strategy Both Side", overlay=true)  

// Input for the point move threshold
point_move_in = input.int(100, title="Point Move Threshold")
point_target = input.int(100, title="Point Target")
point_stoploss = input.int(100, title="Point Stop Loss")
point_buffer = input.int(5, title="Point Buffer")

point_move = point_buffer + point_move_in

// Define the start and end times for trading
start_hour = 9
start_minute = 15
end_hour = 14
end_minute = 30

// Function to check if the current time is within the allowed trading window
in_time_range = (hour(time('30')) > start_hour or (hour(time('30')) == start_hour and minute(time('30')) >= start_minute)) and (hour(time('30')) < end_hour or (hour(time('30')) == end_hour and minute(time('30')) <= end_minute))

// Retrieve the open, high, low, and close prices of 30-minute candles
open_30m = request.security(syminfo.tickerid, "30", open)
high_30m = request.security(syminfo.tickerid, "30", high)
low_30m = request.security(syminfo.tickerid, "30", low)
close_30m = request.security(syminfo.tickerid, "30", close)

// Calculate the range of the candle
candle_range_long = (close_30m - open_30m)
candle_range_short = (open_30m - close_30m)

// Determine if the candle meets the criteria to be marked
big_candle_long = candle_range_long >= point_move_in
big_candle_short = candle_range_short >= point_move_in

// Variables to store the state of the trade
var float long_entry_price = na
var float long_target_price = na
var float long_stop_loss_price = na

var float short_entry_price = na
var float short_target_price = na
var float short_stop_loss_price = na

// Check if there are no active trades
no_active_trades = (strategy.opentrades == 0)

// Long entry condition
if (big_candle_long and na(long_entry_price) and in_time_range and no_active_trades)
    long_entry_price := high_30m+point_buffer
    long_target_price := long_entry_price + point_target
    long_stop_loss_price := long_entry_price - point_stoploss
    strategy.entry("Buy", strategy.long, stop=long_entry_price, limit=long_target_price)

plot(long_entry_price, style=plot.style_linebr, color=color.blue, linewidth=2, title="Entry Price")
plot(long_target_price, style=plot.style_linebr, color=color.green, linewidth=2, title="Target Price")
plot(long_stop_loss_price, style=plot.style_linebr, color=color.red, linewidth=2, title="Stop Loss Price")

// Short entry condition
if (big_candle_short and na(short_entry_price) and in_time_range and no_active_trades)
    short_entry_price := low_30m - point_buffer
    short_target_price := short_entry_price - point_target
    short_stop_loss_price := short_entry_price + point_stoploss
    strategy.entry("Sell", strategy.short, stop=short_entry_price, limit=short_target_price)

plot(short_entry_price, style=plot.style_linebr, color=color.blue, linewidth=2, title="Short Entry Price")
plot(short_target_price, style=plot.style_linebr, color=color.green, linewidth=2, title="Short Target Price")
plot(short_stop_loss_price, style=plot.style_linebr, color=color.red, linewidth=2, title="Short Stop Loss Price") 

// Long exit conditions
if (not na(long_entry_price))
    strategy.exit("Long Exit", from_entry="Buy", limit=long_target_price, stop=long_stop_loss_price)
   
// Short exit conditions
if (not na(short_entry_price))
    strategy.exit("Short Exit", from_entry="Sell", limit=short_target_price, stop=short_stop_loss_price)

// Reset trade status
if (strategy.position_size == 0)
    long_entry_price := na
    long_target_price := na
    long_stop_loss_price := na

    short_entry_price := na
    short_target_price := na
    short_stop_loss_price := na

// Plot the big candle and entry/exit levels
plotshape(series=big_candle_long, location=location.abovebar, style=shape.circle, color=color.green)
plotshape(series=big_candle_short, location=location.abovebar, style=shape.circle, color=color.red)

//plot(long_entry_price, style=plot.style_stepline, color=color.blue, linewidth=2, title="Entry Price")
//plot(long_target_price, style=plot.style_stepline, color=color.green, linewidth=2, title="Target Price")
//plot(long_stop_loss_price, style=plot.style_stepline, color=color.red, linewidth=2, title="Stop Loss Price")