Maybe I'm just totally lost, but how would one going about using the Max attribute? Im trying to create a variable for an entry signal based on a 55 day high, just to get a working algorithm going.
self.LE_Signal = self.Max(self.Symbol, 55, Resolution.Daily)
I keep getting an error saying "
AttributeError : 'Algorithm' object has no attribute 'Max'
Jared Broad
Hard to say for sure without pretext of algorithm but guessing it's the capitalization, MAX()
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.
Sean Tiffen
import numpy as np import pandas as pd from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from datetime import datetime, timedelta from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Data.Market import TradeBar import json import math from QuantConnect.Data import SubscriptionDataSource from QuantConnect.Python import PythonData from QuantConnect.Indicators import * from QuantConnect.Securities import * class Algorithm(QCAlgorithm): def Initialize(self): #Establish universe-wide settings self.UniverseSettings.Resolution = Resolution.Daily self.UniverseSettings.Leverage = 2 #Initial investment and backtest period self.SetStartDate(2019,1,1) #Set Start Date self.SetEndDate(datetime.now().date() - timedelta(1)) #Set End Date self.SetCash(1000000) #Set Strategy Cash futureGold = self.AddFuture(Futures.Metals.Gold, Resolution.Minute); # Only consider the front month contract # Update the universe once per day to improve performance future.SetFilter(lambda x: x.FrontMonth().OnlyApplyFilterAtMarketOpen()) # Symbol of the current contract self.symbol = None # set our expiry filter for this futures chain # SetFilter method accepts timedelta objects or integer for days. # The following statements yield the same filtering criteria #self.futureGold.SetFilter(timedelta(0), timedelta(182)) #self.futureGold.SetFilter(0, 182) benchmark = self.AddEquity("SPY"); self.SetBenchmark(benchmark.Symbol); self.entryPeriod = 125 self.exitPeriod = 7 # Long Entry self.LE_Signal = self.MAX(future, self.entryPeriod, Resolution.Daily)
Â
Shile Wen
Hi Sean,
To use indicators with futures, I suggest following this example, changing EMA to MAX. Furthermore, we are working on adding support to continuous contracts.
Best,
Shile Wen
Sean Tiffen
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!