RSI Dynamic Position Averaging Strategy
This strategy combines Relative Strength Index (RSI) and martingale position averaging principles. It initiates a long position when RSI goes below the oversold line, and doubles down the position if the price…

Overview
This strategy combines Relative Strength Index (RSI) and martingale position averaging principles. It initiates a long position when RSI goes below the oversold line, and doubles down the position if the price continues to decline. Profit taking is achieved with small targets. This strategy is suitable for high market cap coins in spot trading for steady gains.
Strategy Logic
- Use RSI indicator to identify market oversold conditions, with RSI period set to 14 and oversold threshold set to 30.
- Initiate first long position with 5% of account equity when RSI < 30.
- If price declines 0.5% from the initial entry price, double the position size to average down. If price declines further, quadruple the position size to average down again.
- Take profit at 0.5% increment each time.
- Repeat the cycle.
Advantage Analysis
- Identify market oversold conditions with RSI for good entry points.
- Martingale position averaging brings down average entry price.
- Small profit taking allows for consistent gains.
- Suitable for high market cap coins spot trading for controlled risks.
Risk Analysis
- Prolonged market downturn can lead to heavy losses.
- No stop loss means unlimited downside.
- Too many averaging downs increases loss.
- Still has inherent long direction risks.
Optimization Directions
- Incorporate stop loss to limit max loss.
- Optimize RSI parameters to find best overbought/oversold signals.
- Set reasonable profit taking range based on specific coin volatility.
- Determine averaging pace based on total assets or position sizing rules.
Summary
This strategy combines RSI indicator and martingale position averaging to take advantage of oversold situations with appropriate averaging down, and small profit taking for steady gains. It has risks that can be reduced through stop losses, parameter tuning, etc.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 14 | RSI Length |
| v_input_2 | 30 | Oversold Threshold |
| v_input_3 | 0.5 | Profit Target (%) |
| v_input_4 | 5 | Initial Investment % of Equity |
Source Pine Script
/*backtest
start: 2024-01-06 00:00:00
end: 2024-02-05 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Stavolt
//@version=5
strategy("RSI Martingale Strategy", overlay=true, default_qty_type=strategy.cash, currency=currency.USD)
// Inputs
rsiLength = input(14, title="RSI Length")
oversoldThreshold = input(30, title="Oversold Threshold") // Keeping RSI threshold
profitTargetPercent = input(0.5, title="Profit Target (%)") / 100
initialInvestmentPercent = input(5, title="Initial Investment % of Equity")
// Calculating RSI
rsiValue = ta.rsi(close, rsiLength)
// State variables for tracking the initial entry
var float initialEntryPrice = na
var int multiplier = 1
// Entry condition based on RSI
if (rsiValue < oversoldThreshold and na(initialEntryPrice))
initialEntryPrice := close
strategy.entry("Initial Buy", strategy.long, qty=(strategy.equity * initialInvestmentPercent / 100) / close)
multiplier := 1
// Adjusting for errors and simplifying the Martingale logic
// Note: This section simplifies the aggressive position size adjustments without loops
if (not na(initialEntryPrice))
if (close < initialEntryPrice * 0.995) // 0.5% drop from initial entry
strategy.entry("Martingale Buy 1", strategy.long, qty=((strategy.equity * initialInvestmentPercent / 100) / close) * 2)
multiplier := 2 // Adjusting multiplier for the next potential entry
if (close < initialEntryPrice * 0.990) // Further drop
strategy.entry("Martingale Buy 2", strategy.long, qty=((strategy.equity * initialInvestmentPercent / 100) / close) * 4)
multiplier := 4
// Additional conditional entries could follow the same pattern
// Checking for profit target to close positions
if (strategy.position_size > 0 and (close - strategy.position_avg_price) / strategy.position_avg_price >= profitTargetPercent)
strategy.close_all(comment="Take Profit")
initialEntryPrice := na // Reset for next cycle
Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-06. 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/RSI-Dynamic-Position-Averaging-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
- Multiple Indicator Quantitative Trading StrategyPine Script · Martingale · 1h
- RSI Quantitative Trading StrategyPine Script · Martingale · 1h
- Advanced MACD Strategy with Limited Martingale 453225Pine Script · Martingale · 1h
- RSI and Moving Average Combination MT5 Martingale Scalping StrategyPine Script · Martingale · 1d
- Martingale Strategy with Expanded Moving Average Range for Stock TradingPine Script · Martingale · 1h
- Bollinger Bands and RSI indicators strategyPine Script · Martingale · 2h