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:
- OnStateChange() >> State.DataLoaded >> Below All Other Code
- OnStateChange() >> State.Historical >> Above All Other Code
- OnStateChange() >> State.Historical >> Below All Other Code
- OnStateChange() >> State.Transition >> Above All Other Code
- OnStateChange() >> State.Transition >> Below All Other Code
- OnStateChange() >> State.Realtime >> Above All Other Code
- 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:
- 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.
- 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:
- 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.
- 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.
- 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.