Hi everyone,
I'm a newbie here and I'm not an expert coder, so apologies if my question sounds silly.
I'm trying to implement a strategy that I usually use manually that enters a trade with a LONG position when the following conditions are met:
- Both Stochastic %K and %D lines cross from below the oversold threshold (20)
- It waits until the RSI indicator crosses from below the 50 threshold
- It confirms the uptrend with the MACD histogram being positive (Fast line above Signal)
Now… where I'm struggling is that I don't know how to tell the algo to “wait until”. I tried with some loops but I can't seem to find something that works.
Can anyone help me with that. I am attaching te partial code I have at the moment but it doesn't generate a backtest because the loop (clearly wrong) takes more than 10 min to run.
Thanks in advance for the help and apologies for the question that I know will be silly.
Cheers.
Dario
Varad Kabade
Hi Dario de Gennaro,
We recommend going through the following example algorithms [1, 2, 3]. We also recommend going through the following doc on Indicators in QC. For further assistance, would you mind attaching a code snippet/backtest?
Best,
Varad Kabade
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!