Parent: TimeSeries
IndicatorBase is the base class for technical indicators in WealthLab. It derives from TimeSeries and implements the INamed interface. In addition to the DateTimes and Values inherited from TimeSeries, IndicatorBase provides the metadata, parameters, plotting information, companion indicators, and calculation methods used by the WealthLab indicator subsystem. Developers creating custom indicators derive their classes from IndicatorBase and implement the required descriptive properties, parameters, and calculation logic.
Causes the indicator to assume the values of the TimeSeries specified in ts. The indicator's Values are cleared and replaced with the source values. Its DateTimes are also synchronized with the source when necessary.
Override this method in custom indicators that support partial updates in streaming charts. Calculate the indicator's value using the source TimeSeries StreamingValue, assign the result to the indicator's StreamingValue, and return true if a partial value could be calculated. The default implementation returns false.
public override bool CalculatePartialValue() { StreamingValue = Double.NaN; TimeSeries source = Parameters[0].AsTimeSeries; if (Double.IsNaN(source.StreamingValue)) return false; int period = Parameters[1].AsInt; if (period >= source.Count) return false; double sum = 0; for (int n = 0; n < period - 1; n++) { int idx = source.Count - 1 - n; sum += source[idx]; } sum += source.StreamingValue; StreamingValue = sum / period; return true; }
Contains the Parameter instances that define the indicator's inputs and settings. Typical parameters include a source TimeSeries, period, smoothing method, or other values required to calculate the indicator.
Override this method to calculate and populate the indicator's values. WealthLab calls Populate after the indicator's parameter values have been assigned.
Generates and assigns the indicator's Description based on its Abbreviation and current parameter values. If useOptimizable is true, optimizable parameter descriptions are used.
Returns the companion indicator used when rendering an indicator with a bands plot style. For example, an upper band indicator can return the corresponding lower band indicator.
Returns the abbreviation of the indicator's band companion. The default implementation attempts to match indicator abbreviations ending in "Upper" with the corresponding "Lower" indicator, and vice versa. If no such match exists, the first entry in Companions is used when available.
Determines whether companion indicators should adopt matching Parameter values from the parent indicator. The default value is true.
Returns the abbreviations of indicators that belong to the same indicator family. For example, the Directional Movement family contains ADX, ADXR, DIPlus, and DIMinus.
Creates and returns the indicator's companion instances. Override this method when companion indicators require special construction or use parameter values that differ from those of the parent indicator. When using this approach, you will typically also override CompanionAdoptsParentParameters to return false.
Override this method for indicators that represent Open, High, Low, and Close components and are intended to be rendered using a bar-chart style. The pc parameter indicates which PriceComponent is being requested. An implementation can return the current indicator for PriceComponent.Close and corresponding companion indicators for Open, High, and Low.
Returns a color to use when plotting this indicator as a companion of the indicator specified in parent. The default value is WLColor.Empty.
Returns true if the indicator defines companion indicators through either the Companions property or an overridden CreateCompanionInstances method.
Returns the abbreviation used to identify the indicator, for example "RSI", "SMA", or "ADX".
Returns a description of the indicator based on its abbreviation and parameter values. IndicatorBase generates the description dynamically when necessary.
Returns descriptive text explaining the indicator.
Optionally returns a URL containing additional information about the indicator. The default value is a blank string.
Returns the name of the .NET assembly that contains the indicator. This can be null for custom indicators loaded from the My Indicators folder.
Returns the full name of the indicator.
Returns a token derived from the first word of the indicator's Name, used internally for Strategy AI matching. For names beginning with certain common words, the indicator's Abbreviation is used instead.
Returns a description of the indicator using the optimizable descriptions of its Parameters.
Optional tooltip text that can provide additional information when the indicator is plotted.
Determines whether the indicator's pane assignment can be changed dynamically in an indicator editor. The default value is true.
Returns the BarHistory associated with the indicator. If no BarHistory has been explicitly assigned, IndicatorBase attempts to obtain it from the first Parameter when that Parameter is of type BarHistory.
Returns true if the indicator can use another indicator as its source. The default implementation returns true when the first Parameter is a TimeSeries parameter.
Returns true if the indicator contains one or more Parameters whose ParameterType represents another indicator.
Returns true if calculation of the indicator is considered lengthy. Tools such as the Indicator Profiler can use this information when working with indicators. The default value is false.
Returns true if both OverboughtLevel and OversoldLevel contain valid values.
Returns true if the indicator should be hidden from normal indicator selection interfaces. The default value is false.
Returns true if the indicator is considered a smoother. Smoothers typically accept a TimeSeries as their first Parameter and smooth that source in some manner. Examples include SMA and EMA. The default value is false.
Returns the midpoint between OverboughtLevel and OversoldLevel.
The overbought level for an oscillator. The default value is Double.NaN.
The oversold level for an oscillator. The default value is Double.NaN.
Contains the parent indicator when this indicator uses another indicator as its source.
Returns true if the indicator is known to use future information in its calculation. The default value is false.
Returns the corresponding reversed value within the range defined by OversoldLevel and OverboughtLevel.
Loads locally cached indicator data from the specified folder and dataKey. Returns true when the data needs to be obtained or updated. Returns false when suitable cached data is available. When cached data is available, the indicator assumes its values using AssumeValuesOf. This method is useful for indicators that rely on externally obtained data that can be persisted locally, such as economic or interest-rate data.
Saves the indicator's current TimeSeries data to the local indicator data cache using the specified folder and dataKey.
Adds a StringChoice Parameter whose choices correspond to the values of the enumerated type represented by enumVal. The default value is the current value of enumVal.
Creates a Parameter with the specified name, type, and default value, adds it to the indicator's Parameters, and returns the newly created Parameter.
Adds a StringChoice Parameter populated with the abbreviations of available indicators that identify themselves as smoothers. Indicators marked as lengthy calculations are excluded.
Override this method to create the Parameters required by your custom indicator. It is called by the IndicatorBase constructor. Use methods such as AddParameter, AddIndicatorParameter, AddDataSetParameter, AddSmootherParameter, and AddEnumParameter to populate the ParameterList.
Creates and calculates a smoother indicator with the specified name, source, and period. Returns the resulting IndicatorBase instance, or null if the smoother cannot be created or calculated.
Creates a string key from the supplied arguments that can be used to identify an indicator calculation in a cache.
Allows an indicator to modify generated Building Block C# code. The default implementation returns s unchanged.
Returns a string representing the indicator's current Parameter values in a form suitable for constructing the indicator in generated C# code. If parametersOnly is false, the indicator class name and parentheses are included.
Corrects TimeSeries Parameter default values so that TimeSeries originating from the specified BarHistory are represented by their corresponding PriceComponent values.
Updates the description of the indicator's TimeSeries source Parameter to reflect the description of the IndicatorBase specified in ib.
Returns generated C# code representing the default construction of the indicator.
Contains the name of the most recently selected DataSet. IndicatorBase uses this value when generating DataSet Parameters.
Returns a descriptive string containing the indicator type and the types and names of its Parameters.
Returns a string representation of the indicator's current configuration, including its abbreviation, plotting properties, pane information, and Parameter values.
Called after Parameters are loaded or assigned, allowing an indicator to perform additional processing on the ParameterList. The default implementation performs no processing.
Reconciles Parameters that use another indicator as their TimeSeries source. When a ParentIndicator exists, the source Parameter is converted to an IndicatorSource Parameter and assigned the parent indicator's description.
The color to use when plotting the indicator.
Returns the indicator's default plotting color. The default implementation returns WLColor.Black.
Returns the name of the plot object that should be used to render the indicator. By default, this is based on DefaultPlotStyle.
Returns the default PlotStyle for the indicator. The default implementation returns PlotStyle.Line.
Returns the number of extended bars the indicator requires to the right of the chart data. Extended bars allow an indicator to project values into the future. The default value is zero.
Returns the pane tag that should ultimately be used to render the indicator. This method considers UserAssignedPaneTag, PaneTagOverride, the indicator's PaneTag, and whether the source TimeSeries represents Volume.
Optionally returns the name of an embedded image resource that should be used to represent the indicator in the user interface. The default value is null.
Optionally specifies a line style override to use when plotting the indicator.
Optionally specifies a line width override to use when plotting the indicator.
Returns the name of the chart pane in which the indicator should normally be plotted, for example "Price", "Volume", or "RSI".
Allows the indicator's normal PaneTag to be overridden in certain plotting situations.
Contains the plot object currently being used to render the indicator on a chart.
The name of the plot object used to render the indicator.
The PlotStyle used to render the indicator. Assigning this property also updates PlotName.
Allows a user-selected chart pane to override the indicator's normal pane assignment.
Determines whether the chart pane containing the indicator should always include zero on its y-axis. The default value is false.