Draw on Bars with Exits Due to Money Management Functions (Set Stop Loss, Set Trailing Stop, Set Parabolic Trailing Stop, and Set Profit Target) (Point-and-Click NinjaTrader® Strategy)
Original Trading Strategy
Peer Reviews, Modifications & Responses
Thanks for Sharing!
Trading Strategy Summary
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 and exits when the close price crosses below the lower band of a Bollinger Bands® indicator.
Note that this strategy is not meant to perform well. Rather it is meant to demonstrate how to draw on bars with exits due to money management functions. This strategy may perform better if it exits when the close price crosses below the middle line rather than the lower band, but we chose to use the lower band for the exits of this particular strategy to allow for more stop losses, trailing stops, parabolic trailing stops, and profit targets to exit positions so users would see more examples of drawings on bars with exits due to money management functions.
The strategy also exits its long position via one of three possible types of protective stops (a stop loss, trailing stop, or parabolic trailing stop) as determined by the value to which the “Stop Type (1=Stop Loss, 2=Trailing Stop, 3=Parabolic Trailing Stop)” input parameter is set if this strategy’s “Use A Protective Stop of Any Type?” input parameter is set to True due to its check box being checked in the NinjaTrader® user interface.
The strategy also exits its long position via a profit target if this strategy’s “Use Profit Target?” input parameter is set to True due to its check box being checked in the NinjaTrader® user interface.
If a position is exited due to a protective stop, a translucent (i.e. semi-transparent) dot whose color is set by the input parameter named “Color of Dot on High of Protective Stop Exit Bar” is drawn on the high of the bar, the bar’s “candle outline color” is set by the input parameter named “Candle Outline Color of Protective Stop Exit Bar”, and the background color of all chart panels is set by the input parameter named “Background Color of Protective Stop Exit Bar”. Note that if the “Calculate” drop-down list in the “Strategy Details” section below is set to a value other than “On Bar Close”, then the translucent dot will be drawn at the high of the bar on the tick or price change upon which it was determined that a protective stop exit occurred, which will not necessarily be the high of the bar on the close of the bar.
If a position is exited due to a profit target, a translucent dot whose color is set by the input parameter named “Color of Dot on High of Profit Target Exit Bar” is drawn on the high of the bar, the bar’s “candle outline color” is set by the input parameter named “Candle Outline Color of Profit Target Exit Bar”, and the background color of all chart panels is set by the input parameter named “Background Color of Profit Target Exit Bar”. Note that if the “Calculate” drop-down list in the “Strategy Details” section below is set to a value other than “On Bar Close”, then the translucent dot will be drawn at the high of the bar on the tick or price change upon which it was determined that a profit target exit occurred, which will not necessarily be the high of the bar on the close of the bar.
The logic that determines if a bar is a stop loss, trailing stop, parabolic trailing stop, or profit target exit bar is based on the assumption that the signal names of the exit orders for these four types of money management stops are always “Stop loss”, “Trail stop”, “Parabolic stop”, and “Profit target” respectively, as is stated on the official NinjaTrader® help pages for the “SetStopLoss()” method (a “method” is also commonly referred to as a “function”) at https://ninjatrader.com/support/helpGuides/nt8/setstoploss.htm, “SetTrailStop()” method at https://ninjatrader.com/support/helpGuides/nt8/settrailstop.htm, “SetParabolicStop()” method at https://ninjatrader.com/support/helpGuides/nt8/setparabolicstop.htm and “SetProfitTarget()” method (a “method” is also commonly referred to as a “function”) at https://ninjatrader.com/support/helpGuides/nt8/setprofittarget.htm. These four official NinjaTrader® help pages seem to suggest that the four signal names are always as previously mentioned regardless of the language settings of a given NinjaTrader® installation, and a quick test of this strategy on a NinjaTrader® installation with the language set to “French” appeared to work correctly, but this assumption was not tested on NinjaTrader® installations with language settings other than English or French.
This strategy demonstrates how to use “Color” input parameters so you can change colors used by a strategy from a color picker in the NinjaTrader® user interface. Note that if you need to calculate a color on each bar close, price change, or tick and the color could be one of many colors, such as a gradient from red to yellow to green through all the colors in between, instead of using a Color input parameter you can use a Color internal variable and set it to your calculated color on each bar close, price change, or tick by putting your color calculation logic in the “When Bar Updates” section. Then, you can use the Color internal variable with the calculated color anywhere in the “When Bar Updates” section where you would normally see a color picker by clicking the gear icon next to the color picker and selecting your Color internal variable from the “Input Parameters and Internal Variables > Internal Variables” context menu subfolder instead of selecting a Color input parameter from the “Input Parameters and Internal Variables > Input Parameters” context menu subfolder as was done to build this strategy.
This strategy also demonstrates how to use “List of Choices” input parameters so you can change the values of drop-down lists used by a strategy from a drop-down list in the NinjaTrader® user interface. An example of a drop-down list used by this strategy is the one that lets you set the “Trailing Stop Calculation Mode” to a value such as “Percent” or “Ticks” from a drop-down list in the NinjaTrader® user interface. Note that if you need to calculate the value of a drop-down list on each bar close, price change, or tick, instead of using a “List of Choices” input parameter you can use a “List of Choices” internal variable and set it to your calculated drop-down list value on each bar close, price change, or tick by putting the logic that determines the selection for the drop-down list in the “When Bar Updates” section. Then, you can use the “List of Choices” internal variable with the calculated drop-down list selection anywhere in the “When Bar Updates” section where you would normally see a “List of Choices” drop-down list by clicking the gear icon next to the “List of Choices” drop-down list and selecting your “List of Choices” internal variable from the “Input Parameters and Internal Variables > Internal Variables” context menu subfolder instead of selecting a “List of Choices” input parameter from the “Input Parameters and Internal Variables > Input Parameters” context menu subfolder as was done to build this strategy.
This strategy also demonstrates how to group input parameters together under separate headings in the NinjaTrader® user interface by using the same value in the “Category” field of each related input parameter that should go under a specific heading. The “Category” field of a Quagensia N Edition Strategy’s input parameter is hidden by default but can be shown and filled out by clicking the “Advanced Fields” link of the input parameter. This link was already clicked for all of the input parameters of this strategy which is why the “Category” fields of all the input parameters of this strategy are visible.
This strategy also demonstrates how to create translucent colors using the “Create a Partially or Fully Transparent Color” function.
Copyright © 2024 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.


