Hi there,
I'm new, try to understand the concept and enjoy the platform (coding is not my area of expertise).
Now I'm stuck for quite a while now and I was wondering if the community can give me a hint or refer to a discussion with this topic. It seems I don't understand the logic with OnOrderEvent/loop.,
When I get a buy signal I take an initial position. In case I didn't receive a liquidate signal yet but additional buy signals, I want to averaging down the position IF the current price is lower than the AverageFillPrice of the last order. (Later I want to treat these further signals/position differently: bigger size the lower the current price is vs the AverageFillPrice of the initial position, but that's for later). I would think this is a common use case maybe solved with loops but I don't get my head around in combination with OnOrderEvent. First I tried different ways only within OnData.
I already watch the respective boot camp videos of Jared and Louis and found this thread but could't apply it to my needs:
I attached the current resigned status, a simplified version with RSI signal. In reality I'm going to use different indicators. so it's all about averaging down position for now.
Any hint how to tackle this is greatly appreciated.
Thank you
Heiko
Varad Kabade
Hi Searcher,
We can save the AverageFill price from the OnOrder event handler and add an additional condition inside the OnData method to check if we are invested and the close price is less than the AverageFillPrice and the signal is long:
. Refer to the attached backtest for reference,
Best,
Varad Kabade
Searcher
Hi Varad Kabade,
thank you very much for your input. This helped me a lot. Not only for this specific problem but also to understand the concept of OnOrderEvent better.
Thank you and greetings
Heiko
Searcher
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!