
Chiến lược này là một chiến lược giao dịch dựa trên EMA, VWAP và khối lượng giao dịch. Ý tưởng chính là trong một thời gian giao dịch cụ thể, tín hiệu mở vị trí được tạo ra khi giá đóng cửa phá vỡ VWAP và EMA và khối lượng giao dịch lớn hơn khối lượng giao dịch trên đường K trước đó. Đồng thời, thiết lập các điều kiện dừng lỗ và dừng, và thanh toán vị trí trong một khoảng thời gian cụ thể.
Chiến lược này giao dịch trong một thời gian giao dịch cụ thể bằng cách xem xét tổng hợp xu hướng giá cả, giá trị công bằng của thị trường và khối lượng giao dịch. Mặc dù thiết lập lệnh dừng lỗ và giới hạn thời gian giao dịch, nhưng trong ứng dụng thực tế, vẫn cần chú ý đến các rủi ro như thị trường rung động và điểm trượt. Trong tương lai, có thể tăng cường sự ổn định và khả năng sinh lời của chiến lược bằng cách thêm các điều kiện lọc, tối ưu hóa tham số và quản lý vị trí.
/*backtest
start: 2024-04-27 00:00:00
end: 2024-04-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA, VWAP, Volume Strategy", overlay=true, process_orders_on_close=true)
// Inputs
emaLength = input.int(21, title="EMA Length")
vwapSource = input.source(defval=hlc3, title='VWAP Source')
stopLossPoints = input.float(100, title="Stop Loss (points)")
targetPoints = input.float(200, title="Target (points)")
session = input("0950-1430", title='Only take entry during')
exit = input(defval='1515-1525', title='Exit Trade')
tradein = not na(time(timeframe.period, session))
exit_time = not na(time(timeframe.period, exit))
// Calculate indicators
ema = ta.ema(close, emaLength)
vwapValue = ta.vwap(vwapSource)
// Entry Conditions
longCondition = close > vwapValue and close > ema and volume > volume[1] and close > open and tradein
shortCondition = close < vwapValue and close < ema and volume > volume[1] and open > close and tradein
// Exit Conditions
longExitCondition = ta.crossunder(close, vwapValue) or ta.crossunder(close, ema) or close - strategy.position_avg_price >= targetPoints or close - strategy.position_avg_price <= -stopLossPoints or exit_time
shortExitCondition = ta.crossover(close, vwapValue) or ta.crossover(close, ema) or strategy.position_avg_price - close >= targetPoints or strategy.position_avg_price - close <= -stopLossPoints or exit_time
// Plotting
plot(vwapValue, color=color.blue, title="VWAP")
plot(ema, color=color.green, title="EMA")
// Strategy
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
if longExitCondition
strategy.close('Long', immediately=true)
if shortExitCondition
strategy.close("Short", immediately=true)