Turn Indicator Entry Filters On and Off and Don’t Plot Off Indicators (Using Boolean Variables to Simplify the Entry Condition Set) (Point-and-Click NinjaTrader® Strategy)
Original Trading Strategy
Peer Reviews, Modifications & Responses
Thanks for Sharing!
Trading Strategy Summary
With the exception of the background color used to draw on the chart to identify entry signal bars, this strategy is identical to the strategy built into Quagensia N Edition titled “Turn Indicator Entry Filters On and Off and Don’t Plot Off Indicators” except that it simplifies the rather large and unwieldy set of conditions in the “If the following condition is true…” section of the “Conditional Trading Logic (If Block)” that contains the entry logic of that strategy.
It does this by using a technique that you can use for much more complicated sets of conditions than the toggleable entry filters of this strategy, including sets of conditions that would otherwise have lots of nested parentheses and complicated logic that is hard to understand and change and that requires too much vertical scrolling.
This technique is as follows:
1. First, create Boolean (True or False) internal variables for each subset of the complex set of conditions in the “If the following condition is true…” section of the “Conditional Trading Logic” block whose logic you would like to simplify. In this strategy we created one Boolean (True or False) internal variable for each of the toggleable entry filters.
2. Then, directly above the “Conditional Trading Logic” block whose set of conditions you would like to simplify, set each Boolean variable to a subset of the complex set of conditions. In this strategy a “subset of the complex set of conditions” is a single toggleable entry filter. It is your choice on how you divide up the complex set of conditions into subsets in your own strategies, so you could have less Boolean (True or False) variables that have more complex logic or more Boolean variables that have just a single condition or single toggleable condition.
—- 2A. The way you set a Boolean (True or False) internal variable to a set of conditions is to first create a “Set a Variable” action above the “Conditional Trading Logic” block by clicking on the outermost top-right most gear icon of the “Conditional Trading Logic” block and choosing “Add Item Before Me > Set a Variable > (The Boolean variable name)”.
—- 2B. To set the Boolean (True or False) internal variable to a set of conditions, click on the “(Not Set)” on the right side of the “Set a Variable” action and choose either “Standard Condition (X = Y, X > Y, etc.)” or “Set of Conditions (Combined With AND/OR)”. Note that even if you choose the “Standard Condition (X = Y, X > Y, etc.)”, you can click on the gear icon on the far right of the single condition and turn it into a set of conditions… it just takes an extra step.
—- 2C. Then, simply build out a simple or complex set of conditions on the right side of the “Set a Variable” action the way you normally would. You can copy and paste each individual condition (two copy-and-paste actions in total for one toggleable condition in this example strategy). You may have to add parentheses around some of the pasted conditions for more complex sets of conditions, but this is not required for the simple toggleable entry filters in this example strategy. After doing two copy-and-pastes, the toggleable condition in the parentheses in this example strategy will be on the right side of the “Set a Variable” action. Just make sure that when you copy and paste your own toggleable entry filters that you change the AND between the toggle condition and the actual entry condition to an OR. In this case the parentheses surrounding a given toggleable entry filter aren’t needed, but you can add them if you need them for more complex sets of conditions.
3. Finally, replace the complex set of conditions in the “Conditional Trading Logic” block’s “If the following condition is true…” area with a simple condition that checks if the Boolean (True or False) internal variable is equal to True. In the case of the toggleable condition in this example, the parentheses aren’t needed anymore.
The text below comes from the strategy built into Quagensia N Edition titled “Turn Indicator Entry Filters On and Off and Don’t Plot Off Indicators” and applies both to that strategy and this one:
This strategy demonstrates how to add “toggleable” indicator-based entry filters to your trading strategy’s entry criteria and demonstrates how to toggle indicator visibility based on your strategy’s input parameters as well.
A toggleable entry filter is one that can be turned on or off from the NinjaTrader® user interface by setting input parameters to specific values that turn the toggleable entry filter on or off.
The conditions that turn a toggleable entry filter on or off and that toggle indicator visibility can be based on something as simple as whether or not a single “Boolean (True or False)” input parameter is set to True or False due to a checkbox being checked or unchecked in the NinjaTrader® user interface as is demonstrated in this strategy. The entry filter toggle conditions can be complex as well, and use ANDs, ORs, and parentheses, but this is not demonstrated in this strategy.
One great thing about using “Boolean (True or False)” input parameters for toggle conditions is that NinjaTrader® allows optimizations over “Boolean (True or False)” input parameters, so you can optimize strategies with toggleable conditions like this one using every combination of on and off for each indicator-based filter’s toggle condition. Since this strategy has four toggleable conditions, this creates 2^4 = 16 possible combinations of on and off filter toggle conditions. You can also optimize over this strategy’s numeric input parameters such as moving average lengths as well.
In this strategy, when a toggleable entry filter’s checkbox is unchecked in the NinjaTrader® user interface it will not be used as one of the entry conditions that are required to be True in order to enter a position and the indicator used by the toggleable entry filter will not be plotted on the chart upon which the strategy is applied. When its checkbox is checked the entry filter will be used as one of this strategy’s required entry conditions and the indicator used by the toggleable entry filter will be plotted on the chart.
The way that each entry filter was turned into a “toggleable entry filter” can be seen in this strategy’s “When Bar Updates” section. Note how each toggleable entry filter is “ORed” together with its specific toggle condition that turns it on or off and that these two conditions are inside of paretheses so that they are determined to be True or False as a group. The condition above each OR checks if the entry filter’s toggle is on or off. If the entry filter’s toggle condition is off then the ORed conditions in the parentheses are evaluated as True regardless of whether the specific indicator-based entry filter is True or False on that bar, tick, or price change and won’t filter out entry signals on that bar, tick, or price change. If the entry filter’s toggle condition is on then the specific indicator-based entry filter must be True for the ORed conditions in the parentheses to be evaluated as True for the entry signal to not be filtered out on that bar, tick, or price change.
The way that the indicators are plotted or not plotted based on if their respective entry filter toggles are turned on or off is by creating a condition in the plotting settings for that indicator’s internal variable that must be True for the indicator to be plotted. You can use this technique to conditionally plot indicators, Editable Time Series, and horizontal lines that you define as internal variables in your own strategy’s internal variables section by checking the “Plot This” checkbox of the internal variable, clicking the link that reads something like “Set Conditions That If False Will Cause Plot to Not Be Plotted” and then building a condition or set of conditions in the field that appears.
Note that while this strategy uses toggleable entry filters, you can create “toggleable exit filters” using the same approach.
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.
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.


