IndicatorHelper
Extension class for indicators.
Methods
public static void ApplyParameters(IIndicator indicator, IEnumerable<KeyValuePair<string, object>> parameters)
IndicatorHelper.ApplyParameters(indicator, parameters)
Applies to , keyed by property name and matched case-insensitively. A part of a composite is reached by naming the path to it - K.Length, Macd.LongMa.Length. A key the indicator does not have, or a value it refuses, leaves its own default in place.
- indicator
- Indicator.
- parameters
- Parameters.
public static IIndicator Clone(IIndicator indicator)
result = IndicatorHelper.Clone(indicator)
Create a copy of the indicator.
- indicator
- Indicator.
Returns: Copy.
public static IIndicatorValue CreateEmptyValue(IIndicator indicator, DateTime time)
result = IndicatorHelper.CreateEmptyValue(indicator, time)
Create empty IIndicatorValue.
- indicator
- IIndicator
- time
- Time
Returns: Empty IIndicatorValue.
public static IIndicator CreateIndicator(IndicatorType type)
result = IndicatorHelper.CreateIndicator(type)
Create indicator.
- type
- IndicatorType
Returns: IIndicator
public static IEnumerable<IndicatorType> ExcludeObsolete(IEnumerable<IndicatorType> types)
result = IndicatorHelper.ExcludeObsolete(types)
Exclude obsolete indicators.
- types
- All indicator types.
Returns: Filtered collection.
public static decimal GetCurrentValue(IIndicator indicator)
result = IndicatorHelper.GetCurrentValue(indicator)
To get the current value of the indicator.
- indicator
- Indicator.
Returns: The current value.
public static T GetCurrentValue<T>(IIndicator indicator)
result = IndicatorHelper.GetCurrentValue(indicator)
To get the current value of the indicator.
- indicator
- Indicator.
Returns: The current value.
public static decimal GetFirstValue(IIndicator indicator)
result = IndicatorHelper.GetFirstValue(indicator)
To get the first value of the indicator.
- indicator
- Indicator.
Returns: The current value.
public static decimal? GetNullableCurrentValue(IIndicator indicator)
result = IndicatorHelper.GetNullableCurrentValue(indicator)
To get the current value of the indicator.
- indicator
- Indicator.
Returns: The current value.
public static decimal? GetNullableFirstValue(IIndicator indicator)
result = IndicatorHelper.GetNullableFirstValue(indicator)
To get the first value of the indicator.
- indicator
- Indicator.
Returns: The current value.
public static decimal? GetNullableValue(IIndicator indicator, int index)
result = IndicatorHelper.GetNullableValue(indicator, index)
To get the indicator value by the index (0 - last value).
- indicator
- Indicator.
- index
- The value index.
Returns: Indicator value.
public static IReadOnlyList<ValueTuple<string, IIndicator>> GetOutputs(IIndicator indicator)
result = IndicatorHelper.GetOutputs(indicator)
The series produces: one entry for a plain indicator, one per innermost part for a composite.
- indicator
- Indicator.
Returns: Series name paired with the part whose value it carries, in a stable order.
public static ValueTuple<decimal?[], int?> GetOutputValues(IIndicatorValue value, IReadOnlyList<IIndicator> parts)
result = IndicatorHelper.GetOutputValues(value, parts)
Reads one number per series out of .
- value
- What IIndicatorValue) returned. May be .
- parts
- The parts from IIndicator), in the same order.
Returns: One entry per part, where that series has not formed yet, and the bars-back offset when a sparse indicator reports its value later than the candle it belongs to.
public static IEnumerable<PropertyInfo> GetParameters(Type indicatorType)
result = IndicatorHelper.GetParameters(indicatorType)
The properties of a caller may set: what the indicator declares itself, as opposed to the identity and drawing hints it inherits.
- indicatorType
- Indicator type.
Returns: Settable parameter properties.
public static decimal GetValue(IIndicator indicator, int index)
result = IndicatorHelper.GetValue(indicator, index)
To get the indicator value by the index (0 - last value).
- indicator
- Indicator.
- index
- The value index.
Returns: Indicator value.
public static Type GetValueType(Type indicatorType, bool isInput)
result = IndicatorHelper.GetValueType(indicatorType, isInput)
Get value type for specified indicator.
- indicatorType
- Indicator type.
- isInput
- Is input.
Returns: Value type.
public static T GetValue<T>(IIndicator indicator, int index)
result = IndicatorHelper.GetValue(indicator, index)
To get the indicator value by the index (0 - last value).
- indicator
- Indicator.
- index
- The value index.
Returns: Indicator value.
public static bool IsNonDecimalOutputValue(Type indicator)
result = IndicatorHelper.IsNonDecimalOutputValue(indicator)
Determines whether the indicator is a non-decimal output value.
- indicator
- Indicator type.
Returns: Check result.
private static Dictionary<IIndicator, string> NameInnerParts(IComplexIndicator complex)
result = IndicatorHelper.NameInnerParts(complex)
Names the inner parts after the properties exposing them - UpBand, SignalMa, Dx. Their own Name is localized display text, which would make the series keys change with the language the process is running in.
public static void Preload(IIndicator indicator, IEnumerable<ValueTuple<DateTime, object[]>> items)
IndicatorHelper.Preload(indicator, items)
Bulk preload using primitive tuples. Implementations may override; default throws NotSupportedException.
- indicator
- IIndicator
- items
- Sequence of (time, values) where values correspond to ToValues output.
public static IIndicatorValue Process(IIndicator indicator, object inputValue, DateTime time, bool isFinal)
result = IndicatorHelper.Process(indicator, inputValue, time, isFinal)
To renew the indicator with new value.
- indicator
- Indicator.
- inputValue
- Input value.
- time
- Time
- isFinal
- IsFinal
Returns: IIndicatorValue.
public static IIndicatorValue Process(IIndicator indicator, decimal value, DateTime time, bool isFinal)
result = IndicatorHelper.Process(indicator, value, time, isFinal)
To renew the indicator with numeric value.
- indicator
- Indicator.
- value
- Numeric value.
- time
- Time
- isFinal
- Is the value final (the indicator finally forms its value and will not be changed in this point of time anymore). Default is .
Returns: The new value of the indicator.
public static IIndicatorValue Process(IIndicator indicator, ICandleMessage candle)
result = IndicatorHelper.Process(indicator, candle)
To renew the indicator with candle closing price ClosePrice.
- indicator
- Indicator.
- candle
- Candle.
Returns: The new value of the indicator.
public static IIndicatorValue Process(IIndicator indicator, IIndicatorValue input, decimal value)
result = IndicatorHelper.Process(indicator, input, value)
To renew the indicator with numeric value.
- indicator
- Indicator.
- input
- IIndicatorValue
- value
- Numeric value.
Returns: The new value of the indicator.
public static IIndicatorValue Process<TValue>(IIndicator indicator, ValueTuple<TValue, TValue> value, DateTime time, bool isFinal)
result = IndicatorHelper.Process(indicator, value, time, isFinal)
To renew the indicator with numeric pair.
- indicator
- Indicator.
- value
- The pair of values.
- time
- Time
- isFinal
- If the pair final (the indicator finally forms its value and will not be changed in this point of time anymore). Default is .
Returns: The new value of the indicator.
public static IIndicatorValue SetValue(IIndicatorValue input, IIndicator indicator, decimal value)
result = IndicatorHelper.SetValue(input, indicator, value)
To replace the indicator input value by new one (for example it is received from another indicator).
- input
- IIndicatorValue
- indicator
- Indicator.
- value
- Value.
Returns: New object, containing input value.
public static ICandleMessage ToCandle(IIndicatorValue value)
result = IndicatorHelper.ToCandle(value)
Convert IIndicatorValue to ICandleMessage.
- value
- IIndicatorValue
Returns: ICandleMessage
public static decimal ToDecimal(IIndicatorValue value, Level1Fields? source)
result = IndicatorHelper.ToDecimal(value, source)
Convert IIndicatorValue to Decimal.
- value
- IIndicatorValue
- source
- Field specified value source.
Returns: Decimal
public static decimal? ToNullableDecimal(IIndicatorValue value, Level1Fields? source)
result = IndicatorHelper.ToNullableDecimal(value, source)
Convert IIndicatorValue to Decimal or if the value is empty..
- value
- IIndicatorValue
- source
- Field specified value source.
Returns: Decimal or if the value is empty.
public static IIndicator TryCreateIndicator(IndicatorType type)
result = IndicatorHelper.TryCreateIndicator(type)
Create indicator.
- type
- IndicatorType
Returns: IIndicator
public static IndicatorType TryGetById(IIndicatorProvider provider, string id)
result = IndicatorHelper.TryGetById(provider, id)
Try find IndicatorType by identifier.
- provider
- IIndicatorProvider
- id
- Identifier.
Returns: IndicatorType or .
public static IndicatorType TryGetByType(IIndicatorProvider provider, Type type)
result = IndicatorHelper.TryGetByType(provider, type)
Try find IndicatorType by type.
- provider
- IIndicatorProvider
- type
- Indicator
Returns: IndicatorType or .