
The Livermore Key Pivot Breakout Quantitative Long Strategy is a systematic trading approach based on Jesse Livermore’s trading philosophy. This strategy identifies major trends, natural pullbacks, and secondary reactions in the market to precisely capture price breakouts through key support and resistance levels. The core of the strategy lies in using pivot points defined by either percentage or ATR indicators to determine trend transitions, establishing long positions when a major uptrend is confirmed and closing positions when a major downtrend is confirmed, thus enabling intelligent tracking of market fluctuations and effective capital management.
This strategy is based on Jesse Livermore’s trading concepts, dividing market trends into six states: Major Uptrend (MAIN_UP), Major Downtrend (MAIN_DOWN), Natural Rebound (NATURAL_REBOUND), Natural Retracement (NATURAL_RETRACEMENT), Secondary Rebound (SECONDARY_REBOUND), and Secondary Retracement (SECONDARY_RETRACEMENT).
The strategy determines the current trend state by calculating the relationship between current prices and historical key levels, combined with a preset pivot distance ratio (either a fixed percentage or dynamically calculated using ATR). The specific logic is as follows:
In a major uptrend, when prices continue to rise or pullbacks do not exceed the threshold defined by the major pivot multiplier, the uptrend state is maintained and the highest point is updated; when the pullback exceeds the threshold, the state shifts to natural retracement.
In a major downtrend, when prices continue to fall or rebounds do not exceed the threshold defined by the major pivot multiplier, the downtrend state is maintained and the lowest point is updated; when the rebound exceeds the threshold, the state shifts to natural rebound.
Transitions between natural rebound/retracement and secondary rebound/retracement are determined based on the relationship between price and historical highs/lows, as well as preset major and minor pivot multipliers.
The trading signal generation logic is: establish a long position when the trend is confirmed as a major uptrend for two consecutive periods; close the position when the trend is confirmed as a major downtrend for two consecutive periods.
Systematic Trend Identification: The strategy systematizes Livermore’s trading concepts through a clear mathematical model defining different trend states, eliminating uncertainties from subjective judgments.
Strong Adaptability: Through parameterized pivot distance percentages and ATR options, the strategy can adapt to different market environments and volatility conditions, enhancing its flexibility.
Confirmation Mechanism: The strategy requires trend confirmation for two consecutive periods before executing trades, effectively reducing losses from false breakouts.
Integrated Capital Management: The strategy uses account equity percentage for position sizing, ensuring consistent risk exposure across different account sizes.
Long-term Trend Capture: By distinguishing between major trends and secondary trends, the strategy can effectively capture large-cycle trends while avoiding short-term noise.
Lag Risk: Since the strategy requires confirmation of trend states for two periods before trading, it may miss some profits during the early stages of a trend or suffer larger drawdowns during trend reversals.
Parameter Sensitivity: Strategy performance is highly dependent on parameter settings such as pivot distance percentage and major/minor pivot multipliers. Inappropriate parameters may lead to overtrading or missed important signals.
Unidirectional Trading Limitation: The strategy is designed to execute only long trades, potentially leading to prolonged periods of idle capital in long-term declining markets, affecting overall returns.
Trend Definition Complexity: The transition logic between the six trend states is relatively complex, potentially causing frequent state switching in volatile markets and increasing transaction costs.
Lack of Stop-Loss Mechanism: There is no explicit stop-loss setting in the code, which may result in significant losses during sharp market reversals.
Add Stop-Loss Mechanism: Introduce stop-loss strategies based on ATR or fixed percentages to control single-trade risk before trend reversal. This can be implemented by setting a stop-loss level when establishing long positions to protect capital safety.
Optimize Trend Confirmation Mechanism: The current strategy requires two consecutive periods to confirm trends. Consider combining volume or other technical indicators for trend confirmation to improve signal quality.
Add Short Selling Functionality: Extend the strategy to support short trades, fully utilizing profit opportunities in downtrends and improving all-weather performance.
Dynamic Parameter Adjustment: Introduce dynamic parameter adjustment mechanisms based on historical volatility or market conditions, allowing the strategy to better adapt to different market environments.
Add Filtering Conditions: Incorporate market cycle, seasonality, or fundamental filters to avoid opening positions under unfavorable conditions and improve win rates.
Phased Position Building and Closing: Implement mechanisms for phased entry and exit, reducing timing risk and optimizing capital utilization efficiency.
The Livermore Key Pivot Breakout Quantitative Long Strategy successfully transforms Jesse Livermore’s classic trading philosophy into a quantifiable algorithmic system. By precisely defining six market trend states and their transition conditions, the strategy can effectively identify and track major uptrends, executing long trades based on confirmed trends.
While the strategy has advantages such as systematization, strong adaptability, and built-in confirmation mechanisms, it also faces risks including lag, parameter sensitivity, and lack of stop-loss provisions. By adding stop-loss mechanisms, optimizing trend confirmation, expanding short selling functionality, and implementing dynamic parameter adjustments, the strategy’s robustness and profitability can be further enhanced.
Overall, this strategy provides a solid framework for investors seeking to systematically implement Livermore’s trading philosophy. With appropriate parameter adjustments and risk management optimizations, it has the potential to achieve stable long-term returns in actual trading.
/*backtest
start: 2024-07-16 00:00:00
end: 2025-07-12 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":200000}]
*/
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bozhang_ox
//@version=6
strategy("Trading strategy Jesse Livermore", overlay=true)
// Input parameters
pivot_distance_percentage = input.float(0.5, title="Pivot Distance Percentage")
major_pivot_multiplier = input.int(6, title="Major Pivot Multiplier")
minor_pivot_multiplier = input.int(3, title="Minor Pivot Multiplier")
use_atr_pivot_distance = input.bool(false, title="Use ATR for Pivot Distance")
atr_period = input.int(14, title="ATR Period")
atr_pivot_multiplier = input.float(1, title="ATR Pivot Multiplier")
// Calculate ATR
atr = ta.atr(atr_period)
// Helper function to calculate pivot distance ratio
pivot_distance_ratio = use_atr_pivot_distance ? (atr * atr_pivot_multiplier) / close : pivot_distance_percentage / 100
// Trend states
NONE = 0
MAIN_UP = 6
MAIN_DOWN = 1
NATURAL_REBOUND = 2
NATURAL_RETRACEMENT = 5
SECONDARY_REBOUND = 4
SECONDARY_RETRACEMENT = 3
// Variables to track trends
var float main_up_max = na
var float main_down_min = na
var float natural_rebound_max = na
var float natural_retracement_min = na
var int trend = NONE
var int prev_trend = NONE
var int prev_prev_trend = NONE
// Initialize variables
if na(main_up_max)
main_up_max := -1e10
if na(main_down_min)
main_down_min := 1e10
if na(natural_rebound_max)
natural_rebound_max := -1e10
if na(natural_retracement_min)
natural_retracement_min := 1e10
// Trend logic
if trend == NONE
if close > close[1]
trend := MAIN_UP
main_up_max := close
else
trend := MAIN_DOWN
main_down_min := close
else if trend == MAIN_UP
if close > close[1] or (main_up_max - close < close[1] * pivot_distance_ratio * major_pivot_multiplier)
trend := MAIN_UP
main_up_max := math.max(main_up_max, close)
else
trend := NATURAL_RETRACEMENT
natural_retracement_min := close
else if trend == MAIN_DOWN
if close < close[1] or (close - main_down_min < close[1] * pivot_distance_ratio * major_pivot_multiplier)
trend := MAIN_DOWN
main_down_min := math.min(main_down_min, close)
else
trend := NATURAL_REBOUND
natural_rebound_max := close
else if trend == NATURAL_REBOUND
if close > close[1]
if close <= main_up_max
if close - natural_rebound_max <= close[1] * pivot_distance_ratio * minor_pivot_multiplier
trend := NATURAL_REBOUND
natural_rebound_max := math.max(natural_rebound_max, close)
else
trend := MAIN_UP
main_up_max := close
else
trend := MAIN_UP
main_up_max := close
else
if natural_rebound_max - close <= close[1] * pivot_distance_ratio * major_pivot_multiplier
trend := NATURAL_REBOUND
else if close < natural_retracement_min
trend := NATURAL_RETRACEMENT
natural_retracement_min := close
else
trend := SECONDARY_RETRACEMENT
else if trend == NATURAL_RETRACEMENT
if close < close[1]
if close >= main_down_min
if natural_retracement_min - close <= close[1] * pivot_distance_ratio * minor_pivot_multiplier
trend := NATURAL_RETRACEMENT
natural_retracement_min := math.min(natural_retracement_min, close)
else
trend := MAIN_DOWN
main_down_min := close
else
trend := MAIN_DOWN
main_down_min := close
else
if close - natural_retracement_min <= close[1] * pivot_distance_ratio * major_pivot_multiplier
trend := NATURAL_RETRACEMENT
else if close > natural_rebound_max
trend := NATURAL_REBOUND
natural_rebound_max := close
else
trend := SECONDARY_REBOUND
else if trend == SECONDARY_REBOUND
if close <= natural_rebound_max and close >= natural_retracement_min
trend := SECONDARY_REBOUND
else if close < natural_retracement_min
trend := NATURAL_RETRACEMENT
natural_retracement_min := close
else
trend := NATURAL_REBOUND
natural_rebound_max := close
else if trend == SECONDARY_RETRACEMENT
if close >= natural_retracement_min and close <= natural_rebound_max
trend := SECONDARY_RETRACEMENT
else if close > natural_rebound_max
trend := NATURAL_REBOUND
natural_rebound_max := close
else
trend := NATURAL_RETRACEMENT
natural_retracement_min := close
// Execute trades based on trend changes
if prev_trend != prev_prev_trend
if trend == MAIN_UP and prev_trend == MAIN_UP
strategy.entry("Long Entry", strategy.long, comment="Long Entry")
else if trend == MAIN_DOWN and prev_trend == MAIN_DOWN
strategy.close("Long Entry", comment = "Long Close")
// Update previous trend
prev_prev_trend := prev_trend
prev_trend := trend