AllTick
R-Breaker Strategy
quantitative tradingPython TradingStrategy Backtesting Market Data

R-Breaker Strategy

Learn how the R-Breaker strategy works, calculate its six price levels with Python, define breakout and reversal rules, and backtest trading signals using historical market data.

AllTick3 min read

The R-Breaker strategy combines breakout trading with reversal signals. For quantitative traders, it offers a rule-based way to identify potential intraday entries using price levels calculated from the previous trading session.

However, calculating the levels is only part of the process. A reliable implementation must also define when signals trigger, how positions change, and how historical data is used to evaluate performance.

This guide explains a common parameterized version of the R-Breaker strategy, provides a runnable Python example, and outlines the checks needed before using it in a quantitative trading system.

How the R-Breaker Strategy Works

The strategy uses the previous session's high, low, and close to calculate six price levels. These levels define potential breakout entries and reversal setups.

Let:

  • (H) = previous session's high
  • (L) = previous session's low
  • (C) = previous session's close

The following example uses parameters (a=0.35), (k=1.07), (c=0.07), and (d=0.25). R-Breaker implementations can differ, so keep the formulas and trading rules consistent within your chosen version.

The Six R-Breaker Levels

1.Reversal observation levels
Sell observation level:

text
[
S_{\text{setup}}=H+a(C-L)
]

Buy observation level:

text
[
B_{\text{setup}}=L-a(H-C)
]

These levels establish potential reversal setups. Reaching one does not automatically generate a trade.
2. Reversal entry levels
Sell reversal entry:

text
[
S_{\text{enter}}=\frac{k}{2}(H+L)-cL
]

Buy reversal entry:

text
[
B_{\text{enter}}=\frac{k}{2}(H+L)-cH
]

A reversal signal occurs when price subsequently crosses the relevant entry level in the opposite direction.
3. Breakout levels
First, calculate the distance between the observation levels:

text
[
D=S_{\text{setup}}-B_{\text{setup}}
]

Buy breakout level:

text
[
B_{\text{break}}=S_{\text{setup}}+dD
]

Sell breakout level:

text
[
S_{\text{break}}=B_{\text{setup}}-dD
]

These outer levels identify potential bullish and bearish breakouts.

R-Breaker Trading Rules

The strategy needs clear entry conditions before it can be backtested.

SignalCondition
Breakout buyPrice crosses above the buy breakout level while flat
Breakout sellPrice crosses below the sell breakout level while flat
Reversal sellPrice reaches the sell observation level, then crosses below the sell reversal-entry level while long
Reversal buyPrice reaches the buy observation level, then crosses above the buy reversal-entry level while short

These are explicit rules for the implementation below, not universal rules for every R-Breaker variant. Stop-losses, position sizing, and session-end exits must be defined separately.

Python Example: Calculate R-Breaker Levels

The following code runs with standard Python and calculates all six levels.

text
def r_breaker(high, low, close,
              a=0.35, k=1.07, c=0.07, d=0.25):
    if high <= low:
        raise ValueError("High must exceed low")
    if not low <= close <= high:
        raise ValueError("Close must be between low and high")

    sell_setup = high + a * (close - low)
    buy_setup = low - a * (high - close)

    sell_enter = (k / 2) * (high + low) - c * low
    buy_enter = (k / 2) * (high + low) - c * high

    width = sell_setup - buy_setup

    return {
        "buy_break": sell_setup + d * width,
        "sell_setup": sell_setup,
        "sell_enter": sell_enter,
        "buy_enter": buy_enter,
        "buy_setup": buy_setup,
        "sell_break": buy_setup - d * width,
    }


if __name__ == "__main__":
    levels = r_breaker(105, 95, 102)

    for name, value in levels.items():
        print(f"{name}: {value:.3f}")

For the example inputs, the calculated levels are:

LevelValue
Buy breakout110.825
Sell observation107.450
Sell reversal entry100.350
Buy reversal entry99.650
Buy observation93.950
Sell breakout90.575

These are illustrative calculations, not actual market prices or backtest results. The function calculates levels only; a complete trading system must implement signal state, order execution, and risk management.

How to Backtest the Strategy

For quantitative traders, the quality of a backtest depends on both the trading rules and the market data.

Use the correct session data. Calculate levels from the previous completed session. Do not use the current session's eventual high, low, or close, as this introduces look-ahead bias.

Check data consistency. Validate timestamps, missing bars, duplicate records, and OHLC values. For continuously traded markets, define a consistent daily cutoff.

Model execution costs. Include transaction fees, slippage, realistic fill assumptions, position sizing, and stop-loss rules. A signal price is not necessarily an achievable execution price.

Test different market conditions. Evaluate the strategy across multiple periods and reserve out-of-sample data for validation. Review net returns, maximum drawdown, turnover, and sensitivity to parameter changes.

Historical performance does not guarantee future results.

Using Market Data APIs for Strategy Research

An API can connect historical strategy testing with current market monitoring. Historical bars support the calculation of previous-session levels and the evaluation of past signals, while real-time updates allow a strategy to monitor whether prices cross predefined thresholds.

AllTick provides REST market-data access and WebSocket streaming. Before integrating either service, verify that the required instrument, historical intervals, session definitions, and data-use permissions meet your research needs.

You can start with the AllTick API documentation to review integration options. For equity-focused projects, the AllTick Stock API page describes its stock-market data coverage.

Common R-Breaker Mistakes

  • Mixing formula variants: Do not combine price levels from different R-Breaker implementations without defining and testing the resulting rules.
  • Ignoring session boundaries: The previous session must match the instrument's trading calendar and chosen cutoff.
  • Assuming perfect fills: Model execution after the signal becomes available rather than assuming every order fills at the trigger price.
  • Optimizing only for past returns: Excessive parameter tuning can produce results that do not generalize to unseen data.

Frequently Asked Questions

Does R-Breaker require tick data?

Not always. Historical OHLC bars can support a close-based implementation. Tick data may be useful when testing more granular triggers or reconstructing the order of intraday price movements.

How often are the levels recalculated?

In this version, levels are calculated from the previous completed session and remain fixed throughout the current session.

Does R-Breaker guarantee profits?

No. Performance depends on market conditions, execution costs, parameter choices, and risk controls. Backtesting helps evaluate a defined implementation but cannot predict future returns with certainty.

Start Testing Your R-Breaker Strategy

The R-Breaker strategy becomes useful when its formulas, signal rules, and execution assumptions are defined consistently. Validate the six levels first, then test the signals with historical data before connecting the strategy to a live market feed.

Review the AllTick API documentation to determine whether its available data supports your chosen instrument and research workflow.

Market data should be used in accordance with the provider's applicable terms. This article is for educational purposes and does not constitute investment advice.

More Trading Strategies

【Dual MA Moving Average Strategy】

Start streaming market data today

Generate a free API key in seconds and connect to every market from one endpoint.