Stacked Imbalances Strategy

Created 07 Jan 2024 · Updated 24 Jan 2025

The Stacked Imbalances Strategy is a Premium mechanical strategy for the NinjaTrader 8 platform. It's a full-auto strategy that can run on autopilot, while its built-in command buttons let you extend or override it manually. The strategy can be used to pass propfirm evaluation challenges.

Prerequisites

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


  • NinjaTrader 8, with any license type. Click here to download
  • An OrderFlow-enabled NinjaTrader account, obtained either by purchasing a lifetime NinjaTrader license or through a license provided by a trader funding program.
  • An automated-trading.ch account with an active Premium Subscription

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.

The Stacked Imbalances strategy is both a trend-following and a reversal strategy, based on the assumption that stacked volume imbalances are a symptom of inherent inefficiencies in market microstructure.

The strategy implements multiple imbalance-based entry setups:

  • Trend Mode: enters long when an ask-side stacked imbalance occurs, or short when a bid-side stacked imbalance occurs
  • Reversal Mode: enters long when trapped sellers are detected on a long price reversal, or short when trapped buyers are detected on a short price reversal
  • Auto Mode: automatically switches between Trend and Reversal modes based on the prior day's Volume Profile in relation to current price action

The strategy aims to be profitable long-term by generating a positive expected return from a win/loss ratio higher than 1. It can be used on a price-based bar type (Range or Tick bars) or a time-based bar type — see the Performance Reports section for suggested settings on different instruments.

Entry Setup Examples

Entering Long on Trend Continuation Mode

The strategy detects an ask-side stacked imbalance which arms it to go long, then waits for price-action follow-through to execute the trade — e.g. a candle closing above the previous candle's high. In one such example, the trade was executed with a $100 stop loss/take profit and a quantity of 2 contracts on MES.

Entering long on trend continuation mode example
Click to enlarge
Entering Trades on Reversal Mode

When Stacked Imbalances Entry Mode is set to Reversal, a buy-side stacked imbalance triggers a short entry, and a sell-side stacked imbalance triggers a long entry — e.g. a long entry following a bid-side stacked imbalance and a confirmation candle, profitable because the imbalance reflected high-volume buy limit orders taking profit after a bearish trend before price reversed up.

Entering trades on reversal mode example
Click to enlarge
Entering Long on a Trapped-Sellers Signal

With only the Trapped Traders setup enabled, a bid-side stacked imbalance on a green candle (aggressive selling being trapped, or a large volume of buy limit orders at that level) arms the strategy; a follow-through candle confirms the entry. One such setup produced a profitable long trade with 2 contracts and a $100 1:1 take profit/stop loss on MCL.

Entering long on trapped-sellers signal example
Click to enlarge
"Dollar Cost Averaging" Order Management in Action

When DCA is used as the order management strategy, the position's quantity is increased at each closing candle in the winning direction, aiming to reach breakeven and close the position early at breakeven or slightly in profit. This doesn't always work — sometimes the stop loss is hit earlier than the take profit due to the increased quantity, resulting in an early loss exit. Extensive backtesting across market regimes, instruments, and timeframes is recommended to understand this method's long-term impact.

Dollar cost averaging order management in action
Click to enlarge
Strong Imbalance Signal but No Follow-Through

A strong sell-side stacked imbalance can arm a short entry, but without confirming price action (price instead continues upward), the short signal is canceled — illustrating why follow-through price action matters, rather than showing an actual trade.

Strong imbalance signal but no follow-through example
Click to enlarge

Features

The Stacked Imbalances strategy has a set of unique features:

  • Performant, in-house-developed imbalances detection engine
  • No pending orders are placed — only market orders
  • Full-auto strategy that can be scaled into multiple instances
  • Can be run as a semi-auto strategy using the automated trading interface on the Chart panel
  • 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 accounts or NinjaTrader brokerage accounts

Parameters

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

General
Execute Historical TradesShould be checked whenever the strategy runs in Historical, Backtest, or Optimization modes, and unchecked when running Live Real-Time.
Daily TakeProfit TargetThe strategy stops for the day once daily realized profit reaches this amount. Ignored when set to 0.
Weekly TakeProfit TargetThe strategy stops for the week once this weekly take-profit amount is reached after closing a position. Resets at the start of each new week. Ignored when set to 0.
Daily StopLoss LimitThe strategy stops for the day once the daily loss limit is reached after closing a position (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.
Swings PeriodSets how many bars are enough to separate two swings of the same type. The higher this value, the fewer swings overall; the lower, the more. A value of 3 or 4 is typical.
Draw Price SwingsEnables/disables drawing swings on the chart. Swings are always analyzed and processed regardless of this parameter, which only affects visibility.
Buy Imbalances Color / Sell Imbalances ColorColor of bullish/bearish stacked imbalance zones drawn on the chart.
Execute on MicrosExecutes trades on a different instrument than the active chart's — e.g. run logic on Minis but execute on Micros to better manage risk. All risk calculation happens on the execution instrument.
Execution InstrumentChoose from a list of Micros available on your NinjaTrader connection as the instrument trades execute on. Historical and live trades won't be drawn on the chart in this case.
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 TimeSpecifies the time interval(s) in which the strategy is allowed to place trades — e.g. 09:30-16:15 for RTH in EST, or 00:01-08:00,09:55-15:55,18:01-23:59 to cover RTH and ETH while excluding volatile periods. Intervals must be listed in increasing order (even the one spanning midnight into the next session) and are cut at midnight to avoid issues stepping into a new day.
Quantity Strategy
  • Fixed Quantity: fixed quantity per trade; skipped if the evaluated risk exceeds Max Risk Currency
  • 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.
Trade Entry Mode
  • Immediate: opens a position immediately at bar close when an entry setup occurs
  • Wait For Bar Confirmation: waits for a candle to close higher (long) or lower (short) than the setup candle — helps avoid cases where price reverses against the setup
  • Wait For FVG Confirmation: waits for a Fair Value Gap to close higher (long) or lower (short) than the setup candle — aims for higher-probability entries
Order QtyQuantity per trade when Quantity Strategy is Fixed — also used for each quantity increase if the order management mechanism scales in.
Enable Trapped Traders EntryEnables/disables entering on trapped-traders signals — a stacked imbalance on a reversal candle followed by a follow-through price break above/below the imbalance candle's high/low.
Enable Stacked Imbalances EntryEnables/disables the trend-following entry signal — a stacked imbalance followed by the same kind of follow-through.
Stacked Imbalances Entry Mode Sets the trade entry mode for Enable Stacked Imbalances Entry.
  • Trend Following: enters in the direction of the stacked imbalance, hoping for trend continuation
  • Reversal: enters in the opposite direction, hoping to profit from a price reversal
  • Auto: sets a trend bias from the prior day's RTH (9:30-16:15 EST) Volume Profile — long-only if price is above the previous Value Area High, short-only if below the previous Value Area Low, reversal if price is between VaL and VaH, or trend (long or short) if the previous profile was a double distribution and price sits between its two components
VWAP FilterEnables/disables a VWAP filter for entries — long entries require price above VWAP, short entries require price below VWAP.
Swing Filter Enables/disables a swing trend filter for entries, analyzing consecutive swing pivots.
  • Long entries are allowed only if at least 2 consecutive low swings occurred prior to the setup
  • Short entries are allowed only if at least 2 consecutive high swings occurred prior to the setup
Imbalances
Min Imbalance RatioMinimum ratio between the diagonal bid/ask volumes to consider an imbalance.
Min Imbalance VolumeMinimum volume value on the strong side (bid/ask) to consider an imbalance.
Max Imbalance Gap (Ticks)Gap tolerance between stacked imbalance levels — imbalances that aren't perfectly stacked (with tick gaps between them) still count as a cluster if this parameter is higher than one.
Min Stacked Imbalance CountMinimum number of imbalances in a cluster of stacked imbalances — generally 3 or more.
Order Management
Order Management Strategy
  • Classic Trail Stop: trails the stop loss based on a trigger and a trailing amount (see Trailing Stop Parameters below)
  • ATM Strategy: delegates position management entirely to a NinjaTrader ATM strategy template of your choice, selected via the Chart Trader panel
  • Dollar Cost Averaging (Grid): increases order quantity each time a swing forms on the losing side of the trade, averaging down the position's price
  • Trail Stop on Swings: trails the stop loss each time a swing forms in the winning direction
  • None: uses the stop loss defined by Stop Loss Currency instead
ATM Strategy Template NameOnly used with the ATM Strategy order management method — the exact template name of your custom ATM strategy, shown in a drop-down of available templates.
On Opposite Signal
  • Breakeven: moves the stop loss to breakeven when an opposite signal occurs
  • Close Position: closes the position immediately when an opposite signal occurs
  • Do Nothing: ignores opposite signals
StopLoss Strategy
  • Bar High Low: sets the stop loss to the imbalance candle's low/high level (also bounded by Stop Loss Currency; the position closes when either level is hit first)
  • Last Swing: sets the stop loss to the previous price swing's high/low level (same Stop Loss Currency bound applies)
  • Fixed Currency Value: only the stop loss defined by Max Stop Loss Currency is used
  • Points: a fixed number of points from entry
TakeProfit Strategy
  • Fixed Currency Value, based on Take Profit Currency
  • Fixed win/loss ratios: 0.5:1 through 6:1, calculated from the stop loss price
  • Points, a fixed number of points from entry
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 PointsAvailable when the Stop Loss 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. If not, set it high enough that it doesn't interfere with the ratio-based strategies.
Enable Price BreakevenEnables/disables the price-based breakeven mechanism.
Price Breakeven Strategy
  • Points: breakeven triggers based on points
  • Percentage: breakeven triggers based on percentage of take profit reached
Price Breakeven TriggerAvailable if price-based breakeven is enabled — the trigger value (in points, or a percentage from 1-100) needed to move the stop loss to breakeven.
Enable Time BreakevenEnables/disables a time-based (minutes) breakeven mechanism.
Time Breakeven Trigger (Minutes)Available if time-based breakeven is enabled — the number of minutes needed to move the stop loss to breakeven.
Trailing Stop Parameters
Trailing Stop Strategy Used with the Classic Trail Stop order management method.
  • 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.
DCA (Grid) Parameters
Breakeven Profit ShiftUsed with the DCA order management method — adds a small amount of profit to the breakeven definition, to help cover commission costs when closing the grid at breakeven.
Grid Size to BreakevenUsed with the DCA order management method — the number of order increases required before considering closing the position at breakeven.
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.
Entry Mode Switch ButtonSwitches the strategy's entry mode between Trend and Reversal.
Close Position ButtonImmediately flattens the position on the active instrument without restarting the strategy, which keeps looking for new trades afterward.
Increase Qty ButtonIncreases the current active position's quantity by the amount set in Order Qty — useful to manually dollar-cost-average or double down after a winning-side confirmation signal.

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.6.0.0 · Published 1 year ago
This file was downloaded 1077 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.
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, Historical, Backtest, and Optimization 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

  • Added CET timezone; Added Fair Value Gap entry filter; Added 1.5:1 take profit option; Fixed fixed-value take profit interference with dynamic mode; Optimized memory usage on optimizations; Added Points as stoploss option; Added Risk per trade / max allowed risk parameters; Added StopLoss Offset Points parameter; Upgraded price breakeven methods; Added time based breakeven; Better dynamic quantity calculation; Added Points based take profit; Added Weekly take profit target

  • Fix duplicate Chart Panel controls

  • Added Execution on Micros; Added new trail stoploss method; Added stoploss offset in points; Various Fixes

  • Added Breakeven option; Removed maximum count of trades as daily stop trade method

  • Bug Fix: error on render method

  • Bug Fix: Max Currency Risk should not take over stoploss price

  • Added additional daily stop strategies; Added Risk adjusted quantity strategy; Added Auto switch Trend/Reversal entry modes; Added VWAP filter for entries; Added Swing direction filter for entries

  • Major update: adding ATM Strategy management capabilities

  • Added Entry Mode Switch to command buttons

  • Bug Fix: Last Swing StopLoss method was incorrect

  • User Friendly parameter value options; Better Swing analysis; Rendering of imbalances zones from within strategy; Added Take profit strategy; Strategy became Premium

  • First Release of the strategy as a free 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.6.0.0
Last Updated 1 year ago
Downloads 1077