How to Paste NinjaScript® Code into Your Quagensia N Edition Strategy

You can convert a pre-existing NinjaScript® strategy into a no-code Quagensia N Edition Strategy with a mix of no-code trading logic and raw NinjaScript® code, regardless of how complex the NinjaScript® strategy is and regardless of how many thousands of lines of NinjaScript® code it has.

The “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section offers all possible locations in your NinjaScript® strategy’s outputted code file, other than the locations represented in the sections above the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section, where you can copy and paste code from a NinjaScript® strategy into “Raw Code Output (Single or Multiple Statements)” Action text boxes in your no-code Quagensia® N Edition Strategy.

Furthermore, seven of the 30 separate subsections in the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section in which you can paste raw NinjaScript® code also allow the use of most of the no-code features and functions that are available in the “Internal Variables” section of a Quagensia N Edition Strategy, as well as most of the no-code features and functions that are available in the “Money Management” section of a Quagensia N Edition Strategy (with the notable exception of the no-code functions that are available in the “Money Management” section that set up the actual “money management” of the strategy like the no-code functions that start with “Set Stop Loss” and “Set Profit Target”). The seven subsections in the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section that allow the use of these no-code features and functions are:

  1. OnStateChange() >> State.DataLoaded >> Below All Other Code
  2. OnStateChange() >> State.Historical >> Above All Other Code
  3. OnStateChange() >> State.Historical >> Below All Other Code
  4. OnStateChange() >> State.Transition >> Above All Other Code
  5. OnStateChange() >> State.Transition >> Below All Other Code
  6. OnStateChange() >> State.Realtime >> Above All Other Code
  7. OnStateChange() >> State.Realtime >> Below All Other Code

Since the main purpose of this help page is to teach you how to copy and paste raw NinjaScript® code into a Quagensia N Edition Strategy and describe the use cases and benefits of doing so, and since the vast majority of Quagensia N Edition documentation is focused on the use of its no-code features and functions, the rest of this help page will focus entirely on pasting raw NinjaScript® code into a Quagensia N Edition Strategy rather than on the no-code features and functions you can use in the seven subsections listed above.

Copying and pasting NinjaScript® code into your Quagensia N Edition Strategy will enable you do the following powerful things:

  1. Convert a pre-existing NinjaScript® strategy into a no-code Quagensia N Edition Strategy that includes some copied and pasted NinjaScript® code from the NinjaScript® strategy but in which you can quickly and easily add no-code trading logic using point-and-click in Quagensia N Edition.
  2. Copy and paste NinjaScript® code fragments from 1) ChatGPT or Claude code output, 2) the official NinjaTrader® support forum or another reputable source of NinjaScript® code online, or 3) a NinjaScript® strategy in your possession to solve a specific problem or add trading logic to your otherwise no-code Quagensia N Edition Strategy using the NinjaScript® code you already have in your possession.

Practical examples of when you might benefit from doing one of the two things above include:

  1. There may not be a no-code function in Quagensia N Edition that does something that the NinjaScript® code in your possession does. For instance, maybe you have a large amount of complex code that uses webhooks, accesses and even updates a live database using a database technology like Microsoft SQL Server, SQLite, or MySQL, you have NinjaScript® code that integrates a NinjaScript® strategy directly with Microsoft Excel, MATLAB, or R, or does any other highly complex task and you want to simply copy and paste this code into your Quagensia N Edition Strategy in a way that outputs the NinjaScript® code to the right location in the NinjaScript® strategy outputted by Quagensia N Edition.
  2. You have already working NinjaScript® code that you neither want to spend the time required nor take the risks of mistakes in re-creating the NinjaScript® logic using the no-code functions and features of Quagensia N Edition.
  3. You have an entire NinjaScript® strategy that already works perfectly and you want to get it into a Quagensia N Edition Strategy as quickly as possible, without having to re-create any of its logic using the no-code functions and features of Quagensia N Edition so that you can then add entirely new no-code logic to your original NinjaScript® strategy without needing any programming knowledge.

There are 30 separate subsections in the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section in which you can paste raw NinjaScript® code. What follows is an example of one of them, specifically the “Bottom of File >> Above Strategy Ending Brace (i.e. ‘}’) (For Strategy’s Functions, Classes, and Enums)” section and how to use it, but the information in the section below applies to the other 29 sections as well.

Example: How to Paste Code Into the “Bottom of File >> Above Strategy Ending Brace (i.e. ‘}’) (For Strategy’s Functions, Classes, and Enums)” Section of a Quagensia N Edition Strategy that Will Be Outputted to That Location in the NinjaScript® Strategy’s Outputted Code File

The “Bottom of File >> Above Strategy Ending Brace (i.e. ‘}’) (For Strategy’s Functions, Classes, and Enums)” section is one of the locations in your NinjaScript® strategy’s outputted code file, other than the locations represented in the sections above the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section, where you can copy and paste code from a NinjaScript® strategy or a NinjaScript® code fragment into your no-code Quagensia N Edition Strategy.

Doing this will enable you to quickly and easily convert a NinjaScript® strategy into a no-code Quagensia N Edition Strategy that includes some copied and pasted NinjaScript® code from a NinjaScript® strategy or a NinjaScript® code fragment but in which you can quickly and easily add no-code trading logic using point-and-click in Quagensia N Edition.

The NinjaScript® code in the “Raw Code Output (Single or Multiple Statements)” Actions’ text boxes in this section will be outputted directly below the line of code in this Quagensia N Edition Strategy’s outputted NinjaScript® code file that starts with the following text:

				
					// Bottom of File >> Above Strategy Ending Brace (i.e. '}') (For Strategy's Functions, Classes, and Enums)
				
			

You can locate this line of code by generating the code of a Quagensia N Edition Strategy, then opening it in the NinjaScript® Editor and searching for the phrase that starts with “//” shown above.

To add a “Raw Code Output (Single or Multiple Statements)” Action that has a text box in which you can copy and paste NinjaScript® code, click the “Add Trading Logic” link at the bottom of this section and select “Raw Code Output (Single or Multiple Statements)” from the “More Actions” folder of the context menu that appears.

You can copy and paste NinjaScript® code directly into the text box of the “Raw Code Output (Single or Multiple Statements)” Action that appears when you do this.

“Raw Code Output (Single or Multiple Statements)” Actions can be used in more than just the subsections of the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section.

Note that you can add “Raw Code Output (Single or Multiple Statements)” Actions in other sections of your Quagensia N Edition Strategy, such as the “When Bar Updates” section, “When Button Control is Clicked” section, and the subsections of the “When Advanced NinjaScript® Events Occur” section as well. The difference between these other sections and the subsections of the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section is that “Raw Code Output (Single or Multiple Statements)” Actions are the only functional trading logic component that you can add to the subsections of the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section. In other words, the subsections of the “Other Locations in the Strategy Code File to Paste NinjaScript® Code” section are solely for copying and pasting raw NinjaScript® code into, whereas the other sections are usually for no-code trading logic but you can add “Raw Code Output (Single or Multiple Statements)” Actions whose text boxes contain raw NinjaScript® code in the other sections when desired.

To learn more about using the “Raw Code Output (Single or Multiple Statements)” Action, please read the Using the Raw Code Output (Single or Multiple Statements) Action help page. That help page discusses multiple key concepts and techniques such as how to use the no-code Input Parameters and Internal Variables that you added to your Quagensia N Edition Strategy without code directly in the raw NinjaScript® code pasted into a “Raw Code Output (Single or Multiple Statements)” Action text box so that the no-code logic in your Quagensia N Edition Strategy and the raw NinjaScript® code pasted into a “Raw Code Output (Single or Multiple Statements)” Action text box can interact rather than function independently as isolated islands of logic and information.

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.