This strategy combines the Relative Strength Index (RSI) and Exponential Moving Average (EMA) technical indicators to implement a quantitative trading strategy based on trend following. It is mainly suitable for trending markets, entering when price reversals are identified to profit from the trend.
Long entry signal:
When both criteria are met, a long position is entered.
Maximum loss for each trade is limited to 3% of total account value. Stop loss placement needs to consider market characteristics.
Position sizing at entry: Max Loss / (Entry Price - Stop Loss Price) = Position Size
This effectively controls per trade risk.
Main exit signals:
When either signal occurs, the position is closed.
The strategy combines the advantages of trend following and mean reversion. The EMA determines overall trend, then entry signals happen at potential reversal zones, benefiting from both trend and reversals for stability. RSI parameters can also be optimized for different markets, making the strategy robust.
The fixed max loss per trade protects capital by directly controlling trade risk level.
The strategy works well in obvious trending markets. In complex and volatile environments, using EMA for trend may have limitations. Also RSI has some lagging effect, needing confirmation from actual price action.
Stop loss placement is critical to PnL, needing careful testing for different markets. If too wide, single loss can expand; if too tight, noise may trigger unwanted stops. Live testing is required for ongoing optimization.
Testing different RSI parameters to fit more markets. Finding optimal trade size ratios. Adding other technical indicators to build more robust entry/exit systems. These are all options worth exploring.
The strategy integrates the strengths of trend following and mean reversion strategies. Entry happens on potential reversal while identifying the bigger trend. RSI optimization adapts it to more market regimes. The fixed trade risk level keeps operation stable over the medium to long term. Further improvements are possible through adjustments and robustness testing using different markets and styles.
/*backtest start: 2023-10-01 00:00:00 end: 2023-12-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy("Stratégie RSI et EMA avec Gestion du Risque", overlay=true) // Paramètres de la stratégie rsiLength = input(14, "Longueur du RSI") rsiOverbought = input(70, "Niveau de Surachat RSI") rsiOversold = input(30, "Niveau de Survente RSI") // Calcul du RSI rsiValue = rsi(close, rsiLength) // Paramètres des EMA ema20 = ema(close, 20) ema50 = ema(close, 50) ema200 = ema(close, 200) // Paramètre du risque par trade riskPerTrade = input(0.03, "Risque par Trade (3%)") // Distance du stop-loss en pips (à ajuster selon votre stratégie) stopLossPips = input(1, "Distance du Stop-Loss en pips") // Calcul de la taille de position et du stop-loss calculatePositionSize(entryPrice, stopLossPips) => stopLossPrice = entryPrice - stopLossPips * syminfo.mintick riskPerTradeValue = strategy.equity * riskPerTrade positionSize = riskPerTradeValue / (entryPrice - stopLossPrice) positionSize // Conditions d'entrée longCondition = (rsiValue < rsiOversold) and (close > ema20 or close > ema50 or close > ema200) if longCondition strategy.entry("Long", strategy.long, qty=1) // Conditions de sortie exitCondition = (rsiValue > rsiOverbought) or (close < ema20 or close < ema50 or close < ema200) if exitCondition strategy.close("Long") // Affichage des EMA et RSI sur le graphique plot(ema20, color=color.red) plot(ema50, color=color.green) plot(ema200, color=color.blue) hline(rsiOverbought, "Niveau de Surachat RSI", color=color.red) hline(rsiOversold, "Niveau de Survente RSI", color=color.blue) plot(rsiValue, "RSI", color=color.purple)