
Chiến lược này kết hợp với các vùng Brin và đường trung bình di chuyển, thiết kế một hệ thống giao dịch theo xu hướng. Khi giá phá vỡ vùng Brin lên đường và đường thấp hơn SMA200, hãy làm nhiều hơn, khi giá giảm xuống đường Brin, hãy đóng cửa một phần, và khi giá giảm xuống SMA200, hãy đóng cửa toàn bộ. Chiến lược này theo dõi xu hướng và dừng lại khi xu hướng thay đổi.
Chiến lược này đánh giá sự tồn tại của xu hướng với giả định rằng vùng Brin cần nằm hoàn toàn trên SMA200 và chỉ chọn vào nhiều hướng trong xu hướng tăng rõ ràng. Khi xu hướng đi xuống, kiểm soát rủi ro bằng cách dừng cổ phần điểm mấu chốt và dừng toàn bộ vị trí.
Những rủi ro này có thể được giảm bớt bằng cách kiểm tra cẩn thận các tham số Brin, tối ưu hóa các chiến lược dừng lỗ một phần, điều chỉnh tham số chu kỳ SMA và giới thiệu các phương pháp quản lý rủi ro khoa học hơn.
Chiến lược này tích hợp các kênh Brin và SMA để thiết kế một chiến lược theo dõi xu hướng hoàn chỉnh hơn. Nó có khả năng theo dõi xu hướng mạnh mẽ và đáng tin cậy hơn khi xác định xu hướng. Bằng cách liên tục tối ưu hóa chiến lược dừng lỗ, giảm tỷ lệ sai lầm tín hiệu và giới thiệu các phương tiện quản lý rủi ro khoa học, chiến lược này có thể trở thành một chiến lược xu hướng đáng để theo dõi trong thời gian dài.
/*backtest
start: 2022-11-09 00:00:00
end: 2023-11-15 00:00:00
period: 1d
basePeriod: 1h
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/
// © mohanee
//@version=4
strategy(title="BB9_MA200_Strategy", overlay=true, pyramiding=1, default_qty_type=strategy.cash, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed,
var stopLossVal=0.00
//variables BEGIN
smaLength=input(200,title="MA Length")
bbLength=input(21,title="BB Length")
bbsrc = input(close, title="BB Source")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
stopLoss = input(title="Stop Loss%", defval=5, minval=1)
riskCapital = input(title="Risk % of capital == Based on this trade size is claculated numberOfShares = (AvailableCapital*risk/100) / stopLossPoints", defval=10, minval=1)
sma200=ema(close,smaLength)
plot(sma200, title="SMA 200", color=color.orange)
//bollinger calculation
basis = sma(bbsrc, bbLength)
dev = mult * stdev(bbsrc, bbLength)
upperBand = basis + dev
lowerBand = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
//plot bb
plot(basis, "Basis", color=color.teal, style=plot.style_circles , offset = offset)
p1 = plot(upperBand, "Upper", color=color.teal, offset = offset)
p2 = plot(lowerBand, "Lower", color=color.teal, offset = offset)
fill(p1, p2, title = "Background", color=color.teal, transp=95)
strategy.initial_capital = 50000
//Entry---
strategy.entry(id="LE", comment="LE capital="+tostring(strategy.initial_capital + strategy.netprofit ,"######.##"), qty=( (strategy.initial_capital + strategy.netprofit ) * riskCapital / 100)/(close*stopLoss/100) , long=true, when=strategy.position_size<1 and upperBand>sma200 and lowerBand > sma200 and crossover(close, basis) ) // // aroonOsc<0 //(strategy.initial_capital * 0.10)/close
barcolor(color=strategy.position_size>=1? color.blue: na)
//partial Exit
tpVal=strategy.position_size>1 ? strategy.position_avg_price * (1+(stopLoss/100) ) : 0.00
strategy.close(id="LE", comment="Partial points="+tostring(close - strategy.position_avg_price, "####.##"), qty_percent=30 , when=abs(strategy.position_size)>=1 and close>tpVal and crossunder(lowerBand, sma200) ) //close<ema55 and rsi5Val<20 //ema34<ema55
//close All on stop loss
//stoploss
stopLossVal:= strategy.position_size>1 ? strategy.position_avg_price * (1-(stopLoss/100) ) : 0.00
strategy.close_all( comment="SL Exit points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and close < stopLossVal ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89//
strategy.close_all( comment="BB9 X SMA200 points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and crossunder(basis, sma200) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89