Plotting and Using the Values of Moving Averages Based on Secondary Price Bars [Algo File Only] (Point-and-Click NinjaTrader® Strategy)
Original Trading Strategy
Peer Reviews, Modifications & Responses
Thanks for Sharing!
Trading Strategy Summary
This point-and-click strategy for NinjaTrader® was built without code in Quagensia N Edition.
It should be run on 1-minute bars. If you are not paying for intraday market data you can still backtest this strategy on 1-minute bars of Bitcoin/USD (Symbol: BTCUSD) because you can gain access to the 1-minute bars of BTCUSD in the free version of NinjaTrader® for free by setting up the Coinbase market data connection in NinjaTrader®.
This strategy enters a long position, prints information to the NinjaScript® Output window, and draws on the chart if the following conditions are true:
- The strategy is not currently in a position, i.e. it is flat.
- The Fast Simple Moving Average (SMA) of the close prices of the primary price bar data series of 1-minute bars crossed above the Slow Simple Moving Average (SMA) of the close prices of the primary price bar data series of 1-minute bars.
- Either this strategy’s “Five-Minute MA Must Also Have a Crossover” input parameter was set to False due to its check box being unchecked in the NinjaTrader® user interface, or the Fast Simple Moving Average (SMA) of the close prices of a secondary price bar data series of 5-minute bars crossed above the Slow Simple Moving Average (SMA) of the close prices of the secondary price bar data series of 5-minute bars.
- The “When Bar Updates” section’s logic is being called due to a bar close, tick, or price change event for the primary price bars, which should be set to 1-minute bars when running this strategy.
There is no way (that we know of) to automatically plot a standard, unmodified indicator such as the ones that are built into NinjaTrader®, on a secondary price bar data series using the standard indicator plotting techniques in NinjaScript®. Learn more about this issue.
This strategy demonstrates how to work with multiple price bar data series and indicators based on secondary price bar data series, and demonstrates a point-and-click solution for plotting indicators based on secondary price bar data series by plotting them indirectly by plotting Quagensia N Edition “Editable Time Series” internal variables whose values are set to the same values as the Simple Moving Average (SMA) indicators that are based on a secondary price bar data series rather than plotting the Simple Moving Average (SMA) indicators directly.
This strategy will not plot the secondary price bars on the chart automatically. This is because there is no way (that we know of) for a NinjaScript® strategy to force a secondary price bar data series to appear on a NinjaTrader® chart. Learn more about this issue.
However, by the use of two Quagensia N Edition “Editable Time Series” internal variables that get set to the values of one fast and one slow moving average indicator of the close prices of a 5-minute bar secondary price bar data series it is at least possible to chart the moving averages of the invisible secondary price bar data series on the visible chart of the primary price bars.
The plots of the moving averages of the invisible secondary price bar data series of 5-minute bars will look jagged, or like “stair steps”, because these two moving averages are plotted on the visible chart of the 1-minute price bars, but the value of a moving average based on the close prices of the 5-minute price bar data series can only change at most once every five consecutive 1-minute bars for all price bars in a backtest and all bars on a live chart (with the exception being the last bar on the live chart if “Calculate” is set to a value other than “On Bar Close” and the last bar is partially complete), resulting in a horizontal line that is five 1-minute bars wide, followed by a diagonal line to the new value of the moving average based on the close prices of the 5-minute price bar data series on the next 1-minute bar, followed by another horizontal line that is five 1-minute bars wide, and so on.
How to Use This Strategy
- Run this strategy on a 1-minute bar chart.
- Set the “Five-Minute MA Must Also Have a Crossover” input parameter to True from within NinjaTrader® to cause a long entry to occur when moving average crossovers occur on the 1-minute and 5-minute time frames. Set the “Five-Minute MA Must Also Have a Crossover” input parameter to False from within NinjaTrader® to cause a long entry to occur when a moving average crossover occurs on the 1-minute time frame, even if one doesn’t occur on the 5-minute time frame.
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.
![Plotting and Using the Values of Moving Averages Based on Secondary Price Bars [Algo File Only] (Point-and-Click NinjaTrader® Strategy) Plotting and Using the Values of Moving Averages Based on Secondary Price Bars [Algo File Only] (Point-and-Click NinjaTrader® Strategy)](https://eadn-wc02-5937971.nxedge.io/images/trading-idea-images/2023/08/17/quagensia/plotting-and-using-the-values-of-moving-averages-based-on-secondary-price-bars-n.png)

![Screenshot for point-and-click trading strategy "Plotting and Using the Values of Moving Averages Based on Secondary Price Bars [Algo File Only]" Screenshot for point-and-click trading strategy "Plotting and Using the Values of Moving Averages Based on Secondary Price Bars [Algo File Only]"](https://eadn-wc02-5937971.nxedge.io/images/trading-idea-images/2023/08/17/quagensia/plotting-and-using-the-values-of-moving-averages-based-on-secondary-price-bars-n-full-1.png)