Skip to main content

Breakout

Breakout is a built-in TypeScript strategy from @tradejs/strategy-breakout with weighted signal scoring for long/short breakout scenarios.

Visual overview

Breakout strategy logic

Breakout signal on an illustrative chart

The illustrations are schematic, not market data. Exact thresholds, confirmation rules, and risk parameters come from the active strategy config.

Entry Logic

On each bar, strategy computes boolean signals and opens a position only if:

  • required signals (required: true) are satisfied
  • total score is >= REQUIRED_SCORE_*

Long and short use separate signal maps (SIGNALS_LONG, SIGNALS_SHORT).

Exits

With an open position, strategy closes when:

  • opposite open signal appears (CLOSE_POSITION_BY_OPEN_SIGNAL)
  • MA trend flips against position (CLOSE_POSITION_BY_SMA)

Otherwise returns POSITION_HELD.

Configuration keys

The keys are grouped by purpose. Common runtime and decision-service keys keep the same meaning across the built-in strategies.

GroupKeysPurpose
Runtime and decision servicesENV, INTERVAL, MAKE_ORDERS, CLOSE_OPPOSITE_POSITIONS, BACKTEST_PRICE_MODE, AI_ENABLED, AI_MODE, MIN_AI_QUALITY, ML_ENABLED, ML_THRESHOLDSelect the runtime mode and candle interval, control order placement, and enable optional AI or ML decisions.
Shared indicators and levelsMA_FAST, MA_MEDIUM, MA_SLOW, OBV_SMA, ATR, ATR_PCT_SHORT, ATR_PCT_LONG, BB, BB_STD, MACD_FAST, MACD_SLOW, MACD_SIGNAL, LEVEL_LOOKBACK, LEVEL_DELAYSet the periods used for shared indicators and local support and resistance levels.
Weighted scoreSIGNALS_LONG, SIGNALS_SHORT, REQUIRED_SCORE_LONG, REQUIRED_SCORE_SHORT, ATR_OPENDefine the weighted conditions for each direction, the required score, and the volatility threshold used by the VOLATILE condition.
Entry engineBREAKOUT_USE_ENGINE, BREAKOUT_ENGINE_LOOKBACK, BREAKOUT_ENGINE_DELAY, BREAKOUT_TREND_LOOKBACK, BREAKOUT_ENTRY_MODE, BREAKOUT_CONFIRMATION_BARS, BREAKOUT_RETEST_MAX_BARS, BREAKOUT_RETEST_TOLERANCE_ATR, BREAKOUT_RETEST_TOLERANCE_ATR_LONG, BREAKOUT_RETEST_TOLERANCE_ATR_SHORTEnable the replayable detector and configure its history, level delay, trend window, and breakout, confirmation, or retest entry.
Direction and breakout qualityBREAKOUT_LONG_ENABLED, BREAKOUT_SHORT_ENABLED, BREAKOUT_REQUIRE_FRESH_LEVEL_CROSS, BREAKOUT_REQUIRE_DIRECTIONAL_BODY, BREAKOUT_MIN_BODY_ATR, BREAKOUT_MIN_VOLUME_REL20, BREAKOUT_MIN_ACCEPTANCE_CLOSESEnable each direction and require a fresh cross, directional candle, body size, volume, or accepted closes.
Distance, range, and cooldownBREAKOUT_MAX_DISTANCE_ATR, BREAKOUT_MAX_DISTANCE_ATR_LONG, BREAKOUT_MAX_DISTANCE_ATR_SHORT, BREAKOUT_MIN_TREND_MOVE_ATR, BREAKOUT_MIN_RANGE_ATR, BREAKOUT_MIN_RANGE_ATR_LONG, BREAKOUT_MIN_RANGE_ATR_SHORT, BREAKOUT_MAX_RANGE_ATR, BREAKOUT_MAX_RANGE_ATR_LONG, BREAKOUT_MAX_RANGE_ATR_SHORT, BREAKOUT_COOLDOWN_HOURSLimit breakout distance, trend movement, source-range size, and repeated entries, with directional overrides.
Position and exitsLIMIT, TP_LONG, TP_SHORT, SL_LONG, SL_SHORTSet quote-currency position size and the directional take-profit ladders and stop ratios.

Indicators Used (What Each One Means)

Used in Signal Logic

  • maFast, maSlow — trend direction checks.
  • obv, smaObv — OBV vs OBV-SMA checks.
  • atr — volatility threshold calculation.
  • bbUpper, bbLower — Bollinger breakout checks.
  • highLevel, lowLevel — local breakout/breakdown levels.
  • prevCandle — previous candle for high/low/close comparisons.

Used in Payload

  • correlation — included in indicators for analysis/ML.

Signal Payload

additionalIndicators:

  • highLevel, lowLevel
  • signals (all boolean checks)

Example Runtime Config

{
"ENV": "CRON",
"INTERVAL": "15",
"LIMIT": 100,
"ATR_OPEN": 0.5,
"REQUIRED_SCORE_LONG": 7,
"REQUIRED_SCORE_SHORT": 7,
"TP_LONG": [
{ "profit": 0.1, "rate": 0.25 },
{ "profit": 0.15, "rate": 0.5 }
],
"TP_SHORT": [
{ "profit": 0.05, "rate": 0.25 },
{ "profit": 0.1, "rate": 0.5 }
],
"SL_LONG": 0.06,
"SL_SHORT": 0.03
}

Run

npx @tradejs/cli backtest --user root --config Breakout:base --connector bybit --timeframe 15
npx @tradejs/cli signals --user root --timeframe 15