Back

Is there a way to use MOMP on an indicator? Or is there some sort of rolling window operation that I need to do? Please Help

So I want to make trades based on the slope of the volume of shares being traded. It looks great in TradingView but I am now attempting to bring it on to QuantConnect. The tickers are of course fillers but I will happily share them once someone helps me lol

class VentralParticlePrism(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2012, 7, 17) # Set Start Date
self.SetEndDate(2020, 7, 17)
self.SetCash(250000000) # Set Strategy Cash
self.AddEquity("SPY", Resolution.Minute)
self.AddEquity("XYZ", Resolution.Minute)
self.AddEquity("ABC", Resolution.Minute)
self.vma = self.SMA("ABC", 365, Resolution.Daily, Field.Volume)
#Here is my problem.
self.vmaSlope = self.MOMP(self.vma, 14, Resolution.Daily)
#How do I calculate this? I want to find the momentum of this indicator over the given period.
self.Schedule.On(
self.DateRules.EveryDay("SPY"),
self.TimeRules.AfterMarketOpen(5),
self.Derp)

def Derp(self):
if self.vmaSlope <= -0.1:
self.SetHoldings("XYZ", 0.9)
self.SetHoldings("SPY", 0)
self.SetHoldings("ABC", 0.1)
if self.vmaSlope.Current.Value <= -0.01:
self.Liquidate("XYZ")

 

Update Backtest







0

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.


Update Backtest





0

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.


Loading...

This discussion is closed