Hello,
This algorithm doesn't seem to be functioning the I'd like it to. I think the stock has split so many times, that the share price in years past is really tiny. I believe that's what's causing the stop loss to constantly be hit and execute. Is there a way to determine if the problem here is how the average true range is being calculated or if the problem here is that there aren't enough decimal places? Or maybe we need to undo the reverse splits to have it function correctly? Thanks!
Mia Alissi
Here are the key bugs and issues found in your code regarding instrument splits and ATR stop-loss logic:
1. Data Availability and Garbage Historical Prices
2. Data Normalization Mode
ADJUSTEDdata with splits/dividends applied, which makes historical prices appear tiny after many splits, further magnifying your ATR and stop issues.RAW: This ensures actual traded prices are used (no split/back-adjustment).3. ATR and Stop Calculation Magnitude
ATR * 0.05yields extremely small numbers, causing near-instant stop-outs.4. Symbol Availability & Consolidator
5. ATR/Price Logging for Debugging
6. Watch for Price/ATR Data Dropouts
price < 1oratr < 0.01), skip trading and log a warning. This signals data corruption, missing history, or a big recent split.Summary of Required Fixes
data_normalization_mode=DataNormalizationMode.RAWwhen adding TQQQ.After these changes, your ATR/price logic will be far more robust and stop-loss logic should perform as expected.
Sources: Trailing Stop Orders - QuantConnect.com, Sparse Optimization - QuantConnect.com, Data Preparation - QuantConnect.com
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.
Retrospective Green Ocelot
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!