This strategy is a trading strategy based on EMA, VWAP, and volume. The main idea is to generate opening signals when the closing price breaks through VWAP and EMA, and the trading volume is greater than the previous candle’s volume within a specific trading time. It also sets stop loss and take profit, as well as conditions for closing positions within a specific time period.
By comprehensively considering price trends, market fair value, and trading volume, this strategy trades within a specific trading time. Although stop loss, take profit, and limited trading time are set, it still needs to pay attention to risks such as volatile markets and slippage in actual application. In the future, the strategy’s robustness and profitability can be improved by adding more filtering conditions, optimizing parameters, and managing positions.
/*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)template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6