Breakout with RSI Filter
This strategy builds a long breakout setup on BTCUSDT 4h using a highest resistance channel, an RSI filter, and a lowest exit channel.
The position opens when the close breaks above the previous candle’s resistance while RSI stays below an optimised ceiling. It closes if the breakout fails and price falls back below the lower channel, or if RSI drops below its exit threshold.
The exploration covers both channel lengths, the RSI length, and the two RSI thresholds, with the constraints exit_low.length < breakout_high.length and rsi_exit_floor < rsi_entry_ceiling. This strategy runs 911,625 backtests. Only runs with at least 20 positions and a maximum drawdown of 25% are kept, then ranked by Calmar ratio.
# Illustrative example only, do not use for live trading. Public domain (CC0 1.0).
# Backtest configuration
[backtest]
symbol = "BINANCE:BTCUSDT"
timeframe = "240"
start_date = 2024-01-01
end_date = 2026-01-01
initial_capital = 1000
# 95% keeps position size below 1x to avoid an immediate 1x margin call
# caused by trading fees and the gap between signal and execution price.
default_qty_value = 95
# Optimization objective:
# rank accepted runs by Calmar ratio to favor return relative to drawdown.
[[objective]]
id = "calmar"
formula = "calmar_ratio"
ascending = false
# Enable detailed trade output in backtest results.
[logging]
include_trades = true
timestamp_enabled = false
# Result acceptance filters:
# - require at least 20 trades to avoid overfitting on sparse activity
# - cap maximum drawdown at 25%
[filters]
min_required_positions = 20
max_allowed_drawdown = 25
# Breakout channel:
# track the highest high over the last N candles to define resistance.
[[highest]]
id = "breakout_high"
source = "high"
length.start = 10
length.stop = 60
length.step = 2
# Exit channel:
# track the lowest low over the last N candles to detect breakout failure.
[[lowest]]
id = "exit_low"
source = "low"
length.start = 10
length.stop = 60
length.step = 2
# RSI filter:
# momentum must stay below a configurable ceiling at entry time.
[[rsi]]
id = "rsi_filter"
source = "close"
length.start = 8
length.stop = 18
# RSI ceiling allowed at entry:
# an RSI that is already too high suggests an overextended breakout.
[[constant]]
id = "rsi_entry_ceiling"
start = 50
stop = 80
step = 2
# RSI exit floor:
# if momentum drops below this level, the position is closed.
[[constant]]
id = "rsi_exit_floor"
start = 20
stop = 50
step = 2
# Hyperparameter constraints:
# - keep the exit channel shorter than the breakout channel
# - keep the RSI exit floor below the RSI entry ceiling
[constraints]
condition = "exit_low.length < breakout_high.length and rsi_exit_floor < rsi_entry_ceiling"
# Entry point of the state machine.
# The strategy starts by watching for the next valid breakout close.
[start]
id = "entry_start"
next_block_id = "wait_breakout"
# Entry condition:
# - the close breaks above the resistance computed on the previous candle
# - RSI remains below the optimised ceiling
# If both are true, execution moves to "open_long".
[[condition]]
id = "wait_breakout"
condition = "close > breakout_high[1] and rsi_filter < rsi_entry_ceiling"
next_block_id = "open_long"
# Open a long position, then move to the exit-monitoring block.
[[entry]]
id = "open_long"
order_id = "breakout_long"
direction = "long"
next_block_id = "monitor_exit"
# Once the position is open, the strategy monitors two exits:
# - breakout failure if price falls back below the lower channel
# - momentum loss if RSI drops below the exit threshold
# As soon as one child validates, the OR block jumps to the shared close block.
[[or]]
id = "monitor_exit"
conditions = ["breakout_failure", "momentum_loss"]
next_block_id = "close_long"
# Exit 1:
# price falls below the lower exit channel computed on the previous candle.
[[condition]]
id = "breakout_failure"
condition = "close < exit_low[1]"
# Exit 2:
# the breakout still exists structurally, but RSI has lost too much strength.
[[condition]]
id = "momentum_loss"
condition = "rsi_filter < rsi_exit_floor"
# Close the position and jump directly back
# to the next breakout wait state.
[[close]]
id = "close_long"
order_id = "breakout_long"
next_block_id = "wait_breakout"Console output
[info]
[info] ================================================================
[info] Whale Engine 1.0.1068
[info] Backtesting & Strategy Optimization Software
[info] (c) 2025 Almageste - https://Whale-E.com
[info] ================================================================
[info] Strategy : C:\Whale-E_Project\dragon\doc\examples\rsi-filtered-breakout.toml
[info] Using 31 threads for parallel computation.
[info] Using database cache directory: C:\Users\Tony\AppData\Local\Almageste\Whale-E
[info] Detected 1 grid in the strategy.
[info] Analyzing hyperparameter grids.
[info] Grid 1/1 has 911 625 valid combinations out of 1 903 616 total combinations.
[info] Hyperparameter grid analysis completed in 7 ms.
[info] Starting exploration of 1 grid.
[info] [Run 1/1] Grid 1 BINANCE:BTCUSDT (240): Price series ready.
[info] [Run 1/1] Grid 1 BINANCE:BTCUSDT (240): Exploring 911 625 valid combinations.
[info] [Run 1/1] Grid 1 BINANCE:BTCUSDT (240): Completed in 04s 676ms with 911 625 backtests, 12 093 168 positions, and 845.9M candles/s.
[info] [Run 1/1] 123 098 backtests exceeded the maximum allowed drawdown.
[info] [Run 1/1] 259 441 backtests fell below the minimum required number of positions.
[info] [Run 1/1] 344 315 backtests opened no positions.
[info] Completed 911 625 backtests in total.
[info]
[info] +======================================================================+
[info] | OBJECTIVE RANKING |
[info] | Name: calmar |
[info] | Sort order: descending |
[info] +======================================================================+
[info]
[info] ========================================================================
[info] Result 1 | score 8.049818639128 | G1C246180 | BINANCE:BTCUSDT | 240
[info] ========================================================================
[info]
[info] Backtest Settings
[info] --------------------------------------------------------
[info] Strategy | rsi-filtered-breakout
[info] Timezone | UTC
[info] Price history start date |
[info] Backtest start | 2024-01-01 00:00:00
[info] Backtest end | 2026-01-01 03:59:59
[info] Initial capital | 1000.00 USDT
[info] Quantity type | percent_of_equity
[info] Default quantity value | 95.00 %
[info] Long size multiplier | x1.00
[info] Short size multiplier | x1.00
[info] Pyramiding | 1
[info] Long margin | 100.00 %
[info] Short margin | 100.00 %
[info] Process orders on close | No
[info] Bar Magnifier | No
[info] Close open position at end | Yes
[info] Close entries rule | fifo
[info] Backtest fill limits assumption | 0
[info] Automatic slippage | No
[info] Automatic slippage ratio | 0.000000
[info] Slippage | 0
[info] Commission type | percent
[info] Commission value | 0.100000 %
[info] --------------------------------------------------------
[info]
[info] Hyperparameters
[info] ---------------------------------------
[info] breakout_high.length | 34
[info] exit_low.length | 18
[info] rsi_entry_ceiling | 74.000000000000
[info] rsi_exit_floor | 32.000000000000
[info] rsi_filter.length | 9
[info] ---------------------------------------
[info]
[info] Overview
[info] --------------------------------------------------------------------------------
[info] Total P&L | Max equity drawdown | Trades | Profitable trades | Profit factor
[info] --------------------------------------------------------------------------------
[info] 1355.93 USDT | 155.09 USDT | 20 | 60.00 % | 4.933
[info] 135.59 % | 6.63 % | | 12/20 |
[info] --------------------------------------------------------------------------------
[info]
[info] Performance
[info] --------------------------------------------------------------
[info] Metric | All | Long | Short
[info] --------------------------------------------------------------
[info] Open P&L | 0.00 USDT | |
[info] | 0.00 % | |
[info] --------------------------------------------------------------
[info] Net profit | 1355.93 USDT | 1355.93 USDT | 0.00 USDT
[info] | 135.59 % | 135.59 % | 0.00 %
[info] --------------------------------------------------------------
[info] Gross profit | 1700.72 USDT | 1700.72 USDT | 0.00 USDT
[info] | 170.07 % | 170.07 % | 0.00 %
[info] --------------------------------------------------------------
[info] Gross loss | 344.79 USDT | 344.79 USDT | 0.00 USDT
[info] | 34.48 % | 34.48 % | 0.00 %
[info] --------------------------------------------------------------
[info] Commission paid | 77.07 USDT | 77.07 USDT | 0.00 USDT
[info] --------------------------------------------------------------
[info] Buy & hold return | 1075.24 USDT | |
[info] | 107.52 % | |
[info] --------------------------------------------------------------
[info] Max equity run-up | 1612.48 USDT | |
[info] | 61.74 % | |
[info] --------------------------------------------------------------
[info] Max equity drawdown | 155.09 USDT | |
[info] | 6.63 % | |
[info] --------------------------------------------------------------
[info]
[info] Trade Analysis
[info] ----------------------------------------------------------------------
[info] Metric | All | Long | Short
[info] ----------------------------------------------------------------------
[info] Total trades | 20 | 20 | 0
[info] ----------------------------------------------------------------------
[info] Total open trades | 0 | |
[info] ----------------------------------------------------------------------
[info] Winning trades | 12 | 12 | 0
[info] ----------------------------------------------------------------------
[info] Losing trades | 8 | 8 | 0
[info] ----------------------------------------------------------------------
[info] Percent profitable | 60.00 % | 60.00 % | 0.00 %
[info] ----------------------------------------------------------------------
[info] Avg P&L | 67.80 USDT | 67.80 USDT | 0.00 USDT
[info] | 4.98 % | 4.98 % | 0.00 %
[info] ----------------------------------------------------------------------
[info] Avg winning trade | 141.73 USDT | 141.73 USDT | 0.00 USDT
[info] | 9.62 % | 9.62 % | 0.00 %
[info] ----------------------------------------------------------------------
[info] Avg losing trade | 43.10 USDT | 43.10 USDT | 0.00 USDT
[info] | 2.00 % | 2.00 % | 0.00 %
[info] ----------------------------------------------------------------------
[info] Largest winning trade | 396.02 USDT | 396.02 USDT | 0.00 USDT
[info] ----------------------------------------------------------------------
[info] Largest winning trade percent | 31.10 % | 31.10 % | 0.00 %
[info] ----------------------------------------------------------------------
[info] Largest losing trade | 98.02 USDT | 98.02 USDT | 0.00 USDT
[info] ----------------------------------------------------------------------
[info] Largest losing trade percent | 4.36 % | 4.36 % | 0.00 %
[info] ----------------------------------------------------------------------
[info]
[info] Risk and Performance Ratios
[info] ---------------------------------------------
[info] Metric | All | Long | Short
[info] ---------------------------------------------
[info] Sharpe ratio | 2.030 | |
[info] ---------------------------------------------
[info] Sortino ratio | 3.115 | |
[info] ---------------------------------------------
[info] Calmar ratio | 8.050 | |
[info] ---------------------------------------------
[info] Profit factor | 4.933 | |
[info] ---------------------------------------------
[info] Market Exposure | 27.65 % | 27.65 % | 0.00 %
[info] ---------------------------------------------
[info] Margin call | 0 | 0 | 0
[info] ---------------------------------------------
[info]
[info] Trade List
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] Trade # | Type | Date | Signal | Price | Qty | P&L | Run-up | Drawdown | Cumulative P&L
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 20 Long | Exit | 2025-12-01 04:00:00 | breakout_long | 86346.13 USDT | 2234.64 USDT | -98.02 USDT | 78.80 USDT | -100.56 USDT | 1355.93 USDT
[info] | | | | | | -4.21 % | 3.38 % | -4.32 % | 135.59 %
[info] | Entry | 2025-11-26 20:00:00 | breakout_long | 89957.37 USDT | 2328.10 USDT | | | |
[info] | | | | | 0.02588 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 19 Long | Exit | 2025-10-29 16:00:00 | breakout_long | 111509.74 USDT | 2330.55 USDT | -44.68 USDT | 59.86 USDT | -143.57 USDT | 1453.96 USDT
[info] | | | | | | -1.88 % | 2.52 % | -6.05 % | 145.40 %
[info] | Entry | 2025-10-21 16:00:00 | breakout_long | 113422.60 USDT | 2370.53 USDT | | | |
[info] | | | | | 0.02090 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 18 Long | Exit | 2025-09-19 20:00:00 | breakout_long | 115125.13 USDT | 2377.33 USDT | 40.12 USDT | 99.80 USDT | -63.81 USDT | 1498.64 USDT
[info] | | | | | | 1.72 % | 4.27 % | -2.73 % | 149.86 %
[info] | Entry | 2025-09-05 08:00:00 | breakout_long | 112954.32 USDT | 2332.51 USDT | | | |
[info] | | | | | 0.02065 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 17 Long | Exit | 2025-08-15 20:00:00 | breakout_long | 116936.28 USDT | 2337.56 USDT | 3.66 USDT | 156.68 USDT | -20.06 USDT | 1458.52 USDT
[info] | | | | | | 0.16 % | 6.72 % | -0.86 % | 145.85 %
[info] | Entry | 2025-08-07 12:00:00 | breakout_long | 116519.54 USDT | 2329.23 USDT | | | |
[info] | | | | | 0.01999 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 16 Long | Exit | 2025-07-01 12:00:00 | breakout_long | 106605.79 USDT | 2331.47 USDT | -45.63 USDT | 4.47 USDT | -49.95 USDT | 1454.85 USDT
[info] | | | | | | -1.92 % | 0.19 % | -2.10 % | 145.49 %
[info] | Entry | 2025-06-29 12:00:00 | breakout_long | 108477.12 USDT | 2372.39 USDT | | | |
[info] | | | | | 0.02187 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 15 Long | Exit | 2025-05-28 16:00:00 | breakout_long | 107107.31 USDT | 2377.78 USDT | 9.76 USDT | 120.31 USDT | -101.25 USDT | 1500.48 USDT
[info] | | | | | | 0.41 % | 5.09 % | -4.28 % | 150.05 %
[info] | Entry | 2025-05-19 00:00:00 | breakout_long | 106454.27 USDT | 2363.28 USDT | | | |
[info] | | | | | 0.02220 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 14 Long | Exit | 2025-05-05 00:00:00 | breakout_long | 94277.61 USDT | 2381.45 USDT | 258.69 USDT | 352.47 USDT | -29.03 USDT | 1490.73 USDT
[info] | | | | | | 12.20 % | 16.62 % | -1.37 % | 149.07 %
[info] | Entry | 2025-04-11 20:00:00 | breakout_long | 83858.28 USDT | 2118.26 USDT | | | |
[info] | | | | | 0.02526 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 13 Long | Exit | 2025-03-28 08:00:00 | breakout_long | 85212.98 USDT | 2121.80 USDT | -9.74 USDT | 80.84 USDT | -58.35 USDT | 1232.03 USDT
[info] | | | | | | -0.46 % | 3.80 % | -2.74 % | 123.20 %
[info] | Entry | 2025-03-19 20:00:00 | breakout_long | 85433.38 USDT | 2127.29 USDT | | | |
[info] | | | | | 0.02490 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 12 Long | Exit | 2025-02-24 16:00:00 | breakout_long | 94323.95 USDT | 2126.06 USDT | -96.73 USDT | 21.50 USDT | -106.03 USDT | 1241.77 USDT
[info] | | | | | | -4.36 % | 0.97 % | -4.77 % | 124.18 %
[info] | Entry | 2025-02-20 20:00:00 | breakout_long | 98422.80 USDT | 2218.45 USDT | | | |
[info] | | | | | 0.02254 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 11 Long | Exit | 2025-01-27 00:00:00 | breakout_long | 102620.01 USDT | 2229.93 USDT | 127.62 USDT | 281.26 USDT | -28.09 USDT | 1338.50 USDT
[info] | | | | | | 6.08 % | 13.39 % | -1.34 % | 133.85 %
[info] | Entry | 2025-01-14 12:00:00 | breakout_long | 96548.04 USDT | 2097.99 USDT | | | |
[info] | | | | | 0.02173 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 10 Long | Exit | 2025-01-07 20:00:00 | breakout_long | 96451.99 USDT | 2101.69 USDT | -10.33 USDT | 128.44 USDT | -19.72 USDT | 1210.89 USDT
[info] | | | | | | -0.49 % | 6.09 % | -0.93 % | 121.09 %
[info] | Entry | 2025-01-02 12:00:00 | breakout_long | 96733.00 USDT | 2107.81 USDT | | | |
[info] | | | | | 0.02179 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 9 Long | Exit | 2024-11-25 20:00:00 | breakout_long | 94669.49 USDT | 2131.96 USDT | 396.02 USDT | 508.92 USDT | -28.71 USDT | 1221.22 USDT
[info] | | | | | | 22.84 % | 29.35 % | -1.66 % | 122.12 %
[info] | Entry | 2024-11-08 20:00:00 | breakout_long | 76912.58 USDT | 1732.07 USDT | | | |
[info] | | | | | 0.02252 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 8 Long | Exit | 2024-10-21 16:00:00 | breakout_long | 67341.02 USDT | 1739.42 USDT | 75.15 USDT | 133.16 USDT | -15.13 USDT | 825.20 USDT
[info] | | | | | | 4.52 % | 8.01 % | -0.91 % | 82.52 %
[info] | Entry | 2024-10-14 04:00:00 | breakout_long | 64300.00 USDT | 1660.87 USDT | | | |
[info] | | | | | 0.02583 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 7 Long | Exit | 2024-09-30 04:00:00 | breakout_long | 64553.68 USDT | 1668.07 USDT | 85.08 USDT | 136.99 USDT | -52.24 USDT | 750.05 USDT
[info] | | | | | | 5.38 % | 8.66 % | -3.30 % | 75.01 %
[info] | Entry | 2024-09-17 16:00:00 | breakout_long | 61135.49 USDT | 1579.74 USDT | | | |
[info] | | | | | 0.02584 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 6 Long | Exit | 2024-09-16 16:00:00 | breakout_long | 57881.70 USDT | 1582.49 USDT | -12.77 USDT | 63.81 USDT | -25.86 USDT | 664.97 USDT
[info] | | | | | | -0.80 % | 4.00 % | -1.62 % | 66.50 %
[info] | Entry | 2024-09-12 04:00:00 | breakout_long | 58232.73 USDT | 1592.08 USDT | | | |
[info] | | | | | 0.02734 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 5 Long | Exit | 2024-08-27 00:00:00 | breakout_long | 62834.00 USDT | 1596.61 USDT | 28.96 USDT | 85.59 USDT | -48.45 USDT | 677.74 USDT
[info] | | | | | | 1.85 % | 5.47 % | -3.09 % | 67.77 %
[info] | Entry | 2024-08-21 20:00:00 | breakout_long | 61570.00 USDT | 1564.49 USDT | | | |
[info] | | | | | 0.02541 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 4 Long | Exit | 2024-07-23 20:00:00 | breakout_long | 65536.00 USDT | 1575.49 USDT | 154.66 USDT | 226.88 USDT | -59.97 USDT | 648.79 USDT
[info] | | | | | | 10.90 % | 15.99 % | -4.23 % | 64.88 %
[info] | Entry | 2024-07-10 08:00:00 | breakout_long | 58977.99 USDT | 1417.83 USDT | | | |
[info] | | | | | 0.02404 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 3 Long | Exit | 2024-04-24 16:00:00 | breakout_long | 64610.10 USDT | 1419.48 USDT | -26.88 USDT | 32.15 USDT | -27.47 USDT | 494.13 USDT
[info] | | | | | | -1.86 % | 2.22 % | -1.90 % | 49.41 %
[info] | Entry | 2024-04-22 04:00:00 | breakout_long | 65703.49 USDT | 1443.51 USDT | | | |
[info] | | | | | 0.02197 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 2 Long | Exit | 2024-03-14 20:00:00 | breakout_long | 69415.09 USDT | 1463.27 USDT | 346.78 USDT | 440.19 USDT | -2.99 USDT | 521.01 USDT
[info] | | | | | | 31.10 % | 39.48 % | -0.27 % | 52.10 %
[info] | Entry | 2024-02-26 16:00:00 | breakout_long | 52842.33 USDT | 1113.92 USDT | | | |
[info] | | | | | 0.02108 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------
[info] 1 Long | Exit | 2024-02-17 16:00:00 | breakout_long | 50984.56 USDT | 1125.23 USDT | 174.23 USDT | 215.79 USDT | -25.48 USDT | 174.23 USDT
[info] | | | | | | 18.34 % | 22.72 % | -2.68 % | 17.42 %
[info] | Entry | 2024-01-29 20:00:00 | breakout_long | 42995.99 USDT | 948.92 USDT | | | |
[info] | | | | | 0.02207 | | | |
[info] --------------------------------------------------------------------------------------------------------------------------------------------------