Strategy vault / Mean reversion
Dual Moving Average Price Leaping Strategy
This strategy uses the RSI indicator to determine overbought and oversold conditions, combined with a trend judgment system constructed with fast, medium and slow moving average lines, to identify opportunities to…

Overview
This strategy uses the RSI indicator to determine overbought and oversold conditions, combined with a trend judgment system constructed with fast, medium and slow moving average lines, to identify opportunities to open long or short positions when prices are leaping.
Strategy Principle
Use RSI indicator to determine overbought and oversold conditions
- RSI parameter is set to 14 periods
- Oversold line is at 30, overbought line is at 70
Use three SMA lines of different periods to determine the trend
- Fast line is 9-period SMA, representing short-term trend
- Medium line is 50-period SMA, representing medium-term trend
- Slow line is 200-period SMA, representing long-term trend
When fast line crosses above medium line, and RSI indicator shows oversold, go long
When fast line crosses below medium line, and RSI indicator shows overbought, go short
Stop loss is set at 4% of entry price
Profit taking is done in batches, first take profit of 20%, then take 15% as price continues to rise, exiting positions gradually
Advantage Analysis
- Using three SMA lines of different periods can judge trend changes across different time frames
- The use of RSI indicator avoids opening positions outside of overbought/oversold areas
- Batch profit taking increases holding period and average profit of the strategy
Risk Analysis
- Probability of wrong signals from the three moving average lines
- Risk of incomplete batch profit taking execution
- Need to choose suitable instruments with high price fluctuation
Optimization Directions
- Can test modifying parameters of moving averages and RSI to optimize entry and exit
- Can add other indicators to filter candle patterns etc to improve accuracy
- Can dynamically trail stop loss to further control risk
Summary
This strategy combines moving average indicators and the overbought/oversold indicator RSI. By capturing price trend changes while judging trading opportunities, it belongs to a commonly used trend tracking strategy. Further optimizations and improved win rate can be achieved through parameter testing and incorporating additional auxiliary judgment indicators.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 30 | oversold |
| v_input_2 | 70 | overbought |
| v_input_3 | 20 | SellPct |
| v_input_4 | 15 | ExitPct |
| v_input_5 | 9 | v_input_5 |
| v_input_6 | 50 | v_input_6 |
| v_input_7 | 200 | v_input_7 |
| v_input_8 | 100 | v_input_8 |
| v_input_9 | 12 | Lookback Long Period |
| v_input_10 | 2 | Lookback Short Period |
| v_input_11 | 4 | v_input_11 |
Source Pine Script
/*backtest
start: 2023-11-13 00:00:00
end: 2023-11-20 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © syfuslokust
//@version=4
strategy(shorttitle='CoinruleCombinedCryptoStrat',title='CoinruleCombinedCryptoStrat', overlay=true)
// RSI inputs and calculations
lengthRSI = 14
RSI = rsi(close, lengthRSI)
//Normal
oversold = input(30)
overbought = input(70)
//ALGO
//oversold= input(26)
//overbought= input(80)
//sell pct
SellPct = input(20)
ExitPct = input(15)
//MA inputs and calculations
movingaverage_signal = sma(close, input(9))
movingaverage_fast = sma(close, input(50))
movingaverage_slow = sma(close, input(200))
movingaverage_mid= sma(close, input(100))
//Look Back
inp_lkb = input(12, title='Lookback Long Period')
inp_lkb_2 = input(2, title='Lookback Short Period')
perc_change(lkb) =>
overall_change = ((close[0] - close[lkb]) / close[lkb]) * 100
//Entry
//MA
bullish = crossover(movingaverage_signal, movingaverage_fast)
//Execute buy
strategy.entry(id="long", long = true, when = (RSI < oversold and movingaverage_fast < movingaverage_mid))
//when = crossover(close, movingaverage_signal) and movingaverage_signal < movingaverage_slow and RSI < oversold)
//Exit
//RSI
Stop_loss= ((input (4))/100)
longStopPrice = strategy.position_avg_price * (1 - Stop_loss)
//MA
bearish = crossunder(movingaverage_signal, movingaverage_fast)
//Execute sell
strategy.close("long", qty_percent = SellPct, when = RSI > overbought and movingaverage_fast > movingaverage_mid)
//when = (crossunder(low, movingaverage_signal) and movingaverage_fast > movingaverage_slow and RSI > overbought) or (movingaverage_signal < movingaverage_fast and crossunder(low, movingaverage_fast)) or (low < longStopPrice))
//PLOT
plot(movingaverage_signal, color=color.black, linewidth=2, title="signal")
plot(movingaverage_fast, color=color.orange, linewidth=2, title="fast")
plot(movingaverage_slow, color=color.purple, linewidth=2, title="slow")
plot(movingaverage_mid, color=color.blue, linewidth=2, title="mid")Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-21. 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/Dual-Moving-Average-Price-Leaping-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
- Adaptive Mean Reversion Trading Strategy Based on Chande Momentum OscillatorPine Script · Mean reversion · 1d
- Advanced 15 Minute Chart Trading Signal StrategyPine Script · Mean reversion · 3h
- Advanced Momentum EMA Trend Following with RSI Overbought Oversold Trading StrategyPine Script · Mean reversion · 1d
- Advanced Quantitative Trading Strategy Combining RSI Divergence and Moving AveragesPine Script · Mean reversion · 1h
- Advanced Strategy with Volume and Price Pullback Multiple Take ProfitPine Script · Mean reversion · 1h
- BONK Multi Factor Trading StrategyPine Script · Mean reversion · 1d