Hi everyone,
I'm dipping my toes into forex trading and wanted to try out some strategies. I made this strategy work somewhat on QC but it suddenly stops entering positions? The trading period is short (1y) just to see if the strategy actually runs. The starting cash is also a random amount. But I can't seem to find a reason as to why it would stop making trades in the middle of the trading period. I tried longer periods as well and the same thing happens. Any clue?
Thanks,
Kris
Mia Alissi
Based on the code you provided, there could be a few reasons why your algorithm stops entering positions:
Cooldown Period: You have a cooldown period set in your algorithm. If a trade is made, the algorithm will not make another trade until the cooldown period has passed. If the cooldown period is too long, this could be why your algorithm stops trading.
EMA and RSI Conditions: Your algorithm only enters a position if certain conditions related to the EMA and RSI are met. If these conditions are not met, the algorithm will not enter a position. It's possible that these conditions are not being met after a certain point in time, causing your algorithm to stop trading.
Lack of Funds: Your algorithm starts with a set amount of cash. If this cash is used up, the algorithm will not be able to enter any more positions. You can check if this is the case by logging the cash balance at each step of the algorithm.
Data Availability: Your algorithm uses data from multiple forex pairs. If data for one or more of these pairs becomes unavailable, this could cause your algorithm to stop trading.
To debug this issue, you could add logging statements in your code to track the cash balance, the values of the EMA and RSI, and whether the conditions for entering a position are being met. This will help you understand why the algorithm is not entering positions.
Here is an example of how you can add a logging statement to track the cash balance:
And here is an example of how you can log the values of the EMA and RSI:
You can also log whether the conditions for entering a position are being met:
By adding these logging statements and examining the logs, you should be able to figure out why your algorithm is not entering positions.
Sources:
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.
Kristofferson V Tandoc
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!