Harmonics XABCD Strategy

Created 12 Jul 2025 · Updated 12 Jul 2025

The Harmonics XABCD Strategy is a Premium mechanical strategy for the NinjaTrader 8 platform. The strategy can be used to pass trader funding programs.

Prerequisites

To properly use this strategy you should have the following prerequisites available.


Important Disclaimer

We strongly recommend that you never run your algorithmic trading systems on your hard-earned real money. You should always minimize your risk and run your strategies on trader funding programs, so the maximum amount you risk losing is the monthly subscription fee you pay those programs.

This strategy is based on entering trades following XABCD harmonic patterns. These patterns are defined by swing points generally named X, A, B, C, and D, which define legs that ratios can be calculated on — for example, the AB/XA ratio, obtained by dividing the AB leg's retracement by the XA leg's initial move. When every leg respects a specific ratio rule set, the pattern is recognized.

If you want to learn more about XABCD harmonic patterns, have a look at the Harmonics XABCD indicator page.

Entry Setup Examples

The following examples were handpicked to show best-case scenarios where the recognition engine detects valid patterns. In real-time trading, a detected pattern won't always lead to a winning trade — that's the reality of trading, where the goal is long-term profitability rather than a guaranteed win on every signal. All examples below are taken on the MES instrument on the 1-minute timeframe.

Example #1: Bullish Butterfly

The strategy recognized a bullish butterfly pattern. One bar after the pattern was detected, the strategy entered a long trade targeting 1.5x the stop distance (the D swing price of the pattern), leading to a winning trade. In this example, the strategy is set to enter immediately on bar close, without waiting for a confirmation bar.

Bullish Butterfly harmonic pattern example
Click to enlarge
Example #2: Overlapping Butterfly Patterns

This example shows an aspect of the strategy that occurs often: overlapping patterns. Two butterfly patterns were detected on top of each other — in this case the strategy enters on the first valid pattern.

Overlapping Butterfly patterns example
Click to enlarge
Example #3: Bullish Gartley Following the Trend

The Gartley XABCD harmonic pattern is a trend-following pattern. Two consecutive trades were taken from two Gartley patterns aligned with the trend.

Bullish Gartley harmonic pattern example
Click to enlarge
Example #4: Loss Avoided With the Trend Filter

This example illustrates the Trend Filter avoiding trades counter to the trend. The filter analyzes swing points to determine the prevailing direction — an upward sequence of swing points restricts the strategy to long entries only, which avoided two losing short trades on this chart that would otherwise have triggered from valid Gartley patterns against the trend.

Trend filter avoiding counter-trend trades
Click to enlarge

Features

The Harmonics XABCD strategy has a set of unique features:

  • Robust in-house implementation of the XABCD harmonics pattern-recognition algorithm
  • No pending orders are placed — only market orders, which produces no rejected or partially filled orders
  • Full-auto strategy that can be scaled into unlimited instances with a single license
  • Precise backtesting capabilities following NinjaTrader's official best practices, achieving precise entry/exit backtesting at the tick level
  • A robust in-house order management library, resistant to connection loss, that works seamlessly on Rithmic or Tradovate accounts
  • On-chart command buttons to manually manage positions when needed
  • A very lightweight strategy that can run in multiple instances even on a low-power VPS
Dynamic Quantity and Risk Management

As with all our strategies, this strategy implements two methods for setting the quantity of open positions:

  • Fixed Quantity: uses the same quantity for every position. If the stop loss is variable between positions, win/loss amounts will vary too.
  • Dynamic Risk-Adjusted Quantity: calculates each position's quantity from its stop loss, the maximum risk (in $) allowed per position, and the maximum allowed quantity — producing equal win/loss amounts across all positions regardless of stop loss width.
Position Management

As with all our strategies, this strategy implements multiple position management methods:

  • ATM Strategy: delegate position management entirely to your own ATM strategy, selected from a drop-down.
  • Classical Trailing Stop: trails the stop loss based on a trigger and a trailing amount.

The strategy also allows setting the stop loss based on multiple strategies and the take profit based on a ratio — see the Parameters section for details.

Account Management

The strategy implements daily stop-trading triggers based on the net winning position count, the net losing position count, or a target realized net profit or net loss.

Parameters

We try to keep the parameters to a minimum — only the most important are exposed.

General
Execute Historical TradesEnables executing trades when the strategy runs in Historical, Backtest, or Optimization mode — useful to test performance on past days, but should be unchecked when running Live.
Daily TakeProfit TargetThe strategy stops for the day once this daily take-profit amount is reached. Ignored when set to 0.
Daily StopLoss LimitThe strategy stops for the day once the daily loss limit is reached (positive value — e.g. 300 stops trading once realized PnL ≤ -$300). Ignored when set to 0.
Stop @ Winning CountStops trading for the day once the net winning-trade count reaches this value. Ignored when set to 0.
Stop @ Losing CountStops trading for the day once the net losing-trade count reaches this value. Ignored when set to 0.
Execute on Different InstrumentExecutes trades on a different instrument than the active chart's — e.g. run logic on Minis but execute on Micros. All risk calculation happens on the execution instrument, and trades on a different instrument aren't drawn on the chart.
Execution InstrumentChoose from a list of Micros available on your NinjaTrader connection as the instrument trades execute on. Trades won't be drawn on the chart in this case.
Order LabelA label suffixed to every position sent to the broker, useful to differentiate your orders from other users of the same strategy.
Enable/Disable Trading Days Restricts trading on certain weekdays.
  • Trade Mondays: enables trading Mondays and Sunday night when futures markets open
  • Trade Tuesdays, Wednesdays, Thursdays, Fridays: same, per weekday
XABCD Harmonics
Swing PeriodSets how many bars must separate two swings of the same type before a new swing invalidates the previous one. Increasing this parameter reduces the overall number of swings detected; decreasing it increases them. It has a significant impact on pattern quality — more swings mean more patterns, and vice versa.
Show Price SwingsEnables/disables drawing a mark below/above swing price points — useful to see how market structure is analyzed, since swing points are the building blocks of the pattern-recognition algorithm.
Swing Bullish Color / Swing Bearish ColorSets the color brush used for low (bullish) and high (bearish) swing points.
Swing Opacity (1-100)Opacity of the swing points drawing — 1 is transparent, 100 is fully opaque.
Enable Gartley / Enable Bat / Enable Crab / Enable Butterfly / Enable Shark / Enable CypherEnables/disables trading each specific harmonic pattern.
Gartley/Bat/Crab/Butterfly/Shark/Cypher Ratio Tolerance %Sets the tolerance, in percentage, applied to each pattern's leg ratio rules — e.g. with a 10% tolerance, a leg ratio that should be around 0.368 can range between 0.368 - 10% and 0.368 + 10%.
Entry Setup
Time Zone The time zone used for the Trade Time parameter below. Futures markets operate on US Eastern time (EST), so this lets you specify the trading interval relative to your own machine's time zone instead.
  • EST, CET, or Local Time
Trade Time (hh:mm-hh:mm,...)Time interval sequence during which the strategy is allowed to place trades — e.g. 09:30-16:15 for regular trading hours in EST. Multiple intervals can be listed in increasing order, e.g. "00:01-08:00,09:55-15:55,18:01-23:59" to cover extended hours with a gap around a volatile period, cut at midnight to avoid day-rollover issues.
Quantity Strategy
  • Fixed Quantity: fixed quantity per trade; skipped if the evaluated risk exceeds Target Risk Per Trade ($)
  • Risk Adjusted: dynamic contract size, calculated from the stop loss price and Target Risk Per Trade ($)
Max QtyMaximum allowed quantity when Risk Adjusted is selected — useful since some prop firms enforce order-quantity limits that can invalidate an account.
Entry Mode The trigger used to enter a trade once an XABCD pattern is recognized and validated.
  • Immediate on Bar Close: enters a trade as soon as the pattern is confirmed on the next bar close
  • Wait For Bar Confirmation: waits for a confirmation bar — a bullish bar closing above its previous bar's high for a long entry, or a bearish bar closing below its previous bar's low for a short entry
SuperTrend Entry FilterRestricts long entries to when SuperTrend is bullish and short entries to when it's bearish.
Swing Trend Entry FilterFilters entries by comparing the XABCD pattern's first swing point to the previous price swing — a bullish entry requires the previous swing to be below the pattern (continuation of an uptrend), and a bearish entry requires it to be above.
Order QtyUsed only when Quantity Strategy is Fixed — the fixed quantity per trade.
Order Management
Order Management Strategy
  • ATM Strategy: delegates position management entirely to a NinjaTrader ATM strategy template of your choice
  • Classic Trail Stop: trails the stop loss based on a trigger and a trailing amount (see Trailing Stop Parameters below)
  • None: the stop loss defined by Target Risk Per Trade ($) is used instead
ATM Strategy Template NameOnly used with the ATM Strategy order management method — the exact template name of your custom ATM strategy. Must match an existing template, or no position will be opened.
Scale out % Qty at % TargetCloses a percentage of the position's quantity once price hits a percentage of the profit target (rounded down when fractional — e.g. 50% of a 5-lot position closes 2 contracts).
Scale out at % TargetThe percentage of the profit target that triggers the scale-out mechanism.
Scale out % QtyThe percentage of the quantity closed by the scale-out mechanism.
Enable Price BreakevenEnables/disables the price-based breakeven mechanism.
Breakeven Price Strategy
  • Points: breakeven triggers based on points
  • Percentage: breakeven triggers based on percentage of take profit reached
Breakeven Price TriggerAvailable if price-based breakeven is enabled — the trigger value needed to move the stop loss to breakeven.
StopLoss Strategy
  • Pattern Defined: derived from the XABCD pattern's own structure
  • Last Swing: the most recent swing high (short) or swing low (long)
  • Fixed Currency Value: only Target Risk Per Trade ($) is used
  • Points: a fixed number of points from entry
TakeProfit Strategy
  • Fixed Currency Value: based on Take Profit Currency
  • Points: a fixed number of points from entry
  • Pattern Extreme: the pattern's opposite extreme point from the entry price (generally point A or C, depending on the pattern)
  • Fixed win/loss ratios: 0.5:1 through 6:1
Target Risk Per Trade ($)Maximum risk, in dollars, per position — used before opening a trade to verify the calculated stop loss respects this limit; if not, the trade is skipped.
Max Allowed Risk Per ($)Only used with Risk Adjusted quantity — controls how far the real calculated risk is allowed to deviate from the Target Risk (since an exact match is rarely possible).
Stop Loss Points / Take Profit PointsAvailable when the respective strategy is set to Points.
Stoploss offset PointsAdds an offset, in points, to the calculated stop loss level — used when computing risk per trade.
Take Profit CurrencyThe take-profit amount in dollars, used when the Fixed Currency Value strategy is selected.
Trailing Stop Parameters
Trailing Stop Strategy
  • Points: trigger and trailing amount calculated in points from entry
  • Ratio: calculated as a ratio of the stop loss value, mirrored on the winning side
Trailing Stop TriggerThe trigger (in points or ratio) for the Classic Trail Stop method.
Trail AmountThe amount (in points or ratio) trailed once the trigger is hit.
Super Trend
Visible only when the SuperTrend Entry Filter parameter is enabled.
SuperTrend ModeATR-based, or Adaptive (based on candle close/high/low).
Period / Multiplier / Moving Avg. Type / SmoothStandard SuperTrend calculation parameters — period, band multiplier, moving-average type, and smoothing period.
Command Buttons
The strategy exposes manual command buttons on the Chart Trader panel — make sure it's displayed on your active chart.
Arm/Disarm ButtonsManually enable/disable entering long or short trades — useful if you have a directional bias.
Close Position ButtonImmediately flattens the position on the active instrument without restarting the strategy, which keeps looking for new trades afterward.
Increase / Decrease Qty ButtonAdjusts the current active position's quantity by ±1 contract.
Set Breakeven ButtonMoves the open position's stop loss to breakeven, if doing so would improve it.

Performance Reports

Past results are not a guarantee of future results. All backtesting results are for indicative purposes only.

  • Commissions are included, using NinjaTrader's Lifetime license commission schema, for realistic results.
  • We follow NinjaTrader's official guide for precise intrabar-granularity backtesting using additional tick-level data series, and only use market orders — never pending orders — in both real-time and backtest modes.

No performance reports have been uploaded for this strategy yet.

Download & Installation Instructions

License Requirements

At automated-trading.ch you can choose to either purchase a monthly subscription to use our premium products, or use our free products without subscribing.

In both cases, you need to create an account so you can get a License you can use for both premium and free products.

To obtain your license, simply sign up and then get your license on the billing page.

Important: This is a Premium product. It can be run in Backtest, Playback, and Optimization modes for free; an active Premium subscription is required to run it live.
Download
Sign in to download this file.
Latest Version v1.0.0.1 · Published 1 year ago
This file was downloaded 211 times. Last download was 1 day ago.

You can also download this strategy — and every other automated-trading.ch strategy or indicator — anytime from your centralized Downloads page.

Installation Steps
1
Import the downloaded .zip file into NinjaTrader using the Import NinjaScript menu item.
2
Open a new chart window, making sure the Tick Replay checkbox is checked (if you don't see it, go to Tools → Options → Market Data and enable Show Tick Replay).
3
Right-click the chart and choose Strategies (or press Ctrl+S) to open the Add New Strategy dialog, and make sure the Enabled checkbox is checked.
4
After adding the strategy, it runs on the chart's historical data first, then switches to Real-Time mode and adds a license text box to the Chart Trader panel — make sure that panel is displayed.
5
Paste your license (found on the billing page) into the text box and click Check License.
6
Once verified, the "Check License" button turns green along with the next verification date — this only needs to be repeated after that date.
7
Without an active subscription, the strategy can still be run in Playback and Historical modes to test it first.

Frequently Asked Questions

General

Using a VPS is good but not imperative — a low-cost Windows VPS instance is sufficient for most users.

Yes, as long as each instance runs on a unique instrument — NinjaTrader aggregates orders into one position per instrument per account, so running two instances on the same instrument won't work.

You can, but running multiple instances of the strategy directly is usually a better solution — the license allows unlimited instances across multiple machines.

Yes — the strategy is designed for exactly that, and works seamlessly on Rithmic, NinjaTrader brokerage, Tradovate, or any other provider connected to your NinjaTrader platform.

It's designed to be fully automatic, but its command buttons also let you manage trades manually if you'd rather run it semi-auto.

Automated strategies trade around the clock, execute faster and more precisely, remove psychology and sentiment from the equation, and can scale to dozens or hundreds of instances — producing genuinely passive income rather than another stressful manual job.

Yes — if you have an idea that could improve the strategy, use the contact page to get in touch.

No, the source code is protected for copyright reasons.
Billing

Yes, you can cancel your subscription from the account page at any time to prevent future payments. We can't refund the unused portion of your subscription, but you'll be able to use it for the remainder of the billing cycle.

No, we don't offer a trial subscription plan, but you can download and test the product in backtest and playback modes before subscribing.

We do not offer full or partial refunds, but you may cancel your subscription at any time to stop future payments.
Skeptics

I've been a professional software developer since 2010 and have developed automated trading strategies since 2012, both for myself and for clients worldwide — I've also worked in finance and investment banking. I'm not a marketer, and I don't outsource strategy development.

I'm not selling it — I'm renting it, as an additional income source alongside diversifying my own trading. The strategy is purely mechanical, with no hidden quantitative edge that erodes as more people use it.

Pending (limit) orders offer better price execution and some protection against connectivity issues, but they can be rejected under high volatility, need active management, and are visible to the broker. Market orders guarantee execution regardless of volatility, are invisible to the broker before submission, and execute faster — the only real drawback is that a lost connection prevents sending them at all. NinjaTrader's MIT (market-if-touched) orders are a solid alternative if you specifically want pending-order behavior.

We follow NinjaTrader's official guide for precise intrabar-granularity backtesting using additional tick-level data series. Don't take our word for it — run a backtest at the end of each trading day and compare it against the strategy's actual live trades that day.

Release Notes

  • First release of the strategy
discord
Join our Discord community
Questions, feedback, or just want to chat with other traders? Come say hi.
Join Discord
Quick Facts
Platform NinjaTrader 8
Category Strategy
Plan Required Premium
Latest Version v1.0.0.1
Last Updated 1 year ago
Downloads 211