Using Advanced NinjaScript® Objects in Quagensia® N Edition

What are “advanced NinjaScript® objects”?

Advanced NinjaScript® objects such as Orders, Executions, Positions, Accounts, and Instruments, are a part of NinjaScript® that allow advanced NinjaScript® programmers to create highly advanced trading logic by writing code and that allow advanced users of Quagensia® N Edition to create highly advanced trading logic completely without code.

Common uses of advanced NinjaScript® objects include the use of the “Order” and “Execution” objects that are parameters of the “OnOrderUpdate()” and “OnExecutionUpdate()” event-driven methods of NinjaScript® strategies, respectively. You can do these types of things, and many more, with advanced NinjaScript® objects in your Quagensia N Edition Strategies without code.

The NinjaTrader help documentation includes many help pages on advanced NinjaScript® objects and the advanced event-driven methods of NinjaScript® strategies that use them.

It is beyond the scope of this help page to fully document advanced NinjaScript® objects. Rather, the purpose of this help page is to help advanced Quagensia N Edition users that are already familiar with using advanced NinjaScript® objects directly in NinjaScript® strategies know how to accomplish the same things without code in Quagensia N Edition.

Creating Advanced NinjaScript® Object Internal Variables Without Code in Quagensia N Edition Strategies and Functions

You can create an Internal Variable of one of the various types of advanced NinjaScript® objects by scrolling down to the “Internal Variables” section of your Quagensia N Edition Strategy and choosing an advanced NinjaScript® object type from the hierarchical “Type” drop-down list’s “Advanced Data Types >> NinjaScript®/Advanced Objects” folder.

You can also create Lists and Arrays, including multi-dimensional arrays, whose data type of individual items is set to an advanced NinjaScript® object, so for example you could create a 2-dimensional array of Order objects.

You can create Internal Variables of these types in both Quagensia N Edition Strategies and Quagensia N Edition Functions. Furthermore, Quagensia N Edition Functions can even have Input Parameters of these types and can return expressions of these types.

Using Advanced NinjaScript® Objects That Are Passed As Input Parameters to Advanced Event-Driven Methods Like “OnOrderUpdate()” and “OnExecutionUpdate()”

Most of a NinjaScript® strategy’s advanced event-driven methods, such as “OnOrderUpdate()” and “OnExecutionUpdate()”, have one input parameter that is an advanced NinjaScript® object. For example, the “OnOrderUpdate()” event-driven method has an “Order” input parameter and the “OnExecution()” event-driven method has an “Execution” input parameter.

When you click on a location in the “When OnOrderUpdate Occurs” section of a Quagensia N Edition Strategy where an “Order” object is allowed, you can add the “Order” input parameter of the “OnOrderUpdate()” event-driven method to your strategy’s logic by selecting the “OnOrderUpdate Event’s ‘Cbi.Order order’ Parameter” no-code function located in the “When OrderUpdate Occurs” folder of the context menu that appears. You can use this same procedure with the other advanced NinjaScript® event-driven methods that have an input parameter of one of the advanced NinjaScript® object types and that have a corresponding section in Quagensia N Edition Strategies.

If your Quagensia N Edition Strategy has an Internal Variable of type “Order”, you can use a “Set a Variable” Action in the “When OnOrderUpdate Occurs” section to set the Internal Variable of type “Order” to the Order object that is passed to the “OnOrderUpdate()” event-driven method. You can use this same procedure with the other advanced NinjaScript® event-driven methods that have an input parameter of one of the advanced NinjaScript® object types and that have a corresponding section in Quagensia N Edition Strategies from where you can set an Internal Variable of the relevant advanced NinjaScript® object type.

Advanced NinjaScript® objects have “properties” that can be accessed without code in Quagensia N Edition. An example of a property is an Order object’s “Quantity”, which is of type “Whole Number”, and “Stop Price”, which is of type “Decimal Number”.

To use properties of an “Order” object, whether it is the “Order” object passed as an input parameter to the “OnOrderUpdate()” event-driven method, an Internal Variable whose type is “Order”, or any other Order object, click on a location in your Quagensia N Edition Strategy’s logic where the given property is allowed, such as clicking on a location that allows Whole Numbers for the case of the “Quantity” property of the Order object, and select the property in the advanced NinjaScript® object’s corresponding subfolder in the “NinjaScript®/Advanced Objects” folder of the context menu that appears. For example, if you click on a location where a Whole Number is allowed, you could access an Order object’s “Quantity” property by selecting the no-code function named “Quantity Property of Non-Null Order NinjaScript® Object” in the “NinjaScript®/Advanced Objects >> Order NinjaScript® Object” folder of the context menu that appears. Once the no-code function is added to your logic, you can then click on the no-code function’s single parameter and navigate to the Order object whose property, such as its “Quantity” property, is desired and select the object.

Note that the procedure in the paragraph above assumes that the object passed into the no-code function is not “null”, i.e. it has been set to an actual object, such as an Order object. If you use the procedure above with a “null”, or “unset”, object a runtime error will occur. To avoid such errors, you should check if the object is null before attempting to access its properties in this way, and if the object is null then do not attempt to access its properties. You can do this by creating an “If the following condition is true…” Action block with a condition that checks if the object “Is Equal To” the “Null Value” for the object and then putting all logic that accessed the object’s properties using the method described above inside the “If the following condition is true…” Action block. To create the “If the following condition is true…” Action block’s condition, first set the comparison operator of the condition to “Is Equal To”. Second, change the left side of the condition to the object. Finally, set the right side of the condition to the no-code function for the “Null Value” of the object, which you can find in the same folder of the context menu where you selected the no-code function for the object’s specific property such as the “Quantity” property of an Order object. For instance, if the object on the left side of the condition is an Order, you can click on the right side of the condition and select the no-code function named “Null Value for an Order NinjaScript® Object” from the “NinjaScript®/Advanced Objects >> Order NinjaScript® Object” folder of the context menu that appears.

Note that everything described above, with the exception of accessing a specific input parameter of a specific advanced event-driven method, can be done in the “When Bar Updates” section of a Quagensia N Edition Strategy or the “Function Logic” section of a Quagensia N Edition Function, in a “When Button Control is Clicked” section of a Quagensia N Edition Strategy, and in many other sections.

Which Advanced NinjaScript® Objects Does Quagensia N Edition Support, and Where Can I Learn More?

Quagensia N Edition supports each of the following advanced NinjaScript® objects. Click on an object below to visit a help page on the official NinjaTrader website containing more information about it.

  1. Account
  2. ConnectionStatusEventArgs
  3. Execution
  4. FundamentalDataEventArgs
  5. Instrument
  6. MarketDataEventArgs
  7. MarketDepthEventArgs
  8. Order
  9. Position

Note that currently Quagensia N Edition does not support all properties of the objects above, but an attempt was made to support the most commonly used properties.

Submit your high-quality Quagensia tutorials for consideration for free inclusion on our website.

If you publish high-quality Quagensia tutorials on a social media platform like YouTube, please consider submitting them to us. We may promote them for free by linking to them from relevant pages on our website.

To submit your Quagensia tutorials for consideration for free inclusion on our website, use the How to Submit Your Quagensia-Enhanced Content page. We are available by phone or email to help you create, publish, and promote Quagensia-enhanced content. You can also get questions answered in our Content Creator Support Center and in the official Quagensia® Discord community’s content-creators channel.

Thanks for Sharing!

Ready to get started?

Download the Quagensia no-code strategy builder free trial and build your trading strategies now.

Under a dollar a day.

Priced to be an easy decision for most traders.

Join Us on Discord

Build point-&-click strategies for NinjaTrader® and TradeStation® using Quagensia®. Collaborate with other traders to get and give help, build and backtest strategies together, and grow your skills.

Subscribe to our Newsletter

We'll send you product updates and company news from Quagensia as well as curated lists of Quagensia-enhanced content.

Welcome
Content Creators

Quagensia enables content creators to make interactive content. We invite you to create Quagensia-enhanced content and share it on YouTube and other social media channels. You may submit your high-quality Quagensia-enhanced content for consideration for free inclusion on our website.

Screenshots

For larger and additional screenshots, see large Quagensia N Edition screenshots (for NinjaTrader®) and large Quagensia T Edition screenshots (for TradeStation®).

For additional screenshots, see the list of Strategies Built into Quagensia N Edition (for NinjaTrader®) and Strategies Built into Quagensia T Edition (for TradeStation®). Select a built-in strategy that interests you and scroll down for the screenshot. Then scroll up to the top of the page and click the “Overview” link to watch the video on how to use that built-in strategy.

This is a screenshot of the point-and-click trading strategy you will build in Quagensia N Edition (for NinjaTrader®) if you follow along with the video titled Create NinjaTrader® Strategies Using Point-&-Click with Quagensia N Edition – Full Tutorial.

This is a screenshot of the point-and-click trading strategy you will build in Quagensia N Edition (for NinjaTrader®) if you follow along with the video titled "Introduction to Quagensia N Edition".

Click the gear icon that appears when you place your mouse pointer over the location to which you would like to add trading logic. A context menu will appear with filtered options to choose from.

Click the gear icon that appears when you place your mouse pointer over the location to which you would like to add trading logic. A context menu will appear with filtered options to choose from.

Thanks for Sharing!

Ready to get started?

Download the Quagensia no-code strategy builder free trial and build your trading strategies now.

Under a dollar a day.

Priced to be an easy decision for most traders.

Join Us on Discord

Build point-&-click strategies for NinjaTrader® and TradeStation® using Quagensia®. Collaborate with other traders to get and give help, build and backtest strategies together, and grow your skills.

Subscribe to our Newsletter

We'll send you product updates and company news from Quagensia as well as curated lists of Quagensia-enhanced content.

Welcome
Content Creators

Quagensia enables content creators to make interactive content. We invite you to create Quagensia-enhanced content and share it on YouTube and other social media channels. You may submit your high-quality Quagensia-enhanced content for consideration for free inclusion on our website.