
Chiến lược này dựa trên các chỉ số Brin, mở vị trí nhiều đầu khi giá đóng cửa phá vỡ đường lên, mở vị trí mở đầu khi giá đóng cửa rơi xuống đường. Điều kiện đặt hàng nhiều đầu là giá rơi xuống đường trung và điều kiện đặt hàng bằng không là giá phá vỡ đường trung. Chiến lược này sử dụng giá so với vị trí của Brin để xác định hướng xu hướng và thời gian mở vị trí.
Chiến lược này là một chiến lược theo dõi xu hướng cổ điển, thông qua Brin để nắm bắt xu hướng. Logic của chiến lược rõ ràng, lợi thế rõ ràng, nhưng cũng có một số rủi ro. Có thể cải thiện hiệu suất chiến lược, cải thiện khả năng thích ứng bằng cách tối ưu hóa lệnh dừng lỗ, quản lý vị trí và lọc vị trí.
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
// Bollinger Bands: Madrid : 14/SEP/2014 11:07 : 2.0
// This displays the traditional Bollinger Bands, the difference is
// that the 1st and 2nd StdDev are outlined with two colors and two
// different levels, one for each Standard Deviation
strategy(shorttitle='MBB', title='Bollinger Bands', overlay=true)
src = input(close)
length = input.int(20, minval=1, title = "Length")
mult = input.float(2.0, minval=0.001, maxval=50, title = "Multiplier")
basis = ta.sma(src, length)
dev = ta.stdev(src, length)
dev2 = mult * dev
upper1 = basis + dev
lower1 = basis - dev
upper2 = basis + dev2
lower2 = basis - dev2
// Strategy
long_condition = ta.crossover(close, upper1)
short_condition = ta.crossunder(close, lower1)
if (long_condition)
strategy.entry("Long", strategy.long)
if (short_condition)
strategy.entry("Short", strategy.short)
// Exit conditions
exit_long_condition = ta.crossunder(close, basis)
exit_short_condition = ta.crossover(close, basis)
if (exit_long_condition)
strategy.close("Long")
if (exit_short_condition)
strategy.close("Short")
colorBasis = src >= basis ? color.blue : color.orange
pBasis = plot(basis, linewidth=2, color=colorBasis)
pUpper1 = plot(upper1, color=color.new(color.blue, 0), style=plot.style_circles)
pUpper2 = plot(upper2, color=color.new(color.blue, 0))
pLower1 = plot(lower1, color=color.new(color.orange, 0), style=plot.style_circles)
pLower2 = plot(lower2, color=color.new(color.orange, 0))
fill(pBasis, pUpper2, color=color.new(color.blue, 80))
fill(pUpper1, pUpper2, color=color.new(color.blue, 80))
fill(pBasis, pLower2, color=color.new(color.orange, 80))
fill(pLower1, pLower2, color=color.new(color.orange, 80))