DoubleTap
DoubleTap is a built-in TypeScript strategy from @tradejs/strategies.
It detects double-bottom and double-top structures, then trades the breakout/breakdown with stop and target prices produced by the pattern engine.
Entry Logic
- Replays candles through
createDoubleTapEngine(...). - Reads
runtimeState.pattern. - Skips until a pattern exists.
- Uses
LONGconfig for a long pattern andSHORTconfig for a short pattern. - Computes
riskDistancefrom current price topattern.stopLossPrice. - Computes
riskRatiofrom target distance divided by risk distance. - Sizes quantity from
MAX_LOSS_VALUE / riskDistance, withFEE_PERCENTbuffer. - Returns
entrywith double-tap figures anddoubleTapContext.
Entry codes:
DOUBLETAP_DOUBLE_BOTTOM_BREAKOUTDOUBLETAP_DOUBLE_TOP_BREAKDOWN
Exits
When a position exists:
DOUBLETAP_OPPOSITE_PATTERN_EXITwhenDOUBLETAP_EXIT_ON_OPPOSITE_PATTERN=trueand the engine detects the opposite pattern.- otherwise
POSITION_EXISTS.
Config Parameters
Shared runtime:
ENV,INTERVAL,MAKE_ORDERS,CLOSE_OPPOSITE_POSITIONSBACKTEST_PRICE_MODEAI_ENABLED,AI_MODE,MIN_AI_QUALITYML_ENABLED,ML_THRESHOLD
Risk and shared indicators:
FEE_PERCENT,MAX_LOSS_VALUEMA_FAST,MA_MEDIUM,MA_SLOWOBV_SMA,ATR,ATR_PCT_SHORT,ATR_PCT_LONGBB,BB_STD,MACD_FAST,MACD_SLOW,MACD_SIGNAL
Pattern model:
DOUBLETAP_PIVOT_LENGTHDOUBLETAP_PIVOT_TOLERANCE_PCTDOUBLETAP_TARGET_FIB_PCTDOUBLETAP_STOP_FIB_PCTDOUBLETAP_MIN_PATTERN_HEIGHT_PCTDOUBLETAP_MAX_BREAKOUT_DISTANCE_PCTDOUBLETAP_EXIT_ON_OPPOSITE_PATTERN
Side configs:
LONG.enable,LONG.direction,LONG.minRiskRatioSHORT.enable,SHORT.direction,SHORT.minRiskRatio
Signal Payload
The strategy stores:
additionalIndicators.doubleTapContext- figures from
buildDoubleTapFigures(...) - stop at
pattern.stopLossPrice - one take-profit at
pattern.targetPrice
Common Skip Reasons
NO_PATTERNPOSITION_EXISTSDEV_TRADE_COOLDOWNSTRATEGY_DISABLEDINVALID_QTYRISK_RATIO:<value>
Validation Notes
Use chart figures to confirm that the detected double top/bottom matches the structure you expected. Pattern engines are sensitive to pivot length and tolerance settings.