Backtesting Futures Strategy
Tyler
Last Update 20 วันที่แล้ว
Introduction
In this tutorial, we’ll walk through how to backtest a futures strategy by downloading it from the Prop Farming Leaderboard and importing it into NinjaTrader. This will help you assess the effectiveness of strategies before applying them to live trading or challenges.
Step 1: Navigate to the Prop Farming Leaderboard
- Go to the Prop Farming Leaderboard.
- Switch from the default Forex page to Futures by selecting the appropriate tab.
- Browse the strategies uploaded to the leaderboard. New strategies are uploaded frequently; in this example, we’ll test a strategy uploaded on August 2nd.
Step 2: Download the Strategy
- Once you’ve chosen a strategy from the leaderboard, click the file folder icon to download it.
- Copy the file by right-clicking on it and selecting Copy.
- Go to your VPS where NinjaTrader and Rhythmic are installed.
- Paste the strategy file into the Downloads folder on your VPS. This folder is accessible through the file explorer in your VPS setup.
Step 3: Import the Strategy into NinjaTrader
- Open NinjaTrader and ensure you are connected to the platform. The connection status is indicated by a green circle in the lower-left corner. If you are not connected, go to Connections in the NinjaTrader menu and select your connection (e.g., TopStep).
- Navigate to Tools in the NinjaTrader menu and select Import > NinjaScript Add-On.
- Scroll down to the downloaded strategy file, highlight it, and click Open.
- A confirmation message will appear once the strategy is successfully imported. Click OK to proceed.
Step 4: Set Up the Strategy Analyzer
- In NinjaTrader, go to the Accounts tab and click on New > Strategy Analyzer.
- In the Strategy Analyzer, select the strategy you imported by hovering over Blue Edge Financial and locating the strategy name (e.g., PrimRat Grow).
- You do not need to input your email address for backtesting purposes.
Step 5: Configure the Backtest Settings
- Target Account Balance: Set the target account balance to all 9s (999999) to ensure the backtest runs for the full year.
- Base Lot Size: The default base lot size may be set to 3, but reducing it to 1 often improves performance. You can experiment with base lot sizes of 2 and 1 to compare results.
- Instrument Selection: Choose the appropriate instrument for the strategy. In this example, the strategy is set for the NQ (Nasdaq futures) instrument.
- Time Frame: Select the time frame you want to test. In this case, we’re backtesting from the start of the year until today.
- Data Series: Set the time interval to 40 seconds since the strategy is designed for this time frame.
Step 6: Run the Backtest
- Once all settings are configured, click Run to start the backtest. The process will only take a few moments.
- After completion, you’ll be able to review the results.
Step 7: Review the Results
- Profit Factor: Look at the profit factor to evaluate the strategy’s effectiveness. A good profit factor is typically above 1.75. In this example, the initial profit factor is 1.28, which is acceptable but not outstanding.
- Percent Profitable: This shows how often the strategy generated a profit. A value of 57% was observed here.
- Profit Curve: Under the Analysis tab, you can view the profit curve to see how the strategy performed over time.
Step 8: Experiment with Base Lot Sizes
- Modify the base lot size and rerun the test to see if performance improves. Reducing the base lot size from 3 to 2 improved the results slightly.
- Testing with a base lot size of 1 often yields better results. In this case, it increased the profit factor to 1.51, and the percent profitable rose to 60.5%.
Additional Tips
- Contract Selection: The results of backtesting can vary based on the contract being tested. For example, testing on the August contract may yield better results than the December contract if fewer traders are using the latter.
- Regularly testing across different contracts and configurations can help optimize performance.
Conclusion
By following this tutorial, you can efficiently download, import, and backtest futures strategies in NinjaTrader using data from the Prop Farming Leaderboard. This method allows you to evaluate strategies before applying them to live trading, ensuring they align with your goals.
Backtesting is a valuable tool in identifying the most effective strategies, so be sure to test various configurations and settings to maximize performance!