This tutorial provides a comprehensive guide on how to create, back-test, and optimize algorithmic trading strategies using Quagensia N Edition for NinjaTrader 8 without any coding. It covers the step-by-step process of building a simple moving average crossover strategy, generating code, and analyzing back-test results.
Quagensia N Edition simplifies the process of creating algorithmic trading strategies for NinjaTrader 8 without the need for coding. By using a point-and-click interface, users can easily translate their trading ideas into actionable strategies. This tutorial will guide you through building a basic algorithmic trading strategy, back-testing it, and optimizing it using historical market data.
Getting Started with Quagensia N Edition
Before diving into strategy creation, ensure you have installed the Quagensia N Edition free trial. Once installed, the trial period begins, allowing you to explore all features and create as many algorithms as possible. Even after the trial ends, the generated strategy code remains yours to use on multiple computers.
Installing Quagensia N Edition
- Visit quagensia.com to download the free trial.
- Follow the installation instructions.
- Restart this tutorial video after installation to follow along.
Creating a New Strategy
To create a new strategy in Quagensia:
- Click the “Plus” icon on the left side of the toolbar.
- Select “Create New Quagensia N Edition Strategy”.
- Name your strategy and set a short name for NinjaTrader 8.
- Save the strategy in the “My Algos” folder.
Setting Up Strategy Details
In the Strategy Details section, configure the following properties:
- Calculate: Set to “On Bar Close” to execute trading logic only when price bars close.
- Default Entry Order Quantity: Set to 100 for equities.
- Exit on Session Close: Uncheck this box to hold positions overnight.
- Slippage: Set to 2 to avoid overly optimistic back-test results.
Defining Input Parameters
Next, define input parameters for your strategy:
- Fast MA Period: Set as a whole number with an initial value of 3.
- Slow MA Period: Set as a whole number with an initial value of 6.
Quagensia supports various data types for input parameters, including advanced types like dates, colors, and lists.
Creating Internal Variables
Define internal variables to store values used in your strategy’s logic:
- Fast MA: Create an internal variable of type “Indicator Time Series” for the fast moving average.
- Slow MA: Create another internal variable for the slow moving average.
Use the context-sensitive menu to select indicators and set their properties. For example, choose the weighted moving average (WMA) for the Fast MA and the triangular moving average for the Slow MA.
Building Trading Logic
In the “When Bar Updates” section, create the logic for your strategy:
- Add a “Conditional Logic (If Block)” action.
- Set conditions for entering a long position:
- Ensure the current market position is flat.
- Check if the Fast MA crossed above the Slow MA.
- Verify that the last two bars have higher lows than their previous bars.
- Restrict signals to occur only on Monday or Tuesday.
Adding Actions for Entry
When the conditions are met, specify actions to take:
- Enter a long position using a market order.
- Change the candle outline color of the signal bar.
- Draw a diamond above the high of the signal bar.
- Print the entry close price to the NinjaScript Output window for debugging.
Creating Exit Logic
To manage exits, add an “Otherwise, If (Else If)” block:
- Check if the Fast MA crossed below the Slow MA while in a long position.
- Exit the entire long position using a market order.
- Copy and paste relevant actions from the entry logic to maintain consistency in logging and drawing.
Generating Strategy Code
Once your strategy is complete, generate the code:
- Open NinjaTrader 8 and the NinjaScript Editor.
- Click the button in Quagensia to send the strategy code to NinjaTrader.
- Ensure the code compiles successfully without errors.
Back-Testing the Strategy
To back-test your strategy:
- Connect to a market data feed in NinjaTrader.
- Open the Strategy Analyzer and set the back-test parameters:
- Choose the instrument (e.g., SPY).
- Set the date range for back-testing.
- Configure slippage and order quantity settings.
- Run the back-test and analyze the results.
Analyzing Back-Test Results
Review the back-test results, focusing on key metrics such as profit factor and cumulative net profit. Use the NinjaTrader Strategy Analyzer to visualize trades on a chart and assess performance over time.
Optimizing the Strategy
To optimize your strategy:
- Change the back-test type to “Optimization”.
- Set the parameter ranges for Fast MA and Slow MA periods.
- Run the optimization to evaluate multiple combinations quickly.
Conclusion
Congratulations! You have successfully created, back-tested, and optimized a basic trading strategy using Quagensia N Edition for NinjaTrader 8. This tutorial only scratches the surface of what Quagensia can do. For more advanced features and strategies, explore additional tutorials available on the Quagensia website.
By leveraging the capabilities of Quagensia N Edition, traders can develop complex strategies without coding, making algorithmic trading more accessible than ever.
Quagensia's Point and Click Strategy Builder • Strategy Apex
Zig Zag Strategy Template Available for download