
Chiến lược này sử dụng đường trung bình di chuyển chỉ số 5 ngày (EMA) và dải Brin (BB) để xác định cơ hội giao dịch tiềm năng trên thị trường. Chiến lược này tạo ra tín hiệu mua hoặc bán khi giá vượt qua dải Brin và đáp ứng các điều kiện cụ thể. Chiến lược này nhằm mục đích nắm bắt sự biến động giá đáng kể của thị trường, đồng thời sử dụng mức dừng lỗ và giá mục tiêu để quản lý rủi ro và tối đa hóa lợi nhuận.
Cốt lõi của chiến lược này là sử dụng EMA ngày 5 và Bollin để đánh giá xu hướng và biến động của thị trường. Chiến lược này tạo ra một tín hiệu bán khi giá vượt qua đường dây Bollin và trên đường K trên EMA ngày 5. Ngược lại, khi giá vượt qua đường dây Bollin và trên đường K trên đường EMA ngày 5, chiến lược sẽ tạo ra tín hiệu mua.
Một khi giao dịch vào cửa, chiến lược sẽ thiết lập điểm dừng và giá mục tiêu. Đặt điểm dừng ở hướng ngược lại với giá vào cửa, để hạn chế tổn thất tiềm năng. Giá mục tiêu được tính dựa trên số điểm cố định (ví dụ: 1000 điểm) để khóa lợi nhuận dự kiến. Nếu giá chạm vào điểm dừng hoặc giá mục tiêu, chiến lược sẽ thoát khỏi giao dịch.
EMA sử dụng hai chỉ số kỹ thuật phổ biến với chiến lược đột phá của Brin để nắm bắt sự biến động giá đáng kể của thị trường. Chiến lược này có các điều kiện nhập cảnh rõ ràng, các biện pháp quản lý rủi ro và mục tiêu lợi nhuận, dễ hiểu và dễ thực hiện. Tuy nhiên, hiệu suất của chiến lược có thể bị ảnh hưởng bởi sự biến động và xu hướng thị trường không rõ ràng.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Nifty Bank Strategy", overlay=true)
// Parameters
lengthEMA = 5
lengthBB = 20
multBB = 1.5
targetPoints = 1000
// Calculate 5-day EMA
ema5 = ta.ema(close, lengthEMA)
// Calculate Bollinger Bands (length 20, multiplier 1.5)
basis = ta.sma(close, lengthBB)
dev = multBB * ta.stdev(close, lengthBB)
upperBB = basis + dev
lowerBB = basis - dev
// Define strategy variables
var float entryPrice = na
var float stopLoss = na
var float targetPrice = na
var bool inTrade = false
var bool isLong = false
var float triggerHigh = na
var float triggerLow = na
var float triggerClose = na
if not inTrade
// Short Entry Trigger Condition
if low > ema5 and low > upperBB and high > upperBB
triggerLow := low
triggerHigh := high
triggerClose := close
label.new(bar_index, high, "Waiting for short trigger", color=color.yellow)
// Long Entry Trigger Condition
else if high < ema5 and high < lowerBB and low < lowerBB
triggerHigh := high
triggerLow := low
triggerClose := close
label.new(bar_index, low, "Waiting for long trigger", color=color.yellow)
// Check for Short Entry
if not inTrade and na(triggerClose) == false and close < triggerClose
if low < triggerLow
entryPrice := close
stopLoss := triggerHigh
targetPrice := entryPrice - targetPoints
strategy.entry("Short", strategy.short)
label.new(bar_index, high, "Short", color=color.red, style=label.style_label_down)
inTrade := true
isLong := false
triggerLow := na
triggerHigh := na
triggerClose := na
// Check for Long Entry
if not inTrade and na(triggerClose) == false and close > triggerClose
if high > triggerHigh
entryPrice := close
stopLoss := triggerLow
targetPrice := entryPrice + targetPoints
strategy.entry("Long", strategy.long)
label.new(bar_index, low, "Long", color=color.green, style=label.style_label_up)
inTrade := true
isLong := true
triggerLow := na
triggerHigh := na
triggerClose := na
// Manage Short Trade
if inTrade and not isLong
if high >= stopLoss
strategy.close("Short", comment="SL Hit")
label.new(bar_index, high, "SL Hit", color=color.red, style=label.style_label_down)
inTrade := false
else if low <= targetPrice
strategy.close("Short", comment="Target Hit")
label.new(bar_index, low, "Target Hit", color=color.green, style=label.style_label_up)
inTrade := false
// Manage Long Trade
if inTrade and isLong
if low <= stopLoss
strategy.close("Long", comment="SL Hit")
label.new(bar_index, low, "SL Hit", color=color.red, style=label.style_label_down)
inTrade := false
else if high >= targetPrice
strategy.close("Long", comment="Target Hit")
label.new(bar_index, high, "Target Hit", color=color.green, style=label.style_label_up)
inTrade := false
// Plotting
plot(ema5, color=color.orange, title="5-day EMA")
plot(upperBB, color=color.red, title="Upper Bollinger Band")
plot(lowerBB, color=color.purple, title="Lower Bollinger Band")
// Plot trade entry and exit points
plotshape(series=inTrade and isLong ? entryPrice : na, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=inTrade and not isLong ? entryPrice : na, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")