Strategy 44X
In this post we convert a trading strategy built in the NinjaTrader 8 Strategy Builder over to a custom NinjaScript strategy. This strategy was originally posted in Automated Trading Strategies.
In this post we convert a trading strategy built in the NinjaTrader 8 Strategy Builder over to a custom NinjaScript strategy.
This is the first article in the HGT strategy research series. In this post, we will take a strategy created by Celan Bryant on the Automated Trading Strategy Substack and convert it from Strategy Builder code over to a custom NinjaScript strategy using the template described in the Template post.
The following link will take you to the original post where you can find this strategy. I am currently working with the ATS Research Group and was permitted by ATS to use this strategy (and others) here. This is an incredible opportunity for us to dissect strategies that have already been created, tested, and put into forward tests.
First, we will briefly cover the logic behind the strategy. Then, we will examine the code generated by the strategy builder and apply its logic to the strategy template. We will separate and label each piece of logic to assist with debugging the strategy. Finally, we will add some features for managing the trades based on findings in the backtest.
Initially, I chose a different strategy to kick things off with. However, I became obsessed with this particular strategy while coding it because I started seeing some interesting patterns in the trade logic and how it fired orders. Down the rabbit hole, I went. This is good and bad. The good part is that there is a lot of cool stuff to learn here. The bad part is that there are many things to go over. So, please bear with me as this will be a long post, and I don’t want to separate it into parts.
The completed code can be accessed on GitHub, so I won’t be posting it here in its entirety. Instead, we will discuss each component in sections. I will break down the process in steps and keep this post as clean and easy to navigate as possible.
If you haven’t setup your environment for being able to code and debug NinjaScript files you can view the Trade Testing Environment article. Be sure to continuously check out the House Keeping post for updates as well. It is designed to help make navigation around the Substack easier and to keep you informed about what is going on with HGT and the logic behind it. Paid subscribers will have access to this code (and more) on the HGT private GitHub repository. Code will always be updated first on the GitHub before articles get updated and not all the code in the GitHub has an associated tutorial.
Disclaimer: the following post is an organized representation of my research and project notes. It doesn’t represent any type of advice, financial or otherwise. Its purpose is to be informative and educational. Backtest results are based on historical data, not real-time data. There is no guarantee that these hypothetical results will continue in the future. Day trading is extremely risky, and I do not suggest running any of these strategies live.