Mua thứ hai bán thứ tư chiến lược giao dịch

Tác giả:ChaoZhang, Ngày: 2023-09-12 16:44:53
Tags:

Chiến lược này giao dịch theo mô hình chu kỳ hàng tuần bằng cách đi dài vào thứ Hai đóng và lấy lợi nhuận trước khi mở thứ Tư để nắm bắt sự dao động giá trong giai đoạn này.

Chiến lược logic:

  1. Thực hiện nhập dài vào mỗi thứ hai đóng cửa.

  2. Lấy lợi nhuận để thoát ra trước khi mở cửa vào thứ Tư.

  3. Thiết lập tỷ lệ dừng lỗ để giới hạn lỗ.

  4. Đặt mục tiêu lợi nhuận tỷ lệ phần trăm để khóa trong lợi nhuận.

  5. Chế độ dừng và đường lợi nhuận cho P & L trực quan.

Ưu điểm:

  1. Giao dịch chu kỳ có lượng rút tiền nhỏ hơn và lợi nhuận lịch sử tốt.

  2. Các quy tắc cố định dễ dàng tự động hóa và thực hiện.

  3. Đơn giản dừng lỗ và lấy lợi nhuận cấu hình.

Rủi ro:

  1. Không thể thích nghi với các sự kiện làm gián đoạn chu kỳ.

  2. Không thể hạn chế lỗ trên giao dịch duy nhất.

  3. Bị khóa trong lợi nhuận không thể theo dõi tăng thêm.

Tóm lại, hệ thống chu kỳ cơ khí này có những thử nghiệm ngược lại ấn tượng nhưng phải vật lộn để thích nghi khi thay đổi mô hình.


/*backtest
start: 2023-08-12 00:00:00
end: 2023-09-11 00:00:00
period: 4h
basePeriod: 15m
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/
// © processingclouds

// @description Strategy to go long at end of Monday and exit by Tuesday close, or at stop loss or take profit percentages  

//@version=5
strategy("Buy Monday, Exit Wednesday", "Mon-Wed Swings",overlay=true)

//  ----- Inputs: stoploss %, takeProfit %
stopLossPercentage = input.float(defval=4.0, title='StopLoss %', minval=0.1, step=0.2) / 100
takeProfit = input.float(defval=3.0, title='Take Profit %', minval=0.3, step=0.2) / 100

//  ----- Exit and Entry Conditions - Check current day and session time
isLong = dayofweek == dayofweek.monday  and not na(time(timeframe.period, "1400-1601"))
isExit = dayofweek == dayofweek.wednesday and not na(time(timeframe.period, "1400-1601"))

//  ----- Calculate Stoploss and Take Profit values
SL = strategy.position_avg_price * (1 - stopLossPercentage)
TP = strategy.position_avg_price * (1 + takeProfit)

//  ----- Strategy Enter, and exit when conditions are met
strategy.entry("Enter Long", strategy.long, when=isLong)
if strategy.position_size > 0 
    strategy.close("Enter Long", isExit)
    strategy.exit(id="Exit", stop=SL, limit=TP)

//  ----- Plot Stoploss and TakeProfit lines
plot(strategy.position_size > 0 ? SL : na, style=plot.style_linebr, color=color.red, linewidth=2, title="StopLoss")
plot(strategy.position_size > 0 ? TP : na, style=plot.style_linebr, color=color.green, linewidth=2, title="TakeProfit")

Thêm nữa