Strategy vault / Trend following
VWAP EMA RSI Trend Following Strategy
This strategy combines VWAP, EMA and RSI for trend bias and follows trends using a trailing stop approach. It aims to ride trends with adaptive exits. Strategy Logic: 1. Calculate VWAP as fair value benchmark. 2…
This strategy combines VWAP, EMA and RSI for trend bias and follows trends using a trailing stop approach. It aims to ride trends with adaptive exits.
Strategy Logic:
Calculate VWAP as fair value benchmark.
Compute 15-period EMA as intermediate-term trend indicator.
Use RSI to identify overbought levels, RSI above threshold signals bullishness.
Enter long when close exceeds VWAP and EMA, and RSI overbought.
Set trailing stop loss line certain percentage below entry point.
Take fixed profit at set point level to lock in gains.
Advantages:
VWAP, EMA and RSI improve entry accuracy from multiple aspects.
Trailing stop moves dynamically to protect profits.
Fixed profit-taking provides certainty in exiting.
Risks:
RSI and EMA prone to false signals during ranges.
Stop loss calibration requires prudence, too wide or too narrow problematic.
No limit on single trade loss size.
In summary, this strategy combines multiple indicators and uses a trailing stop for trend following. It performs well in sustained trends but requires optimization and risk controls.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_int_1 | 15 | EMA Length |
| v_input_int_2 | 14 | RSI Length |
| v_input_int_3 | 45 | RSI Overbought Level |
| v_input_float_1 | 0.5 | Stop Loss % |
| v_input_float_2 | 3.5 | Take Profit % |
| v_input_float_3 | true | Trailing Stop % |
Source Pine Script
/*backtest
start: 2022-09-12 00:00:00
end: 2023-02-03 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("VWAP+15EMA with RSI", overlay=true)
// Inputs
ema_length = input.int(15, title="EMA Length")
rsi_length = input.int(14, title="RSI Length")
rsi_overbought = input.int(45, title="RSI Overbought Level")
stop_loss_pct = input.float(0.5, title="Stop Loss %")
take_profit_pct = input.float(3.5, title="Take Profit %")
trailing_stop_pct = input.float(1, title="Trailing Stop %")
// Calculate Indicators
vwap = ta.vwap(hlc3)
ema = ta.ema(close, ema_length)
rsi = ta.rsi(close, rsi_length)
// Entry Condition
long_entry = close > vwap and close > ema and rsi > rsi_overbought
// Exit Conditions
stop_loss = strategy.position_avg_price * (1 - stop_loss_pct / 100)
take_profit = strategy.position_avg_price * (1 + take_profit_pct / 100)
trailing_stop = strategy.position_avg_price * (1 - trailing_stop_pct / 100)
// Submit Orders
if long_entry and strategy.position_size == 0
strategy.entry("Long", strategy.long)
if strategy.position_size > 0
strategy.exit("Stop Loss /Profit", "Long", profit = take_profit, stop=stop_loss, trail_offset = trailing_stop)
// Plot Indicators
plot(vwap, title="VWAP", color=color.blue)
plot(ema, title="EMA", color=color.orange)
plot(rsi, title="RSI", color=color.purple)
hline(rsi_overbought, title="RSI Overbought", color=color.red)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-13. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/VWAP-EMA-RSI-Trend-Following-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Fixed Range Volume Profile And Anchored VWAP Trend Identification Strategy With Dynamic Stop LossPine Script · Trend following · 1h
- Multi Trend StrategyPine Script · Trend following · 1m
- Multi Period Trend Confirmation Dynamic Risk Control Quantitative Trading StrategyPine Script · Trend following · 1h
- MOST Indicator Dual Position Adaptive StrategyPine Script · Trend following · 4h
- Multi Timeframe Volume and Trend Confluence Trading StrategyPine Script · Trend following · 1d
- WaveTrend and DER Based Swing Trading StrategyPine Script · Trend following · 1d