Buy when price breaks above 50-bar high (momentum breakout). Exit when price breaks below 25-bar low.
Symbol: BTC | Exchange: Bitfinex
| Year | Return | Win Rate | Trades | Max DD | Sharpe |
|---|---|---|---|---|---|
| 2020 | +69.9% | 36.4% | 11 | 13.8% | 1.17 |
| 2021 | +20.9% | 28.6% | 14 | 32.4% | 0.41 |
| 2022 | -49.0% | 20.0% | 15 | 43.6% | -2.97 |
| 2023 | +45.8% | 42.9% | 14 | 16.1% | 1.20 |
| 2024 | +69.0% | 50.0% | 14 | 19.6% | 1.13 |
| 2025 | +12.8% | 45.5% | 11 | 5.3% | 0.87 |
See strategy file
See strategy file
"""
Strategy: breakout_50
=====================
Buy when price breaks above 50-bar high (momentum breakout).
Exit when price breaks below 25-bar low.
Performance: 5/6 years profitable | Total: +169.6%
"""
import sys
sys.path.insert(0, '/root/trade_rules')
def init_strategy():
return {
'name': 'breakout_50',
'subscriptions': [
{'symbol': 'tBTCUSD', 'exchange': 'bitfinex', 'timeframe': '4h'},
],
'parameters': {
'entry_lookback': 50,
'exit_lookback': 25,
}
}
def process_time_step(ctx):
key = ('tBTCUSD', 'bitfinex')
bars = ctx['bars'].get(key, [])
i = ctx['i']
positions = ctx['positions']
params = ctx['parameters']
entry_lb = params['entry_lookback']
exit_lb = params['exit_lookback']
if i < entry_lb:
return []
actions = []
has_position = key in positions
# Calculate levels
high_n = max(b.high for b in bars[i-entry_lb:i])
low_n = min(b.low for b in bars[i-exit_lb:i])
if not has_position:
# Entry: breakout above N-bar high
if bars[i].close > high_n:
actions.append({
'action': 'open_long',
'symbol': 'tBTCUSD',
'exchange': 'bitfinex',
'size': 1.0,
})
else:
# Exit: breakdown below N/2-bar low
if bars[i].close < low_n:
actions.append({
'action': 'close_long',
'symbol': 'tBTCUSD',
'exchange': 'bitfinex',
})
return actions