Contents
Indicator Reference
Fractal Adaptive Moving Average
Create Manual Indicators
You can manually create a FractalAdaptiveMovingAverage
indicator, so it doesn’t automatically update. Manual indicators let you update their values with any data you choose. The following reference table describes the FractalAdaptiveMovingAverage
constructor.
FractalAdaptiveMovingAverage()1/3
FractalAdaptiveMovingAverage QuantConnect.Indicators.FractalAdaptiveMovingAverage (string
name,int
longPeriod )
Initializes a new instance of the average class.
FractalAdaptiveMovingAverage()2/3
FractalAdaptiveMovingAverage QuantConnect.Indicators.FractalAdaptiveMovingAverage (
int
longPeriod
)
Initializes a new instance of the average class.
FractalAdaptiveMovingAverage()3/3
FractalAdaptiveMovingAverage QuantConnect.Indicators.FractalAdaptiveMovingAverage (
int
n
)
Initializes a new instance of the average class.
Update Manual Indicators
You can update the indicator automatically or manually.
Automatic Update
To register a manual indicator for automatic updates with the security data, call the RegisterIndicator
method.
private FractalAdaptiveMovingAverage _frama; // In Initialize() _frama = new FractalAdaptiveMovingAverage(name, n, longPeriod); _frama.Updated += IndicatorUpdateMethod; RegisterIndicator(symbol, _frama, Resolution.Daily); // In IndicatorUpdateMethod() if (_frama.IsReady) { var indicatorValue = _frama.Current.Value; }
# In Initialize() self.frama = FractalAdaptiveMovingAverage(name, n, longPeriod) self.frama.Updated += self.IndicatorUpdateMethod self.RegisterIndicator(symbol, self.frama, Resolution.Daily) # In IndicatorUpdateMethod() if self.frama.IsReady: indicator_value = self.frama.Current.Value
To customize the data that automatically updates the indicator, see Custom Indicator Periods and Custom Indicator Values.
Manual Update
Updating your indicator manually enables you to control when the indicator is updated and what data you use to update it. To manually update the indicator, call the Update
method with a TradeBar
, QuoteBar
, or an IndicatorDataPoint
. The indicator will only be ready after you prime it with enough data.
private FractalAdaptiveMovingAverage _frama; private Symbol symbol; // In Initialize() _frama = new FractalAdaptiveMovingAverage(n, longPeriod); symbol = AddEquity("SPY").Symbol; // In OnData() if (data.QuoteBars.ContainsKey(_symbol)) { _frama.Update(data.QuoteBars[symbol]); } if (_frama.IsReady) { var indicatorValue = _frama.Current.Value; }
# In Initialize() self.frama = FractalAdaptiveMovingAverage(n, longPeriod) self.symbol = self.AddEquity("SPY").Symbol # In OnData() if data.QuoteBars.ContainsKey(self.symbol): self.frama.Update(data.QuoteBars[self.symbol]) if self.frama.IsReady: indicator_value = self.frama.Current.Value
Create Automatic Indicators
The FRAMA method creates an FractalAdaptiveMovingAverage indicator, sets up a consolidator to update the indicator, and then returns the indicator so you can use it in your algorithm.
The following reference table describes the FRAMA
method:
FRAMA()1/1
FractalAdaptiveMovingAverage QuantConnect.Algorithm.QCAlgorithm.FRAMA (Symbol
symbol,Int32
period,*Int32
longPeriod,*Nullable<Resolution>
resolution,*Func<IBaseData, IBaseDataBar>
selector )
Creates an FractalAdaptiveMovingAverage (FRAMA) indicator for the symbol. The indicator will be automatically updated on the given resolution.
If you don't provide a resolution, it defauls to the security resolution. If you provide a resolution, it must be greater than or equal to the resolution of the security. For instance, if you subscribe to hourly data for a security, you should update its indicator with data that spans 1 hour or longer.
For more information about the selector argument, see Alternative Price Fields.
Get Indicator Values
To get the value of the indicator, use its Current.Value
attribute.
private FractalAdaptiveMovingAverage _frama; // In Initialize() var symbol = AddEquity("SPY").Symbol; _frama = FRAMA(symbol, period); // In OnData() if (_frama.IsReady) { var current = _frama.Current.Value; }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.frama = self.FRAMA(symbol, period) # In OnData() if self.frama.IsReady: current = self.frama.Current.Value
Visualization
To plot indicator values, in the OnData
event handler, call the Plot
method.
private FractalAdaptiveMovingAverage _frama; // In Initialize() var symbol = AddEquity("SPY").Symbol; _frama = FRAMA(symbol, period); // In OnData() if (_frama.IsReady) { Plot("My Indicators", "fractaladaptivemovingaverage", _frama.Current); }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.frama = self.FRAMA(symbol, period) # In OnData() if self.frama.IsReady: self.Plot("My Indicators", "fractaladaptivemovingaverage", self.frama.Current)
For more information about plotting indicators, see Plotting Indicators.