Introduction
You can use secondary price bars in your Quagensia® N Edition Strategies to enable your strategies to run on a main set of price bars but access data from a second, third, fourth, or higher order set of “secondary price bars”.
For example, you can create a strategy that uses the daily price bars for a single stock as its primary price bars, but your strategy can also consider the high or low prices of a “secondary” set of price bars, such as the daily price bars of gold futures or the monthly price bars of the same stock on whose daily data your strategy is using as its primary price bars.
The NinjaTrader® Desktop platform provides excellent support for NinjaTrader® strategies that use secondary price bar data series in their trading logic. You can read the official Ninjatrader® Help Guide’s Multi-Time Frame & Instruments topic to get a deeper understanding of the concepts involved with trading strategies that use secondary price bars in NinjaTrader®.
Quagensia® N Edition allows you to create an Internal Variable of type “Secondary Price Bars” in a Quagensia N Edition Strategy that creates a secondary price bar time series in your NinjaTrader® strategy. A secondary price bar time series can have a different symbol, a different bar period, or a different symbol and bar period than the main set of price bars, i.e. the “primary price bars”, on which your strategy runs.
To view all numeric secondary price bar time series for a Quagensia N Edition secondary price bars variable, click on any location in the “When Bar Updates” section where a number or numeric time series is allowed, and open the “Replace/Set Item >> Price Data >> Secondary Price Bars” context menu folder.
You can view the time series of bar end times for a Quagensia N Edition secondary price bars variable by following the same procedure, but clicking instead on a location in the “When Bar Updates” section where “date and time” values or time series of “date and time” values are allowed.
To learn more about using this feature in Quagensia N Edition, place your mouse pointer over either a data type list with the “Secondary Price Bars” data type selected or place it over the “Secondary Price Bars” control and press the F1 key, or either place your mouse pointer over the icon in the right or upper right of any item in the “Secondary Price Bars” control or place it over the label next to any editable field in the “Secondary Price Bars” control and a tooltip will appear.
The Check Box Labeled “Logic in ‘When Bar Updates’ Section Should Be Executed for This Secondary Price Bars’ ‘When Bar Updates’ Events”
When you add an internal variable of type “Secondary Price Bars” to the “Internal Variables” section of a Quagensia N Edition Strategy, you will need to decide if the check box labeled “Logic in ‘When Bar Updates’ Section Should Be Executed for This Secondary Price Bars’ ‘When Bar Updates’ Events” should be checked or unchecked.
If the trading logic in this strategy’s “When Bar Updates” section should be executed for this Secondary Price Bars’ data series’ “When Bar Updates” events, then check this check box.
If the trading logic in this strategy’s “When Bar Updates” section should not be executed for this Secondary Price Bars’ data series’ “When Bar Updates” events, then uncheck this check box.
When this check box is unchecked, it protects users from creating a strategy that behaves in unexpected and undesirable ways due to trading logic being executed in the “When Bar Updates” section for this Secondary Price Bars’ data series.
For example, the official NinjaTrader® help guide’s descriptions of many functions that enter and exit positions include statements that the functions enter and exit positions for the instrument of the “current” price bars’ data series, i.e. the instrument of the price bars’ data series for which the “When Bar Updates” section is being called in your Quagensia N Edition Strategy, not the instrument of the primary price bars’ data series. This applies to all money management functions in the “Money Management” subfolder of the Actions context menu. This also applies to all order submission functions in the “Submit an Order” subfolder of the Actions context menu that are not in an additional subfolder called “Multi-Instrument/Time Frame” and whose function names do not specifically have the suffix “(Multi-Instrument/Time Frame)”.
Furthermore, even if the instrument of a secondary price bars’ data series is the same as the instrument of the primary price bars’ data series, the official NinjaTrader® help guide recommends that you only submit orders for an instrument “to the first bars context of that instrument”, which for Quagensia N Edition Strategies means only submitting orders for an instrument in the “When Bar Updates” section of the primary price bars’ data series if the order’s instrument and the instrument of the primary price bars’ data series are the same. And if the order’s instrument is not the same as the instrument of the primary price bars’ data series, this means only submitting orders for that instrument when in the “When Bar Updates” event for the first secondary price bars’ data series for that instrument, where “first” means the first internal variable from the top of the “Internal Variables” section of your Quagensia N Edition Strategy that is a “Secondary Price Bars” for that instrument.
If this check box is checked, all “Submit an Order” actions not marked as “(Multi-Instrument/Time Frame)” and all “Money Management” actions (in the context menu subfolders described above) should only be used inside of a “Conditional Trading Logic” block, i.e. an “If” block, whose condition set includes a condition that determines the price bars’ data series for which the current “When Bar Updates” trading logic is being executed. To create such a condition, set the condition’s comparison operator to “Is Equal To” or “Is Not Equal To”, then click on the location to the left of the comparison operator and select one of the relevant functions in the Expressions context menu subfolder “Price Data > Price Bar Metadata > Multi-Instrument/Time Frame” such as “OnBarUpdate() Is Being Called For The Primary Data Series”, “OnBarUpdate() Is Being Called For The Second Data Series (BarsInProgress Index = 1)”, or “OnBarUpdate() Is Being Called For The (N + 1)th Data Series (BarsInProgress Index = N)”, and set the location to the right of the comparison operator to a Whole Number or Boolean (True or False) value accordingly.
You can add Secondary Price Bars of *any* bar type supported in a NinjaTrader NinjaScript Strategy by pasting a single line of NinjaScript code into a text box in Quagensia N Edition.
When you click the button labeled “Paste a Line of Code into a Text Box Instead to Add Secondary Price Bars of *Any* Bar Type Supported in NinjaScript® (Advanced)” at the bottom of the user interface of a Secondary Price Bars Internal Variable in the Internal Variables grid of a Quagensia N Edition Strategy, the standard no-code user interface for adding Secondary Price Bars will be replaced with an advanced user interface that has a text box where a line of NinjaScript code can be pasted to add a Secondary Price Bars Internal Variable (i.e. a secondary data series) of any bar type that supports being added to a NinjaTrader NinjaScript strategy with a line of NinjaScript code, including secondary data series of the following bar types:
- Volumetric Bars (Using the “AddVolumetric” Function)
- Renko Bars (Using the “AddRenko” Function)
- Heiken Ashi Bars (Using the “AddHeikenAshi” Function)
- Kagi Bars (Using the “AddKagi” Function)
- Line Break Bars (Using the “AddLineBreak” Function)
- Point and Figure Bars (Using the “AddPointAndFigure” Function)
- Price on Volume Bars (Using the “AddPriceOnVolume” Function) (We at Quagensia know of no official help page for the “AddPriceOnVolume” function.)
- Delta Bars (Using the “AddDataSeries” function like the following, where 15 is the Order Flow Delta bar type, Value is the Trend Delta, and Value2 is the Trend reversal:
- AddDataSeries(null, new BarsPeriod() { BarsPeriodType = (BarsPeriodType)15, Value = 500, Value2 = 500 });)
- Custom Bar Types from Third Parties (Using a Line of Code Provided by the Third Party)
Secondary Price Bars Internal Variables added with a line of code can be used in all of the no-code ways that Secondary Price Bars Internal Variables that are added using the standard no-code user interface can be used in all other locations in a Quagensia N Edition Strategy without any additional code.
You can learn more about this feature on the Add Secondary Price Bars of Any Bar Type Supported in a NinjaTrader® NinjaScript® Strategy to a Quagensia® N Edition Strategy help page.
Important Information About Secondary Price Bar Data Series and Their Indicators in NinjaTrader®
Other Resources
Please also read the official Ninjatrader® Help Guide’s Multi-Time Frame & Instruments topic to get a deeper understanding of trading strategies that use secondary price bars in Ninjatrader®.