Noise-Tolerant Trend Determination (Uses Loop) (Point-and-Click TradeStation® Strategy)
Original Trading Strategy
Links to the section of the video titled “Using & Customizing the Built-In Strategies in Quagensia T Edition” in which this built-in strategy is covered.
Peer Reviews, Modifications & Responses
Thanks for Sharing!
Trading Strategy Summary
No-code strategy building tools that lack features like lists, arrays, and loops make it tremendously difficult or impossible to create trading strategies that can deal with the reality that prices rarely move in perfect patterns like those drawn in technical analysis textbooks.
In general, market action has a low signal-to-noise ratio, with a lot of apparently random price movements, price spikes, and countertrend movements mixed in with what to the human eye are clear market trends and price patterns that may have been bullish or bearish signals in the past and which warrant a backtest to find out.
To determine if market action similar to the noisy market trend or price pattern that you see on a chart was bullish, bearish, or non-predictive in the past, you need to create a backtestable trading strategy that enters a trade each time market action similar to the noisy market trend or price pattern occurred in the past.
That’s what this Quagensia Strategy enables you to do.
Quagensia T Edition’s features such as lists, arrays, and loops make it possible to codelessly use point-and-click to build trading strategies that can correctly deal with the real world complexities of identifying trends and market patterns that aren’t quite perfect. These features make it relatively easy to look at market action more broadly and comprehensively with a reasonable margin of error to account for things like price spikes and countertrend movements by making it possible to create trading strategies that can do things like the following:
1. Loop over a given number of recent bars to determine if all of the recent bars were in an up trend based on one or more metrics at the times the bars closed. This provides a more complete view of whether prices are in an up trend than only looking at trend metrics of the current bar such as the slope of a moving average at the time the current bar closed. This Quagensia Strategy uses this approach using loops.
2. Require that only a given percentage of recent bars need to be in an up trend for the entire range of recent bars to be considered to be in an up trend. This is one way to determine that the market is in a strong up trend and has been for awhile in spite of the presence of a few price spikes and countertrend price movements that would cause a few bars in the last 50 recent bars to not be in an up trend by the chosen metrics.
3. Rank the current price bar’s trend metrics against the trend metrics of recent bars to determine if the current bar is in more of an up trend than some percentage of recent bars. This makes it possible to determine if the current bar has up trend metrics that are in the 80th percentile of the last 100 recent bars.
4. Rank the current price bar’s trend metrics against only the recent bars whose trend metrics are above a certain threshold. This makes it possible to determine if the current bar has up trend metrics that are in the 80th percentile of only the bars in the last 100 recent bars who also had strong up trend metrics.
This Quagensia Strategy is a noise-tolerant trend following system that demonstrates using a loop to determine if something is true for each the last X bars.
Specifically, this strategy enters a long position if the close prices of each of the last X bars are higher than the close prices of the bars Y bars before them. Each of the last X bars is compared to the bar Y bars before it.
This method of trend determination is noise-tolerant because it can handle market action that has a low signal-to-noise ratio caused by a lot of apparently random price movements, price spikes, and countertrend movements mixed in with what to the human eye is a clear market trend.
To compare each of the last X bars to the bar Y bars before it, a loop is used to loop over each of the last X bars and compare each of the bars’ close prices to the close prices of the bar Y bars before each of the bars.
Quagensia T Edition makes it easy to create different kinds of loops, and even create loops inside of loops that are inside of other loops, to execute the same trading logic multiple times. Actions such as “Exit Out of This Loop” and “Continue Back to the Loop Condition of This Loop” give you total control over loop execution.
Copyright © 2023 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.


