Summary
The Stacked Imbalances Strategy is a Premium mechanical strategy for the NinjaTrader 8 platform. It is a full-auto strategy that can be run on autopilot but in the same time it gives you the possibility to be extended with its built-in command buttons. The stacked imbalances strategy can be used to pass propfirms evaluation challenges
We highly recommend joining our discord community by following this invite link
Index
Overview Video
Prequisites
To properly use this strategy you should have available the following prequisites
- NinjaTrader 8. Click here to download
- OrderFlow data enabled NinjaTrader account that can be obtained by either purchasing a lifetime NinjaTrader license or by using a license provided by
one of our recommended trader funding programs:
We highly recommend
Description
The stacked imbalances strategy is both a trend-following and a reversal strategy. The strategy is based on the assumptions that stacked volume imbalances are a symptom of inherent inefficiencies in market micro-strucutre.
The strategy implements multiple imbalances based entry setups such as:
- Trend Mode: Entering long when a ask-side stacked imbalance occurs, or entering short when a bid-side stacked imbalance occurs
- Regression or Reversal Mode: Entering long when trapped sellers are detected on a long price reversal, or entering short when trapped buyers are detected on a short price reversal
- Auto Mode: The auto mode will automatically switch between Trend and Reversal modes based on the analysis of prior day volume profile in relation to the current price action
The strategy aims to be profitable in the long term by generating a positive expected return determined by a win/loss ratio that is higher than 1.
The strategy can be used on a price based bar-type (Range or Ticks bars) or a time based bar-type. Refer to the preferred settings section to check out our suggested parameters on different instruments
So let's look at some entry examples:
Entering long on trend continutation mode
In this example, the strategy detected an ask-side stacked imbalance on the candle marked "1" which armed the strategy to go on a long trade. At this stage, the strategy will wait for a price action follow-through to execute the trade, which has happened on the "2" candle when the candle closed above the high of the previous candle. The trade was executed at the close of the "2" candle. The stop loss and take profit for this trade were set to 100$ with a quantity of 2 contracts on the MES Decembre 2023 contract
Entering trades on reversal mode
In this example the parameter Stacked Imbalances Entry Mode is set to the value Reversal which means when a buy side stacked imbalance occurs the strategy enters a short trade and when a sell side stacked imbalance occurs the strategy will enter a long trade.
On the above chart, we can see two examples of those reversal trades. The first one is a long trade that was entered following a bid-side stacked imbalance (candle marked with "1") followed by a red confirmation candle (marked "2"). This was a profitable trade since the imbalance were obviously high volume buy limit orders taking profits after a bearish trend, then price reversed up.
In the second trade few candles later we see the same scenario happening again but in the opposite direction/p>
Entering long on Trapped sellers signal
In this example we can see two long profitable trades, both are long trades that were entered after a trapped sellers signal was detected
In this example, only the Trapped Traders setup was enabled. This is why the other trend mode imbalances were not taken. On the first setup, on the candle "1" we can see a bid-side stacked imbalance on a green candle which means that there was either an agressive selling activity being trapped or a big volume of buy limit orders on those levels. The closing of this candle has armed the strategy to wait for a follow-through price action to go long.
The "2" candle has confirmed the entry setup signal and so the strategy entered a trade long making a profit with 2 contracts and 100$ 1:1 Take profit and Stop loss limits on the MCL 01-24 futures contract
On the second trade, the same scenario happened again, the only difference is that the "2" follow-through candle didn't occur directly after the setup signal but one candle later
"Dollar Cost Averaging" order management in action
When DCA is used as an order management strategy, the Imbalance strategy will increase the quantity of the open position at each closing candle in the winning direction in the hope of reaching the breakeven point and closing the position early in breakeven or slightly in profit
The above example illustrates this on three consecutive examples of short trades on a choppy trend.
The idea behind this is that if the price did pull back and went in the losing direction right after entering the trade, the strategy will try to exit as soon as possible by increasing the quantity and hope for a rapid breakeven. Off course this will not always work and sometimes this method will make the strategy exit early in loss because the stop loss was hit earlier than the take profit price due to increasing quantity
One should do many backtests on different market regimes, instruments and timeframes and have a sense of what is the impact of this method on the overall performance of the strategy on the long term
Strong imbalance signal but no follow-through
This example illustrates the importance of follow-through price action after the imbalance signals. In the image we see a strong sell side stacked imbalance which armed the strategy to enter a short trade.
we can see that there were no price action to confirm the imbalance signal. The price continued its movement upward and canceled the short signal
This example doesn't show actual trades. It is for explaining the idea behind follow-through price action
Features
The stacked imbalances strategy has a set of unique features:
- Performant and 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 official best practices to obtain precise entry/exit backtesting on tick level
- Robust In-house Order management library. Resistant to connection loss and works seamlessly on Rithmic accounts or NinjaTader brokerage accounts
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 that the maximum amount your risk to lose is the monthly subscription fee you pay those programs.
Here are the trader funding programs that we recommend using, and that we use to run the Stacked Imbalance Strategy on:
Parameters
We try to keep the parameters to minimum. We only left the most important parameters to be set
General | |
Backtest Mode | This parameter is very important and should be used carefully. This parameter should be set to true (checked) whenever the strategy is run in Historical, Backtest, or Optimization modes. When running the strategy in Live Real-Time mode this parameter should be set to false (unchecked). |
Daily TakeProfit | The strategy will stop trading when the daily Realized profit is equal or great than the value of this parameter. When set to 0, this parameter is ignored |
Daily StopLoss | The strategy will close the open position and stop trading for the day when the daily unrealized Pnl is equal or lower to this value. The value of this parameter is positive. For example if the value is set to 300, the strategy will stop when the Realized PnL is lower or equal to -300$. When set to 0, this parameter is ignored |
Stop @ Winning Count | This will make the strategy stop trading if the net count of winning trades for the day is equal to the value of this parameter. This parameter is ignored if equal to 0 |
Stop @ Losing Count | This will make the strategy stop trading if the net count of losing trades for the day is equal to the value of this parameter. This parameter is ignored if equal to 0 |
Swings Period | Swings are higher lows,higher highs, lower highs and lower lows. After each price bar close, a swing can be detected. But just after that, the next bar can cancel the swing at the previous bar by creating a new swing of the same type. Or this can happen on the second bar, or the third, etc... The swing period sets how many bars is enough to seperate two swings of the same type. The more you increase this parameter, the more you decrease the number of swings overall. The more you decrease this parameter, the more you increase the number of overall swings. I prefer to use the value of 3 or 4 for this parameter. |
Draw Price Swings | This parameter will enable/disable the drawing of swings on the chart. Swings will always be analyzed and processed regardless of this parameter which only affect visibility and render. |
Buy Imbalances Color | Color of Bullish stacked imbalance zones to draw on the chart |
Sell Imbalances Color | Color of Bearish stacked imbalance zones to draw on the chart |
Execute on Micros | The parameter will enable executing trades on another instrument than the one on the active chart. This can be useful if you sant to run the strategy logic on Minis and execute on Micro to better manage the risk by opening the trades on micros. Notice that if you enable this parameter all the risk calculation done by the strategy will be made on the execution instrument. |
Execution Instrument | The parameter will let you chose from a list of Micros available on your NinjaTrader connection, the instrument on which trades will be executed. notice that historical trades and live trades will not be displayed on the Chart in this case. |
Entry Setup | |
Trade Time | This parameter is very important and can be delicate in some cases. This parameter is used to determine the time intervals in which the strategy is allowed to place trades. The time zone that should be used while setting this parameter value should be the Time Zone of the machine on which NinjaTrader is executed.
Here are some examples for more clarifications:
|
Quantity Strategy |
This parameter sets how the quantity should be set for a Trade
|
Max Qty | This parameter sets the maximum allowed quantity when the Risk Adjusted method is selected. This option is very useful since some propfirms has order quantity limits that can cause the account to be invalidated |
Trade Entry Mode |
This parameter sets the entry mode following an entry setup, it can have 2 possible values:
|
Order Qty | This parameter sets the quantity of each trade when the Fixed Quantity method is selected. In the case of increasing orders quantity executed by the order management mechansim, this parameter is also used for each increase in quantity. |
Enable Trapped Traders Entry | This parameter enables/disables entering on trapped traders signals when a stacked imbalance occurs on a reversal candle followed by a follow-through price action. The follow-through price action is when the price breaks above/below the high/low of the imbalance candle |
Enable Stacked Imbalances Entry | This parameter enables/disables trend following entry signal when a stacked imbalance occurs followed by a follow-through price action. The follow-through price action is when the price breaks above/below the high/low of the imbalance candle |
Stacked Imbalances Entry Mode |
This parameter is related the above parameter Enable Stacked Imbalances Entry and it sets the trade entry mode
|
VWAP Filter | This parameter enables/disables the VWAP filter for entries. For Long entries, the price should be above the VWAP and for short entries the price should be below the VWAP |
Swing Filter | This parameter enables/disables the swings trend filter for entries.
This swing filter will analysis consecutive swing pivots and will apply the following filter for entries:
|
Imbalances | |
Min Imbalance Ratio | This parameter sets the minimum ratio between the diagonal bid/ask volumes to consider an imbalance |
Min Imbalance Volume | This parameter sets the minimum volume value on the strong side (bid/ask) to consider an imbalance |
Max Imbalance Gap (Ticks) | This parameter sets a gap tolerance between stacked imbalance levels. For example, multiple imbalances that are not perfectly stacked (having a number of tick gaps between them) will be considered a cluster of stacked imbalances if the this parameter is higher than one |
Min Stacked Imbalance Count | This parameter sets the minimum number of imbalances in a cluster of stacked imbalances, generally this should be 3 or more |
Order Management | |
Order Management Strategy |
|
ATM Strategy Template Name |
This parameter is available when the ATM Strategy order management method is selected. This parameter specifies which ATM strategy to use.
All the available custom ATM templates will be automatically shown in the drop down box |
On Opposite Signal |
|
StopLoss Strategy |
|
TakeProfit Strategy |
|
Max Stop Loss Currency | This sets the max risk in dollars for the open position. |
Take Profit Currency | This sets the take profit in dollars for the open position. If you use the Fixed Currency Value as a take profit strategy, the value of this parameter will be used. If not, make sure to set this parameter to a high value to not interfer with other ratio based strategies |
Enable Breakeven | This parameter will enable/disable breakeven mechanism on open positions |
Breakeven Trigger % | This parameter is available if Breakeven is enable by the previous parameter. This parameter sets the percentage of profit that needs to be reached to trigger setting the stop loss to breakeven for the current open position |
Trailing Stop Parameters | |
Trailing Stop Strategy | When the Classic Trail Stop method is selected, this parameter let you chose on which basis the trailing will be calculated |
Trailing Stop Trigger | When the Classic Trail Stop method is selected, this parameter sets the trigger (in Points or in Ratio) |
Trail Amount | When the Classic Trail Stop method is selected, this parameter sets the amount (in Points or in Ratio) to be trailed when the trigger is hit |
DCA (Grid) Parameters | |
Breakeven Profit Shift | When the DCA method is selected as a position management mode, this parameter will modify the definition of a breakeven and adds a bit of profit to it. This is useful to cover the cost of commissions when closing the grid in breakeven |
Grid Size to Breakeven | When the DCA method is selected as a position management mode, this parameter will set the number of order increases required to consider closing the position in breakeven |
Command Buttons | |
The strategy allows to manually execute some commands in case you want to manually intervene. The commands buttons are added to the Chart Trader panel, make sure to show it on your active chart | |
Arm/Disarm Buttons | The Arm Long/Disabled Long and Arm Short/Disabled Short buttons can manually activate or deactivate entering trades long or short. By default those two toggle buttons are enabled meaning the strategy is armed to enter both long and short trades. Toggling the button to the disable will restrain the strategy to enter a trade in the disabled direction. This can be useful if you have a directional bias or conviction about the direction of the market |
Entry Mode Switch Button | The Entry Mode button allows to switch the entry mode of the strategy between Trend and Reversal |
Close Position Button | The Close position button will immediately flatten the position on the active instrument on the active Chart. This can be useful if you want to exit a trade without having to affect the strategy or restart it. After closing the position, the strategy will continue to function normally and look for new trades to take |
Increase Qty Button | The increase Qty button allows to increase the quantity of the current active position. The increase value is defined by the parameter Order Qty. This can be useful if you want to manually dollar cost average the position or to double the quantity of the position after a confirmation signal on the winning side of the trade |
Backtesting and Preferred Settings
Here I will try to periodically list backtests with different risk appetit. But before that here are some remarks regarding backtesting
- Commissions are included in the backtests to get as realistic results as possible. The commission schema used is NinjaTrade Lifetime license commissions schema
- The Trade Time setting used in these backtests is adapted to UTC+1 Timezone which is 00:01-21:58. The EST equivalent will be 00:01-15:58,18:01-23:59
- At automated-trading.ch we run very precise backtests due to the following 2 factors
- We are following the NinjaTRader official guide on how to achieve precise intrabar granularity backtesting by using additional tick level DataSeries See here for more info
- We are only using Market Orders instead of Pending Orders in both real-time and becktest modes.
- To run this strategy in "Strategy Analyzer - Optimization" mode, make sure you select the Volumetric Data Series type, or otherwise no orders will be sent.
Download & Installation Instructions
The strategy can be downloaded and run on Backtest, Playback, Optimization and live modes for free without the need for an active subscription. Nevertheless, a license number that you can get for free is required for running the strategy on Live Real-time mode.
To obtain the license simply Signup and then get your license on the billing page
To download and install the strategy follow the instructions below
- Click on the below download button to download the Imbalances Strategy file
- Import the downloaded .zip file into NinjaTrader using the import NinjaScript menu item
- Next, open a new chart window while making sure the Tick Replay tickbox is checked
- If you don't see the Tick Replay check box, go to Tools->Options->Market Data and enable Show Tick Replay
- After installing the strategy and opening a new Chart window you should add the strategy to the chart.
- After adding the strategy to the chart, the strategy will be run on Historical data loaded in the chart.
- When the Histocial data run is done, the strategy will switch to Real-Time mode and will add the license panel controls to the Chart Trader Panel
- Make sure to display the Chart Trader panel on your active NinjaTrader Chart
- Copy/Paste your license in the text box as shown in the image below. Your license can be found on the billing main page. Make sure to create an account or login first
- Click on the Check License Button
- At this step the strategy will check the License and activate/deactivate trading according to the license correctness
- If the license is correctly submitted you will see the "Check License" button turned to green, and the next verification date next to your email. License check is only required once. Until the next verification date.
- At this stage, the strategy is ready to be run in all modes of execution
Frequently Asked Questions
General
Using a VPS is good but not imperative. I run this strategy on a ~$6 VPS Windows instance on Hetzner. Check out our resources page to get a discount through our affiliate LINK
Yes! You can run multiple instances of this strategy on the same account but each instance should be run on a unique instrument
You can't run multiple instances on the same account on the same instrument because as you know NinjaTrader will aggregate orders in one position per instrument per account
Yes! you can use a copier, but a better solution would be to run multiple instances of the strategy. The purchased license allows you to run unlimited instances on multiple machines
Yes! The strategy is designed for that exact purpose. It will work seamlessly on Rithmic, NinjaTrader brokerage, Tradovate or any other provider connected to your NinjaTrader platform
I designed this strategy to be full-automatic strategy. Yet, it can be used as a semi-auto strategy to enter trades and then let you manage those trades manually using its command buttons
You should consider full auto-trading over manual trading for many reasons:
- Trading 24/7: Automated trading strategies don't need to go to the bathroom nor it needs to take a break
- Better execution, faster and more precise
- Eliminate psychology and sentiments
- Can be scaled to dozens if not hundreds of instances
- Automated trading can generate truly "passive" income, manual trading is just another stressful job
Yes, If you have an idea that you believe can improve the performance of this strategy, I will be more then happy to hear from you. Please use the contact page to send me a message
No, the source code of the strategy is protected for copyright reasons
Billing
Yes, you can cancel your subscription from the account page at any time to prevent future payments. We cannot refund the unused portion of your subscription, but you will be able to use your subscription even after cancelling for the remainder of the billing cycle.
No, we don't offer a trial subscription plan. But you can download and test the strategy 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 have been a professional software developer since 2010. I have been developing automated trading strategies since 2012, for my self for fun and profit and also been developing strategies for clients all over the world
I have always been invlolved professionaly in the business of Finance and investing, I have worked for trading brokers and investment banking.
I'm not a marketer, and I don't hire someone else to develop my strategies.
This strategy has been profitable for me on the long run with ups and downs, especially when it is run on multiple insturments. But the question remains pertinent, why I'm selling it?
The answer is I'm not selling it, I'm renting it to generate an additional income and diversify my different sources of income besides what this strategy can generate. Which you should also do. You should not rely on one source of income to reach financial independance, the key is diversification.
Lets examine pros and cons of pending orders
- Pros:
- Best price execution when using limit orders
- Protection against losses in case of connectivity issues
- Cons:
- Can get rejected on high price volatility
- Delay between request to place the order and when it gets placed. Price volatility can cause the order to be rejected and the price to run away
- Requires management: any opposite orders need to be canceled
- Visible to the broker, placed orders can be manipulated
After years of developing strategies I reached the conclusion that market orders are better suited for the context of automated trading.
The main drawback of using pending orders is the fact that they can be rejected which is very hard to manage especially in a volatile environment
In all our strategies, we use market orders even for take profit and stop loss. Lets examine the pros and cons of market orders
- Pros:
- Guarantee of execution reagrdless of volatility conditions
- Invisible to the broker before they get submited
- No risk of being rejected which means better protection for stop loss
- Faster execution than pending orders
- Cons:
- In the case of the connection being lost with the broker, the strategy will be unable to send market orders
Remark: MIT (market if touched) orders in NinjaTrader are a solid alternative to pending orders if you really want to use pending orders
We are following the NinjaTrader official guide on how to achieve precise intrabar granularity backtesting by using additional tick level DataSeries See here for more info
Don't take my word for it. Test it yourself, at the end of each trading day, run a backtest of the strategy on that day and compare it with the live trades the strategy made during the day.
Release Notes
- Fix duplicate Chart Panel controls
- Added Execution on Micros
- Added new method to trail stoploss
- Added stoploss offset in points
- Various Fixes
- Added Breakeven option
- Removed maximum count of trades to as a daily stop trade method
- Bug Fix: Fixed error on the render method
- Bug Fix: Max Currency Risk should not take over the stoploss price
Major updates
- Added additional daily stop strategies
- Added Risk adjusted quantity strategy
- Added Auto switch between Trend and 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 the imbalances zones from within the strategy
- Added Take profit strategy
- Strategy became Premium
- First Release of the strategy as a free strategy