Peanut 123 Reversal and Breakout Range Short term Trading Strategy
The Peanut 123 Reversal and Breakout Range Short-term Trading Strategy is a combination strategy that incorporates the signals from a reversal strategy and a breakout strategy sub-strategies to generate more powerful…

Overview
The Peanut 123 Reversal and Breakout Range Short-term Trading Strategy is a combination strategy that incorporates the signals from a reversal strategy and a breakout strategy sub-strategies to generate more powerful trading signals.
Strategy Logic
The strategy consists of two sub-strategies:
Peanut 123 Reversal Strategy
It is an adapted reversal strategy based on the system introduced on P183 of Ulf Jensen's book. It goes long when the close price rises for 2 consecutive days and the 9-day Stochastic Slow line is below 50; It goes short when the close price falls for 2 consecutive days and the 9-day Stochastic Fast line is above 50.
Breakout Range Short Strategy
It is a short-term strategy that uses the breakout of the lowest price in a certain look_bak period as the signal. It goes short when the price breaks below the lowest low in the look_bak period.
The combination strategy takes into account the signals from both sub-strategies. It generates actual trading signals only when the two sub-strategies give signals in the same direction. No trading signals will be generated if the two sub-strategies give opposite signals.
Advantage Analysis
The strategy combines the advantages of both reversal and breakout sub-strategies and considers more factors. It can filter out some noise trades and improve win rate.
The reversal strategy captures short-term reversal opportunities and makes profit during fluctuations.
The breakout strategy catches the short-term trend after the breakout.
By combining the signals of two sub-strategies, more effective trading signals can be generated and noise can be filtered out.
Risk Analysis
The strategy also has the following risks:
Reversals may not happen, there are risks of failed reversals.
Breakouts can also be false breakouts, there are risks of chasing highs and lows.
Neither of the sub-strategies can ensure effectiveness when used alone, combining them may also fail.
To address these risks, methods like optimizing parameters, adjusting the weighting of sub-strategies, choosing different products for arbitrage can be used to reduce risks.
Optimization Directions
There is room for further optimization of the strategy:
Optimize the parameters of the two sub-strategies to better adapt to different cycles and different products.
Increase other types of sub-strategies, such as machine learning prediction strategies, to incorporate more factors.
Dynamically adjust the weighting of the two sub-strategies to give more weight to the better-performed one in different market environments.
Conduct combination arbitrage by selecting products with little correlation but certain commonality.
Summary
The Peanut 123 Reversal and Breakout Range Short-term Trading Strategy integrates the reversal and breakout sub-strategies at the strategy level. To some extent, it combines the advantages of the two sub-strategies while having space for further optimization. It provides new ideas for strategy design - conducting integration and combination at the strategy level while preserving the independence of sub-strategies, in order to discover more effective trading opportunities.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 14 | Length |
| v_input_2 | true | KSmoothing |
| v_input_3 | 3 | DLength |
| v_input_4 | 50 | Level |
| v_input_5 | 4 | Look Bak |
| v_input_6 | false | Trade reverse |
Source Pine Script
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 01/07/2019
// This is combo strategies for get a cumulative signal.
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
// The strategy sells at market, if close price is lower than the previous close price
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// Breakout Range Short Strategy
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
vFast = sma(stoch(close, high, low, Length), KSmoothing)
vSlow = sma(vFast, DLength)
pos = 0.0
pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0)))
pos
BreakoutRangeShort(look_bak) =>
pos = 0
xLowest = lowest(low, look_bak)
pos := iff(low < xLowest[1], -1, 0)
pos
strategy(title="Combo Backtest 123 Reversal & Breakout Range Short", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
look_bak = input(4, minval=1, title="Look Bak")
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBreakoutRangeShort = BreakoutRangeShort(look_bak)
pos = iff(posReversal123 == 1 and posBreakoutRangeShort == 1 , 1,
iff(posReversal123 == -1 and posBreakoutRangeShort == -1, -1, 0))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? color.red: possig == 1 ? color.green : color.blue )Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-29. 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/Peanut-123-Reversal-and-Breakout-Range-Short-term-Trading-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
- Bull Market Tracking SystemPine Script · Breakout · 1h
- Dynamic Stop Loss Strategy Adaptive to ATR FluctuationsPine Script · Breakout · 1h
- Moving Stop Loss Tracking StrategyPine Script · Breakout · 1d
- Quantitative Strategy PSARZigZagMACDART Based on Multi Indicator CombinationPine Script · Breakout · 1m
- Quantitative Trading Price Breakthrough StrategyPine Script · Breakout · 1d
- Reversal Breakout Bandpass Combo StrategyPine Script · Breakout · 1h