How To Set Up & Manage Automated Trading Strategies On A Virtual Server With NT8
We're testing out strategies in real-time and this is the set up.
One thing that differentiates our hunt from the others is that we’re testing many of our strategies using live data. The account is simulated, but the data is live. We’ve set this up on a virtual server and we’re currently in our sixth week of tracking the weekly performance of some of our best strategies and portfolios. You can read more about our real-time tests in the Mudder Report.
The Mudder Report was created to document the process of tracking strategies on a real-time basis, but one thing the Mudder Report is missing is an overview of how to set up and configure a simulated live account on NT8. I want to thank Damien for bringing this to my attention.
I was not involved in all aspects of the set up, but these are the basic steps:
Find a virtual server located as close to the exchange where the asset you’re trading is located. You want to download and run NT8 from within this virtual server. The best virtual server is one that is never down (read: zero downtime). Even more important is that they respond to you within 5 minutes if you do have an issue.
If you trade on your own account, you will need to purchase a second account from your brokerage so you can run both accounts simultaneously without one instance bumping the other out. You will also need to buy another data package. I use NT brokerage. If you contact NT brokerage, they will walk you through the process.
You also need to be mindful of RAM. We recently had to upgrade to 16gb. That said, we’re also running over 130 strategies, so this is something that depends on resource use. Your provider should have a way for you to monitor your resource usage in real-time. Look at peak hours to know your minimum requirements.
You will need to create a backup file of your current settings and import it onto the new server. Then, copy and paste the backup file onto the new server to import. Here's how to copy your existing NinjaTrader workspace, charts, indicators, etc.
NinjaTrader Documentation for exporting a backup: https://ninjatrader.com/support/helpGuides/nt8/creating_a_backup_archive.htm
If the strategies aren’t included in the backup file, you will need to import our (or your own) strategies into NT8 on the virtual server. Ninjatrader download instructions are listed below for downloading our strategies from the Strategy Description:
Click on the link within the strategy description to download the file from G drive.
Download the Strategy to your desktop, keep them in the compressed .zip file.
From the NinjaTrader Control Center window, select the menu Tools > Import > NinjaScript Add-On
Select the downloaded file from your desktop
After you find a virtual server, download NT8, and import strategies, but before you connect to your account to set the strategy up, you will need to create a simulated account to run the strategy on. This can be done when you are connected, but you will need to disconnect and then reconnect before the accounts can be used.
All accounts come with one simulated account preset called SIM, but you can create as many as you want. If you click the “create a simulated account” link above, it will take you to a quick tutorial on creating new simulated accounts.
I like for accounts to have the same name as the strategy it will be run on, i.e. SimAccount2 for Strategy 2 (and all its variations). I also like to create accounts for portfolios, ie. SimPortfolio54b, and start all accounts out at $50K for the sake of comparison. You can also set starting account size to the cumulative max drawdown of the strategy if you’re looking for greater accuracy.
Now you can connect and start running the strategy. If you’ve never run a strategy before, NT8 provides a great overview here. Even if you’ve run a strategy before, this is a great overview of what options you have available to you.
There are two main ways to run a strategy: from a chart and from the Strategies tab. We use both. Personally, I find the chart to be easier when setting up more than 3 strategies, but the Strategy tab is better for adding one or two strategies at a time. It’s good to practice on both to see which one you prefer. Neither has a particular advantage with regard to performance. (11/22/22) Update: setting up strategies on a chart does have an additional advantage. It allows your strategies to auto-update to the current front-month. If you start a strategy from the Strategies tab, it will not update automatically.
The best time to start getting set up is after the market closes on Friday evening. You need to make sure everything is ready to go by Sunday at 6pm (EST).
Monitor your strategies closely. Compare the performance against the backtest on a daily basis at first and track their performance over time like we’re doing. Update (5/22/23): We’ve set up an automated email for a trade performance report. That email goes to an email address dedicated to trade performance reports. We’ve done this to 1) verify that the daily trade performance report is working properly 2) maintain a daily record of trade performance in case the database becomes corrupted.
Once you get set up, you want to develop a strategy to run the strategy. Running a simulated account will help to develop your own management style. These are some things you need to think about:
What happens if you get kicked out of a strategy? This can happen for many reasons, but it usually happens when you have two conflicting strategies on the same contract. This is why we use the same strategy on multiple instruments, but not the same instrument on multiple strategies. If you need help with this, shoot me an email.
What happens if the strategy falls out of sync? There are many reasons that a strategy may be out of sync. This is usually due to a disconnect between the account position and the strategy position. You can learn more about what it is and how to fix it here. If you need help with this, shoot me an email.
What’s your rollover strategy? Rollover is tricky. In my regular trading, I roll with contract volume. That is, the contract with the highest volume is the one I’m trading. Ninjatrader has an automated rollover system, but it’s static. You’ll want to close out of the application once a week for rollovers to update automatically.
We’ve found that many more errors occur during rollover. Until the rollover system is more dynamic, we’re going to turn all strategies off during the last two weeks of major contract expiration dates (four times a year — triple witching) to “manage” the portfolio. In other words, no strategies are running for two weeks running up to triple witching. This might change in the future.
The image below is a calendar from the NASDAQ trade calendar. Triple witching dates are marked with a blue circle. The next date is the 16th of December so we will stop running all strategies on December 2 and restart on the 20th.
What happens if the virtual server shuts down?
Contact the provider immediately. If they don’t respond in 5 minutes, ask for a refund and find another provider. Don’t wait until this happens to test the 5 minute response rule.
What happens if your local computer goes offline? Nothing. This is why you have the strategies set up on a dedicated virtual server. If your local computer goes offline, it will not impact the performance of your strategies, but you should have some way to sign on to NT8 through another device, ie phone, tablet.
When you start the strategy, will you enter the trade immediately or will you wait until the strategy is flat? This is up to you. It is among the many options you have when you first set the strategy up. All of our strategies are set to wait until the strategy is flat, but I haven’t conducted any tests to see if one is better than the other from a performance perspective. Some of you have also said that calculating on each tick is better than calculating on bar close. I don’t know if that’s the case, but it certainly requires more resources to run. Here’s a screenshot of the default view for most of our strategies:
Do you want a strategy that closes at the end of the session or end of week? Some strategies have a better performance when run continuously through the week (read: you don’t automatically close all positions at session close). This also depends on the market and/or exchange. The futures market closes every day for one hour. If you want to hold your position through that close, you will need to add the cost of overnight margin to your starting account balance (i.e., cumulative max drawdown + initial margin). You can learn more about the impact of futures margin on automated trading here.
I’m sure I left something out, but those are the high level basics. I will continue to update this document as we work through the process. The more you live-test, the more you’ll develop your own sense for what works. If I missed something or if you have any other questions, please let me know. I’d prefer it if you would add your question/comment below so we can create a working document, but if you’re uncomfortable with that I’m okay with a direct email as well.