Hi,
I see that the opening range breakout video is in the US Equites section of the boot camp. However can modifications be made to it so that I can use it on XAUUSD?
Thank you
QUANTCONNECT COMMUNITY
Hi,
I see that the opening range breakout video is in the US Equites section of the boot camp. However can modifications be made to it so that I can use it on XAUUSD?
Thank you
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Mia Alissi
Yes, you can modify the opening range breakout strategy to work with XAUUSD. You would need to replace the equity with the Forex symbol in the AddForex method. Here is an example of how you can do it:
This code will create an opening range breakout strategy for XAUUSD. The strategy will go long when the close price is above the high price of the opening range, and go short when the close price is below the low price of the opening range.
Please note that you might need to adjust the time of the opening range depending on the Forex market hours.
Source: QuantConnect Forum Discussion
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Warren chapman
Thank you for your help, however when i run the back test. Still no trades are being made.
How do I adjust that?
Mia Alissi
There could be several reasons why no trades are being made during your backtest. Here are a few things you could check:
Data Availability: Ensure that the data for the symbol "XAUUSD" is available for the date range you have set in your backtest. If you're backtesting locally, you might not have the data available by default. As mentioned in one of the forum discussions, the data is only available for free in the cloud.
Market Hours: Forex trades 24/5, not 24/7. So, you need to make sure the algorithm is set to execute trades within the market hours.
Conditions for Trades: Check the conditions you've set for making trades. If the conditions are too strict or not possible, trades might not be executed. For example, in the code snippet provided, trades are executed when the close price is above the high price or below the low price of the opening range. If these conditions are not met, no trades will be executed.
Resolution: The resolution of your data might also affect your trades. If the resolution is too low (e.g., daily), the algorithm might not have enough data points to execute trades.
If you've checked all these points and still see no trades, it might be helpful to add some logging to your algorithm to understand what's happening at each step. You can use the
self.Debug
function to log information during the backtest.If you're still having issues, please share the relevant parts of your code or error messages, and I'll be happy to help you troubleshoot further.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Warren chapman
My back test is still not running, could you please take a look at my code and try to find my issue as to why the back test will not run.?
Mia Alissi
The issue with your backtest might be related to the date range you've set. You've set the start date as 2023 and the end date as 2024. As of now, QuantConnect might not have data available for this future date range.
Try changing the start and end dates to a range in the past for which data is available. For example:
Another potential issue could be the time you've set for the opening bar. The Forex market operates 24 hours a day from 5 p.m. ET on Sunday to 5 p.m. ET on Friday. You've set the opening bar to be at 9:30, which might not be an appropriate time for the Forex market. You might want to adjust this based on the specific characteristics of the Forex pair you're trading.
Lastly, ensure that the conditions for making trades are being met during your backtest. If the close price never goes above the high or below the low of the opening range, no trades will be executed. You might want to adjust these conditions or add some logging to your algorithm to understand what's happening at each step.
If you're still having issues, please share any error messages you're seeing during the backtest, and I'll be happy to help you troubleshoot further.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Warren chapman
That also did not yield to any results on the back test
Mia Alissi
The issue might be related to the time you've set for the opening bar. The Forex market operates 24 hours a day from 5 p.m. ET on Sunday to 5 p.m. ET on Friday. You've set the opening bar to be at 9:30, which might not be an appropriate time for the Forex market.
In Forex trading, the "opening" time often refers to the start of the new trading day in the trader's time zone, which is typically the open of the Asian trading session (0:00 GMT). You might want to adjust this based on the specific characteristics of the Forex pair you're trading.
Here's how you can adjust the time for the opening bar:
Also, it's important to note that the Forex data in QuantConnect is quoted in Eastern Time (the same as New York Stock Exchange), so you might need to adjust the time accordingly if you're considering a different time zone.
If you're still having issues, please share any error messages you're seeing during the backtest, and I'll be happy to help you troubleshoot further.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Warren chapman
That still did not work.
Mia Alissi
The issue might be related to the way you're setting the
openingBar
. In yourOnDataConsolidated
method, you're setting theopeningBar
only once at the start of the trading day (0:00). However, you're using a 30-minute bar for consolidation, which means a new bar is generated every 30 minutes.If you want to capture the first 30-minute bar of each day as the
openingBar
, you should add a condition to reset theopeningBar
at the end of each day. Here's how you can do it:This way, the
openingBar
is reset at the end of each day (23:30), and the first 30-minute bar of the next day (0:00) is captured as the newopeningBar
.If you're still having issues, please share any error messages you're seeing during the backtest, and I'll be happy to help you troubleshoot further.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Warren chapman
That did not work to produce a back test
Mia Alissi
I'm sorry to hear that you're still having issues with your backtest. Let's try a different approach.
The issue might be related to the way you're handling the consolidated data. In your current setup, you're consolidating the data into 30-minute bars and then checking if the current time is 0:00 or 23:30. However, this might not work as expected because the consolidated bar's time is the beginning of the bar. So, a bar consolidated at 0:00 will contain data from 0:00 to 0:30, and a bar consolidated at 23:30 will contain data from 23:30 of the previous day to 0:00 of the current day.
Instead, you can create a daily consolidated bar and use it to determine the opening range. Here's how you can do it:
In this setup, the
OnDataConsolidated
method is called at the end of each trading day, and theopeningRange
is set to the daily bar. Then, in theOnData
method, you're comparing the current price with the high and low of theopeningRange
.Please note that this is a simplified version of the opening range breakout strategy. In a real-world scenario, you might want to consider other factors such as the size of the opening range, the volume, and the volatility.
If you're still having issues, please share any error messages you're seeing during the backtest, and I'll be happy to help you troubleshoot further.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Warren chapman
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!