Strategy vault / Mean reversion
1 3 1 Red Green Candlestick Reversal Strategy
The 1-3-1 red green candlestick reversal strategy is a strategy that generates buy and sell signals based on candlestick patterns. It looks for buying opportunities when 1 red candlestick is reversed by 3 subsequent…

Overview
The 1-3-1 red green candlestick reversal strategy is a strategy that generates buy and sell signals based on candlestick patterns. It looks for buying opportunities when 1 red candlestick is reversed by 3 subsequent green candlesticks.
Principles
The core logic of this strategy is:
- Check if the current candlestick is a red candle, i.e. the close price is lower than the open price
- Check if the previous 3 candlesticks are green candles, i.e. close price is higher than open price
- Check if the last green candle's close price is higher than the previous 2 green candles
- If the above conditions are met, go long at the close of the red candle
- Set stop loss at the lowest price of the red candle
- Set take profit at entry price plus the distance from entry to stop loss
With this strategy, we can buy when the red candle is reversed, because the subsequent trend is likely to be upwards. Stop loss and take profit are set to control risk and lock in profits.
Advantage Analysis
The 1-3-1 red green reversal strategy has the following advantages:
- Simple and clear logic, easy to understand and implement
- Utilizes candlestick pattern features without reliance on indicators, avoiding overoptimization problems
- Has clear entry and exit rules for objective execution
- Sets stop loss and take profit to control risk/reward of each trade
- Good backtest results, likely to translate well to live trading
Risk Analysis
Some risks to note for this strategy:
- Candlestick patterns cannot perfectly predict future moves, some uncertainty exists
- Only one entry, may have lower win rate due to stock specifics
- No consideration of market trend, risk holding during sustained downtrend
- Does not account for trading costs and slippage, actual performance may be worse
Solutions:
- Consider combining with MA etc to filter signals and improve entry success rate
- Adjust position sizing, scale in across multiple entries
- Dynamically adjust stop loss based on market conditions or pause trading
- Test different stop loss/take profit ratios
- Test actual performance including trading costs
Optimization Directions
Some ways this strategy can be optimized:
Market index filtering - filter signals based on short/medium term market trend, go long in uptrend and stop trading in downtrend
Volume confirmation - only go long if green candle volumes increase
Optimize stop loss/take profit ratios - test different ratios to find optimal parameters
Position sizing optimization - scale in across multiple entries to reduce single trade risk
Add more filters - e.g. MA, volatility etc to ensure high probability entry
Machine learning on big data - collect lots of historical data and train optimal parameter thresholds via ML
Conclusion
The 1-3-1 red green reversal strategy is overall a simple and practical short term trading strategy. It has clear entry and exit rules and good backtest results. With some optimization measures, it can become a reliable quant trading strategy. Risk management is also important to manage capital properly.
Source Pine Script
/*backtest
start: 2023-09-26 00:00:00
end: 2023-10-26 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
//by Genma01
strategy("Stratégie tradosaure 1 Bougie Rouge suivi de 3 Bougies Vertes", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
// Définir les paramètres
var float stopLossPrice = na
var float takeProfitPrice = na
var float stopLossPriceD = na
var float takeProfitPriceD = na
// Vérifier les conditions
redCandle = close[3] < open[3] and low[3] < low[2] and low[3] < low[1] and low[3] < low[0]
greenCandles = close > open and close[1] > open[1] and close[2] > open[2]
higherClose = close > close[1] and close[1] > close[2]
// Calcul du stop-loss
if (redCandle and greenCandles and higherClose) and strategy.position_size == 0
stopLossPrice := low[3]
// Calcul du take-profit
if (not na(stopLossPrice)) and strategy.position_size == 0
takeProfitPrice := close + (close - stopLossPrice)
// Entrée en position long
if (redCandle and greenCandles and higherClose) and strategy.position_size == 0
strategy.entry("Long", strategy.long)
// Sortie de la position
if (not na(stopLossPrice)) and strategy.position_size > 0
strategy.exit("Take Profit/Stop Loss", stop=stopLossPrice, limit=takeProfitPrice)
if strategy.position_size == 0
stopLossPriceD := na
takeProfitPriceD := na
else
stopLossPriceD := stopLossPrice
takeProfitPriceD := takeProfitPrice
// Tracer le stop-loss et le take-profit sur le graphique
plotshape(series=redCandle and greenCandles and higherClose and strategy.position_size == 0, title="Conditions Remplies", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(series=redCandle and greenCandles and higherClose and strategy.position_size == 0, title="Conditions Remplies", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
// Afficher les prix du stop-loss et du take-profit
plot(stopLossPriceD, color=color.red, title="Stop Loss Price", linewidth=2, style = plot.style_linebr)
plot(takeProfitPriceD, color=color.green, title="Take Profit Price", linewidth=2, style = plot.style_linebr)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-27. 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/1-3-1-Red-Green-Candlestick-Reversal-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 Momentum EMA Trend Following with RSI Overbought Oversold Trading StrategyPine Script · Mean reversion · 1d
- Advanced Strategy with Volume and Price Pullback Multiple Take ProfitPine Script · Mean reversion · 1h
- Dynamic Adaptive Multi Timeframe Trend Following and Range Reversal Hybrid StrategyPine Script · Mean reversion · 2d
- Fast RSI Reversal Trading StrategyPine Script · Mean reversion · 1h
- Multi EMA Trend Reversal Trading StrategyPine Script · Mean reversion · 1d