Chiến lược giao dịch đơn giản dựa trên may mắn ngẫu nhiên

Tác giả:ChaoZhang, Ngày: 2023-09-13 17:48:13
Tags:

Chiến lược này được đặt tên là Simple Trading Strategy Based on Random Luck. Nó sử dụng các phương pháp ngẫu nhiên để tạo ra các tín hiệu dài hoặc ngắn vào ngày giao dịch đầu tiên của mỗi tuần, đánh giá hiệu suất giao dịch ngẫu nhiên thông qua một lượng lớn các thử nghiệm lặp đi lặp lại.

Cụ thể, logic giao dịch rất đơn giản:

  1. Quay đồng xu vào mỗi thứ hai, tạo ra kết quả ngẫu nhiên.

  2. Nếu có đầu, đi dài vào ngày đó. Nếu đuôi, đi ngắn vào ngày đó.

  3. Thiết lập stop loss ở 1 x ATR và lấy lợi nhuận ở 1 x ATR khi dài, ngược lại khi ngắn, đạt tỷ lệ rủi ro-lợi nhuận 1: 1.

  4. Giữ vị trí cho đến cuối tuần rồi đóng cửa.

Ưu điểm là kiểm tra lại nhiều năm dữ liệu để đánh giá tỷ lệ thắng trung bình của giao dịch ngẫu nhiên.

Nhưng giao dịch ngẫu nhiên không thể sử dụng các mô hình thị trường và không có khả năng tạo ra lợi nhuận bền vững.

Kết luận, kết quả backtest có thể gợi ý kết quả của giao dịch ngẫu nhiên, nhưng không đại diện cho các chiến lược thực sự áp dụng.


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

//@version=5
strategy("CoinFlip", overlay = true)

int result = int(math.random()+0.5)
atr_period = input(defval = 20, title = "ATR Period")
year_to_test = input(defval = 2022, title = "Year to Test")
day_of_week = input(defval = 1, title = "Day of Week")

atr = ta.atr(atr_period)

shouldSell = result == 0 and dayofweek == day_of_week
shouldBuy = result == 1 and dayofweek == day_of_week 

plotshape(result == 0 and dayofmonth == day_of_week, title="sell", location=location.abovebar, color=color.red, transp=0, style=shape.arrowdown)
plotshape(result == 1 and dayofmonth == day_of_week, title="buy", location=location.belowbar, color=color.lime, transp=0, style=shape.arrowup)


strategy.entry("short entry", strategy.short, 1000 / (1*atr), when=shouldSell and year == year_to_test)
strategy.entry("long entry", strategy.long,  1000  / (1*atr), when=shouldBuy and year == year_to_test)

strategy.exit("exit", "long entry", limit = close + 1*atr, stop = close - 1*atr, when = shouldBuy)
strategy.exit("exit", "short entry", limit = close - 1*atr, stop = close + 1*atr, when = shouldSell)



Thêm nữa