Trying to understand why I cant get the buy and sell conditions to fire on a "upNow" and "downNow" condition. Can anyone help me out or point me in the direction of some learning material that would help my situation?
QUANTCONNECT COMMUNITY
Trying to understand why I cant get the buy and sell conditions to fire on a "upNow" and "downNow" condition. Can anyone help me out or point me in the direction of some learning material that would help my situation?
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.
Derek Melchin
Hi Axist,
To check if the SuperTrend indicator value is "upNow" or "downNow", we need to call the `buySignals` and `sellSignals` methods. We recommend reviewing our Introduction to Financial Python tutorial and completing the Bootcamp lessons to get more familiar with our API.
In addtion, there is an error with the registerATR method. Refer to this related thread to resolve it.
Best,
Derek Melchin
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.
Axist
Thanks Derek. I'll go through those again, but I was calling the two Signals you mentioned I thought in the code. Regarding the registerATR error, that link you provided me 404s. Â
I appreciate the response!
Axist
Realized my mistake with not calling the buy/sell signals with something like:
Â
self.Schedule.On(self.DateRules.EveryDay("SPY"),
         self.TimeRules.Every(timedelta(hours=1)),
         self.buySignals)
        Â
    self.Schedule.On(self.DateRules.EveryDay("SPY"),
         self.TimeRules.Every(timedelta(hours=1)),
         self.sellSignals)
Now just the registerATR error...
Derek Melchin
Hi Axist,
The link above should now be working.
Best,
Derek Melchin
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.
Axist
I've read through that post several times and am bit confused how its applicable to my ATR error? Additionally I dont seem to be seeing this ATR error, infact my issue seems to be I dont know what the proper "SuperTrend.Value.Up" and "SuperTrend.Value.Down" are supposed to be, when I am trying to set a Buy and Sell Signal definition. I've tried throwing debugs around to see what this should be, but this is the error it keeps giving me during the runtime error:
Runtime Error: In Scheduled Event 'SPY: EveryDay: Every 60 min', AttributeError : 'SuperTrendTester' object has no attribute 'atrUp' at buySignals if self.superTrend.Value is self.atrUp: return === at Python.Runtime.PyObject.Invoke (Python.Runtime.PyObject[] args) [0x00061] at <64cb66ee133d4796a89bc88ae6b16a1f>:0 at QuantConnect.Scheduling.ScheduleManager+<>c__DisplayClass15_0.<On>b__0 (System.String name in main.py:line 98 AttributeError : 'SuperTrendTester' object has no attribute 'atrUp'
Â
Derek Melchin
Hi Axist,
By using the following code to create the AverageTrueRange indicator, the algorithm updates the indicator twice. It updates the indicator at every timestep and with every consolidated bar.
self.atr = self.algorithm.ATR(self.symbol, self.period) timeDeltaConsolidator = BaseDataConsolidator(self.resolution) self.algorithm.SubscriptionManager.AddConsolidator(self.symbol, timeDeltaConsolidator) self.algorithm.RegisterIndicator(self.symbol, self.atr, timeDeltaConsolidator)
To resolve the problem, we should instead use
self.atr = AverageTrueRange(self.period) timeDeltaConsolidator = BaseDataConsolidator(self.resolution) self.algorithm.SubscriptionManager.AddConsolidator(self.symbol, timeDeltaConsolidator) self.algorithm.RegisterIndicator(self.symbol, self.atr, timeDeltaConsolidator)
To fix the `artUp` error message, we need to replace
if self.superTrend.Value is self.atrDown:
with
if not self.superTrend.atrDown.IsReady or self.superTrend.Value == self.superTrend.atrDown[0]:
See the attached backtest for reference.
Best,
Derek Melchin
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.
Axist
Thank you very much for this! I did some back tracing and I get now the atrDown[0] is the result of the CalculateSuperTrend function defined in the SuperTrend class. That makes sense now. Â
Axist
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!