Dynamic Position Sizing Based on ATRs and a Strategy P & L Proxy for Account Equity in a NinjaTrader Strategy (Point-and-Click NinjaTrader® Strategy)
Original Trading Strategy
Peer Reviews, Modifications & Responses
Thanks for Sharing!
Trading Strategy Summary
Warning: Account currency and instrument currency must be the same for this strategy to function properly. This strategy does not attempt to do currency conversions.
This strategy is designed to run only on accounts whose account currency is the same as the denominating currency of the instruments on which the strategy runs, since there is no currency conversion logic in this strategy, and since the NinjaTrader® platform supports accounts that are denominated in different currencies than the instruments they trade. To use this strategy on an account whose denominating currency is different than some of the instruments this strategy will be run on, currency conversion logic would need to be added to this strategy to convert between quantities like the notional value of a quantity of 1 of the instrument, which is in the instrument’s currency, and “Approximate Account Value”, which is in the account’s denominating currency.
The Logic Not Related to Dynamic Position Sizing
This trend following strategy goes long when the close price crosses above the upper band of a Bollinger Bands® indicator while the close price is going up.
The strategy exits its long position via a stop loss at a specified number of 14-Period ATRs below the average fill price of the position or via a profit target at a distance above the average fill price of the position equal to the stop loss distance multiplied by the value of the “Risk To Reward Ratio to Make Profit Target ‘X’ Times Larger Than Stop Loss” input parameter.
The Dynamic Position Sizing Logic
The order quantity used to enter positions is calculated dynamically as the minimum result of the following two methodologies of calculating entry order size:
Dynamic Order Quantity Calculation #1: Calculates the order quantity such that the amount of money risked, as calculated by the distance of the stop loss from the average fill price in units of currency for a quantity of 1 multiplied by the order quantity, is no greater than the percentage of the “Approximate Account Equity” specified in the strategy’s “Percent of Account Equity To Risk On A Trade” input parameter.
Dynamic Order Quantity Calculation #2: Calculates the order quantity such that the total notional value of that quantity of the instrument being traded is no greater than the “Approximate Account Equity” multiplied by the value specified in the strategy’s “Est. Notional Value of New Position Should Be <= ‘X’ Times Approx Account Equity” input parameter.
The way that “Approximate Account Equity” is calculated depends on whether the strategy’s “Use Initial Account Equity Entered Below (Set This to True in Strategy Analyzer)” input parameter is set to True or False, due to its check box being checked or unchecked in the NinjaTrader® user interface.
If the “Use Initial Account Equity Entered Below (Set This to True in Strategy Analyzer)” input parameter is set to True, the value of “Approximate Account Equity” is calculated by taking the sum of the value of the strategy’s “Initial Account Equity Entered As An Input Parameter (In Currency of Instrument Being Traded)” input parameter, plus the strategy’s realized P & L, plus the strategy’s unrealized P & L.
If the “Use Initial Account Equity Entered Below” input parameter is set to False, the value of “Approximate Account Equity” is simply the value of the account equity of the account on which the strategy is running, as determined by the NinjaTrader® platform. Note that the account equity for an account may not be accurately returned by the NinjaTrader® platform in a backtest or optimization in the Strategy Analyzer, so it is recommended to check the “Use Initial Account Equity Entered Below” input parameter’s check box and enter an initial account equity in the “Initial Account Equity Entered As An Input Parameter” text box beneath the check box in the NinjaTrader® user interface when using this strategy in the Strategy Analyzer. Also note that even when used on a real-time chart (including in Market Replay), the account equity of the account while the strategy is running on the historical bars before real-time bars are encountered will be static, even though historical “trades” are being simulated and simulated P&L is going up and down, but when “Approximate Account Equity” is calculated as it is when the “Use Initial Account Equity Entered Below” input parameter is set to True that the “Approximate Account Equity” will go up and down while the strategy is running over the historical bars before it encounters the first real-time bar since this calculation methodology uses strategy P & L (including simulated P & L on historical bars).
More Information
Please read the NinjaTrader® help documentation titled “SetStopLoss()” at the following URL to learn important details about using stop losses in NinjaTrader® strategies: https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?setstoploss.htm
Please read the NinjaTrader® help documentation titled “SetProfitTarget()” at the following URL to learn important details about using profit targets in NinjaTrader® strategies: https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?setprofittarget.htm
Copyright © 2025 Quagensia, Inc. All rights reserved.
How to Get the Quagensia Strategies
This point-and-click trading strategy is built into Quagensia N Edition (for NinjaTrader®).
Customize Quagensia Strategies with Your Own Ideas
Tweaking Quagensia Trading Strategies using point-and-click with the Quagensia Desktop Application is easy for non-programmers. If you get stuck you can usually find the answer you need in our online help documentation or you can ask a question in our friendly Discord community.
If you don’t want to tweak a Quagensia Trading Strategy with point-and-click to add your own proprietary trading logic, you can still download a Quagensia Trading Strategy file, open it up in the Quagensia Desktop Application, and generate its code, then backtest and optimize the trading strategy on different instruments, different bar periods (weekly bars, daily bars, hourly bars, 15-minute bars, etc.), or different bar types (time-based bars, volume-based bars, tick-based bars, etc.), and use different start and end dates.
Some tweaks you can make to the Quagensia Trading Strategies you download include:
Modify the entry & exit logic.
- Add more conditions, remove conditions, or change them by choosing from among a very large number of components, including many exotic indicators.
- Add or modify stop losses, trailing stops, and profit targets. Make them tighter, less tight, or based on an entirely different calculation.
- Add or modify time stops. For example, exit after a certain number of bars either unconditionally or only if the post-entry price action did or did not exhibit certain characteristics.
Enhance the output of the strategy to go beyond simply placing orders.
- Draw lines, shapes, and text on the chart. For instance, you can mark times or prices where each entry or exit condition of a multi-condition entry or exit was true, even if all the necessary entry or exit conditions were not true at the same time so an entry or exit did not occur.
- Write information to NinjaTrader®’s NinjaScript® Output window or TradeStation®’s EasyLanguage® Print Log window.
- Write information to a file. You can even output a report that can be opened in Microsoft Excel or consumed by another application that reads comma-delimited, semicolon-delimited, or otherwise character-delimited tabular data files.


