Noise-Tolerant Trend Determination (Uses Tables of Data In-Memory) (Point-and-Click NinjaTrader® Strategy)
Original Trading Strategy
Links to the section of the video titled “Using & Customizing the Built-In Strategies in Quagensia N 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 tables of data, 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 N Edition’s features such as tables of data, 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.
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 uses this approach using tables of data.
This Quagensia Strategy is a trend following strategy that demonstrates how to do the following powerful things with tables of data:
1. Creating an in-memory table of data that is initially empty and then populating the table of data from calculations in the strategy instead of loading the table of data from a tabular data file on disk.
2. Querying and manipulating the data using 1) filtering, 2) sorting, and 3) extracting a number of rows from the bottom of a data table.
3. Doing queries whose results overwrite the data in the queried table of data.
4. Doing queries whose results are copied into a new table of data rather than overwriting the queried table of data.
NOTE #1: This strategy requires that the “Calculate” setting is set to “On Bar Close”.
NOTE #2: This strategy uses Quagensia N Edition’s Quagensia Table System, which is also called the “tables of data” feature. This feature only works properly if the proper versions of the QuagensiaNEditionRuntime.dll, QuagensiaNEditionRuntime.cs, and QuagensiaRuntime.dll files are present in the NinjaTrader® Bin-Custom folder and the QuagensiaNEditionRuntime.dll and QuagensiaRuntime.dll files are properly “referenced”, all of which is accomplished by importing the QuagensiaNEditionRuntime.zip NinjaScript® add-on file that comes with Quagensia N Edition into NinjaTrader®. If the proper versions of the QuagensiaNEditionRuntime.dll, QuagensiaNEditionRuntime.cs, and QuagensiaRuntime.dll files are not present in the NinjaTrader® Bin-Custom folder when you generate the code for a Quagensia N Edition Strategy that uses the “tables of data” feature, the Quagensia N Edition Runtime Setup Assistant will automatically open and will guide you through the quick and easy process of importing the QuagensiaNEditionRuntime.zip NinjaScript® add-on file that comes with Quagensia N Edition into NinjaTrader®.
Quagensia N Edition’s innovative Quagensia Table System makes it easy to load tables of many kinds of data, not just time series data, from tabular data files into in-memory data tables that you can query, modify, and then write back to tabular data files on disk from your strategies.
If you have valuable data in Microsoft Excel files, a database such as Microsoft SQL Server, SQLite, or MySQL, if you have access to exotic data via Bloomberg® Terminal®, Refinitiv® Eikon®, or another high end institutional platform, if you have tabular data output from MATLAB® or R, or if you have access to alternative data sources on the internet, it is generally very easy to get these kinds of data into comma-delimited, semicolon-delimited, or otherwise character-delimited tabular data files. And once you do, it is easy to get all of this data, even entire databases of data, into your NinjaTrader® strategies by simply clicking choices on the screen.
As this strategy demonstrates, you can also create in-memory data tables and populate them with data from scratch, i.e. not from tabular data files, and then create, modify, and delete rows from these in-memory data tables.
Regardless of how you create your in-memory data tables, Quagensia N Edition makes it easy to write that data to tabular data files on disk.
This allows you to run a backtest or optimization of a NinjaTrader® strategy that outputs a report containing tabular data that you can load into any database, use as input data in MATLAB® or R, or load into Microsoft Excel to manipulate further and use to create visually powerful charts and graphs that answer your questions about the markets in ways that backtest performance reports cannot.
All features just described work with data columns of 73 different types of data including: 10 numeric data types, 3 date/time data types, colors, Booleans (true or false), text, and 57 “lists of choices” data types such as the months of the year or the days of the week.
Copyright © 2023 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.


