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 TradeStation® Strategy)
Original Trading Strategy
Peer Reviews, Modifications & Responses
Thanks for Sharing!
Trading Strategy Summary
With the exception of the color of the vertical line used to draw on the chart to identify entry signal bars, this strategy is identical to the strategy built into Quagensia T 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 T 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 TradeStation® 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 in the TradeStation® 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.
In this strategy, when a toggleable entry filter’s input parameter is set to False in the TradeStation® 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 input parameter is set to True the entry filter will be used as one of this strategy’s required entry conditions and, in the case of the Simple Moving Average and Exponential Moving Average but not the oscillators, 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 parentheses 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.
Note that the oscillators used by this strategy will not be plotted on the chart even if their toggle conditions are set to True due to the reason discussed in the Quagensia T Edition onboarding card that describes why it is usually the best approach to add TradeStation® indicators manually from within TradeStation® rather than plotting them automatically from your Quagensia T Edition Strategy. Here is the relevant portion of that onboarding card (whose text may change in the future) that describes the problem with plotting oscillators automatically from your Quagensia T Edition Strategies:
“Many indicators should be plotted on a separate panel than the panel on which prices are displayed, because many indicators have plots whose numeric values are much lower or much higher than the prices of the instrument whose prices are used by the indicator to calculate its values. There is no way (of which we are aware) to automatically plot an indicator from within a TradeStation® EasyLanguage® strategy on a different panel than the panel on which the prices are displayed. By default, TradeStation® charts automatically select the minimum and maximum values of the Y-Axis of a price chart to fit the prices nicely without much wasted space at the top or bottom of the chart. If you automatically plot an indicator from within your strategy and your indicator’s values are much lower or higher than the prices of the instrument on which you are backtesting your strategy, it will not be visible on the chart. Even if you change the minimum or maximum value of the chart’s Y-Axis to include the numerical values of your indicator, both the prices and the indicator plot will be hard to see since both will be vertically compressed with most likely a large amount of wasted vertical space between them. When you add an indicator manually from within TradeStation®, it can be plotted on a different panel than prices, which solves this issue.”
Copyright © 2024 Quagensia, Inc. All rights reserved.
How to Get the Quagensia Strategies
This point-and-click trading strategy is built into Quagensia T Edition (for TradeStation®).
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.


