Strategy vault / Trend following
Multi Technical Indicator Trend Following Trading Strategy 474803
This strategy is a trend-following trading system that combines multiple technical indicators. It integrates RSI (Relative Strength Index), MACD (Moving Average Convergence Divergence), and SMA (Simple Moving…

Overview
This strategy is a trend-following trading system that combines multiple technical indicators. It integrates RSI (Relative Strength Index), MACD (Moving Average Convergence Divergence), and SMA (Simple Moving Average) to execute trades when market trends are clearly defined. The strategy also incorporates take profit, stop loss, and trailing stop mechanisms for better risk management.
Strategy Principles
The strategy executes trades based on the following core conditions:
- MACD shows a golden cross (MACD line crosses above the signal line)
- RSI is below 70, avoiding overbought territories
- Price is above the short-term moving average (20-day SMA)
- Short-term moving average is above the long-term moving average (50-day SMA)
When all these conditions are met simultaneously, the system generates a long signal. Additionally, the strategy sets a 5% take profit target, 3% stop loss limit, and 2% trailing stop to protect accumulated profits. This multi-layered approach to trade conditions helps improve accuracy and security.
Strategy Advantages
- Integration of multiple technical indicators enhances signal reliability
- RSI filtering prevents entries in overbought areas
- Moving average system helps confirm medium to long-term trends
- Comprehensive risk management system including fixed and trailing stops
- Flexible parameter adjustment for different market conditions
- Customizable date range for backtesting and live trading
Strategy Risks
- Multiple indicators may lead to delayed signals
- False signals may occur in ranging markets
- Fixed take profit and stop loss levels may not suit all market conditions
- Trailing stops might exit profitable trades too early in volatile markets Mitigation measures include: adjusting indicator parameters, adapting profit/loss ratios to market characteristics, and adding market environment filters.
Optimization Directions
- Incorporate volatility indicators (like ATR) for adaptive profit/loss levels
- Add volume indicators to validate signal strength
- Implement market condition analysis for parameter adaptation
- Optimize MACD parameters for more timely signals
- Consider adding reversal signals for short positions These optimizations would enhance strategy adaptability and stability.
Summary
This strategy establishes a comprehensive trading system through the combination of multiple technical indicators. It encompasses both trend-following logic and risk management considerations. While there are areas for optimization, the overall framework provides good scalability and adaptability. Successful implementation requires traders to optimize parameters and improve the strategy based on actual market conditions.
Source Pine Script
/*backtest
start: 2024-12-03 00:00:00
end: 2024-12-10 00:00:00
period: 45m
basePeriod: 45m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Flexible Swing Trading Strategy with Trailing Stop and Date Range", overlay=true)
// Input parameters
rsiPeriod = input.int(14, title="RSI Period")
macdFastLength = input.int(12, title="MACD Fast Length")
macdSlowLength = input.int(26, title="MACD Slow Length")
macdSignalSmoothing = input.int(9, title="MACD Signal Smoothing")
smaShortPeriod = input.int(20, title="Short-term SMA Period")
smaLongPeriod = input.int(50, title="Long-term SMA Period")
takeProfitPercent = input.float(5.0, title="Take Profit Percentage")
stopLossPercent = input.float(3.0, title="Stop Loss Percentage")
trailingStopPercent = input.float(2.0, title="Trailing Stop Percentage")
// Date range inputs
startDate = input(timestamp("2023-01-01 00:00"), title="Start Date")
endDate = input(timestamp("2023-12-31 23:59"), title="End Date")
// Calculate RSI
rsi = ta.rsi(close, rsiPeriod)
// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalSmoothing)
// Calculate SMAs
smaShort = ta.sma(close, smaShortPeriod)
smaLong = ta.sma(close, smaLongPeriod)
// Buy condition
buyCondition = ta.crossover(macdLine, signalLine) and rsi < 70 and close > smaShort and smaShort > smaLong
// Execute buy orders within the date range
if (buyCondition )
strategy.entry("Buy", strategy.long)
// Calculate take profit and stop loss levels
takeProfitLevel = strategy.position_avg_price * (1 + takeProfitPercent / 100)
stopLossLevel = strategy.position_avg_price * (1 - stopLossPercent / 100)
// Set take profit, stop loss, and trailing stop
strategy.exit("Take Profit", "Buy", limit=takeProfitLevel)
strategy.exit("Stop Loss", "Buy", stop=stopLossLevel)
strategy.exit("Trailing Stop", "Buy", trail_price=close * (1 - trailingStopPercent / 100), trail_offset=trailingStopPercent / 100)
// Plot Buy signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
// Plot SMAs
plot(smaShort, color=color.blue, title="20 SMA")
plot(smaLong, color=color.red, title="50 SMA")
// Plot MACD and Signal Line
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.orange, title="Signal Line")
// Plot RSI
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
plot(rsi, color=color.purple, title="RSI")
// Debugging plots
plotchar(buyCondition , char='B', location=location.belowbar, color=color.green, size=size.small)
plotchar(strategy.opentrades > 0, char='T', location=location.abovebar, color=color.blue, size=size.small)
plot(stopLossLevel, color=color.red, title="Stop Loss Level")
plot(takeProfitLevel, color=color.green, title="Take Profit Level")
Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-12. 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/Multi-Technical-Indicator-Trend-Following-Trading-Strategy-474803.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
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dynamic Dual EMA Crossover Strategy with Adaptive Profit Loss ControlPine Script · Trend following · 1d
- EMA and RSI Trend Trading StrategyPine Script · Trend following · 1d
- Fixed Range Volume Profile And Anchored VWAP Trend Identification Strategy With Dynamic Stop LossPine Script · Trend following · 1h
- Multi Dimensional Short Term Trend Predictor Technical Analysis and Volatility Adaptive Trading StrategyPine Script · Trend following · 1h