
Chiến lược này đánh giá xu hướng xu hướng bằng cách sử dụng các đường ray trên, giữa và dưới của Brin và mối quan hệ của nó với đường trung bình di chuyển 200 ngày. Trong xu hướng đa đầu, khi giá chạm đường ray Brin xuống, bạn sẽ làm nhiều hơn; trong xu hướng không đầu, khi giá chạm đường ray Brin lên, bạn sẽ làm trống.
Chiến lược này được định hướng xu hướng thông qua dây chuyền Brin, hệ thống giao dịch được hình thành thông qua dây chuyền Brin hỗ trợ đường trung bình di chuyển sau khi xu hướng rõ ràng, không chỉ đảm bảo tính chính xác của hướng giao dịch, mà còn sử dụng phạm vi biến động để khóa lợi nhuận thích hợp. Ngoài ra, cũng có một số vấn đề về lựa chọn tham số và dừng lỗ.
/*backtest
start: 2023-11-29 00:00:00
end: 2023-12-06 00:00:00
period: 1m
basePeriod: 1m
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/
// © Aayonga
//@version=5
strategy("boll trend", overlay=true,initial_capital=1000,default_qty_type=strategy.fixed, default_qty_value=1 )
bollL=input.int(20,minval=1,title = "length")
bollmult=input.float(2.3,minval=0,step=0.1,title = "mult")
basis=ta.ema(close,bollL)
dev=bollmult*ta.stdev(close,bollL)
upper=basis+dev
lower=basis-dev
smaL=input.int(200,minval=1,step=1,title = "trend")
sma=ta.sma(close,smaL)
//多头趋势
longT=upper>sma and basis>sma and lower>=sma
//空头趋势
shortT=upper<sma and basis<sma and lower<=sma
//入场位
longE=ta.crossover(close,lower)
shortE=ta.crossover(close,upper)
//出场位
longEXIT=ta.crossover(high,upper) or ta.crossunder(close,ta.sma(close,300))
shortEXIT=ta.crossunder(low,lower) or ta.crossover(close,ta.sma(close,250))
if longT and longE
strategy.entry("多long",strategy.long)
if longEXIT
strategy.close("多long",comment = "close long")
if shortE and shortT
strategy.entry("空short",strategy.short)
if shortEXIT
strategy.close("空short",comment = "close short")