Class IndicatorExtensions
- Namespace
- FinanceSharp.Indicators
- Assembly
- FinanceSharp.dll
Provides extension methods for Indicator
public static class IndicatorExtensions
- Inheritance
-
IndicatorExtensions
- Inherited Members
Methods
ArrayWindow(IUpdatable, int, bool, string)
An indicator that creates a ArrayRollingWindow with period for every item it receives via Update(long, DoubleArray).
public static ArrayRollingWindow ArrayWindow(this IUpdatable input, int period, bool waitForFirstToReady = true, string name = null)
Parameters
inputIUpdatableThe indicator that sends data via Updated even to the ArrayRollingWindow
periodintThe period to delay input, must be greater than zero
waitForFirstToReadyboolTrue to only send updates to the second if input.IsReady returns true, false to alway send updates to second
namestringName of the returned Delay.
Returns
- ArrayRollingWindow
The reference to the second indicator to allow for method chaining
BreakOnUpdate<T>(T, int)
public static T BreakOnUpdate<T>(this T updatable, int interval = 1) where T : IUpdatable
Parameters
updatableTintervalintOn every n updates to break. by default 1.
Returns
- T
Type Parameters
T
Delay(IUpdatable, int, bool, string)
An indicator that delays its input for a certain period
public static Delay Delay(this IUpdatable input, int period, bool waitForFirstToReady = true, string name = null)
Parameters
inputIUpdatableThe indicator that sends data via Updated even to the second
periodintThe period to delay input, must be greater than zero
waitForFirstToReadyboolTrue to only send updates to the second if input.IsReady returns true, false to alway send updates to second
namestringName of the returned Delay.
Returns
- Delay
The reference to the second indicator to allow for method chaining
EMA(IUpdatable, int, double?, bool)
Creates a new ExponentialMovingAverage indicator with the specified period and smoothingFactor from the left indicator
public static ExponentialMovingAverage EMA(this IUpdatable left, int period, double? smoothingFactor = null, bool waitForFirstToReady = true)
Parameters
leftIUpdatableThe ExponentialMovingAverage indicator will be created using the data from left
periodintThe period of the ExponentialMovingAverage indicators
smoothingFactordouble?The percentage of data from the previous value to be carried into the next value
waitForFirstToReadyboolTrue to only send updates to the second if left.IsReady returns true, false to alway send updates
Returns
- ExponentialMovingAverage
A reference to the ExponentialMovingAverage indicator to allow for method chaining
Explode(IUpdatable, bool)
Creates a CountSelector for every input's OutputCount ordered by ascending index.
public static CountSelector[] Explode(this IUpdatable input, bool waitForFirstToReady = true)
Parameters
inputIUpdatableAn indicator
waitForFirstToReadyboolTrue to only send updates to the second if input.IsReady returns true, false to alway send updates to second
Returns
- CountSelector[]
an array of CountSelector for every
input's OutputCount ordered by ascending index.
ExtractName(IUpdatable)
Resolves the name of given updatable
public static string ExtractName(this IUpdatable updatable)
Parameters
updatableIUpdatable
Returns
Function(IUpdatable, UnaryArrayFunctionHandler, ArraySelectorFunctionHandler, bool, string)
Performs a math op over DoubleArray or the value from selector. The result is stored in a Identity.
public static Identity Function(this IUpdatable first, UnaryArrayFunctionHandler op, ArraySelectorFunctionHandler selector = null, bool waitForFirstToReady = true, string name = null)
Parameters
firstIUpdatableThe indicator that sends data via Updated even to the math
opopUnaryArrayFunctionHandlerThe operation to perform on the DoubleArray passed from
first.selectorArraySelectorFunctionHandlerA selector to choose what DoubleArray to pass to math
op. By default, the unchanged DoubleArray is used.waitForFirstToReadyboolFirst must be ready in order to push the updates forward.
namestringName of the new returned Identity representing the
op.
Returns
Function(IUpdatable, UnaryFunctionHandler, SelectorFunctionHandler, bool, string)
public static Identity Function(this IUpdatable first, UnaryFunctionHandler op, SelectorFunctionHandler selector = null, bool waitForFirstToReady = true, string name = null)
Parameters
firstIUpdatableThe indicator that sends data via Updated even to the math
opopUnaryFunctionHandlerThe operation to perform on Value.
selectorSelectorFunctionHandlerA selector to choose what double to pass to math
op. By default Value is used.waitForFirstToReadyboolFirst must be ready in order to push the updates forward.
namestringName of the new returned Identity representing the
op.
Returns
MAX(IUpdatable, int, bool)
Creates a new Maximum indicator with the specified period from the left indicator
public static IIndicator MAX(this IUpdatable left, int period, bool waitForFirstToReady = true)
Parameters
leftIUpdatableThe Maximum indicator will be created using the data from left
periodintThe period of the Maximum indicator
waitForFirstToReadyboolTrue to only send updates to the second if left.IsReady returns true, false to alway send updates
Returns
- IIndicator
A reference to the Maximum indicator to allow for method chaining
MIN(IUpdatable, int, bool)
Creates a new Minimum indicator with the specified period from the left indicator
public static IIndicator MIN(this IUpdatable left, int period, bool waitForFirstToReady = true)
Parameters
leftIUpdatableThe Minimum indicator will be created using the data from left
periodintThe period of the Minimum indicator
waitForFirstToReadyboolTrue to only send updates to the second if left.IsReady returns true, false to alway send updates
Returns
- IIndicator
A reference to the Minimum indicator to allow for method chaining
Minus(IUpdatable, IUpdatable, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the difference of the left and right
public static CompositeIndicator Minus(this IUpdatable left, IUpdatable right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The difference of the left and right indicators
Remarks
value = left - right
Minus(IUpdatable, IUpdatable, string, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the difference of the left and right
public static CompositeIndicator Minus(this IUpdatable left, IUpdatable right, string name, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
namestringThe name of this indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The difference of the left and right indicators
Remarks
value = left - right
Minus(IUpdatable, double)
Creates a new CompositeIndicator such that the result will be the difference of the left and constant
public static CompositeIndicator Minus(this IUpdatable left, double constant)
Parameters
leftIUpdatableThe left indicator
constantdoubleThe subtrahend
Returns
- CompositeIndicator
The difference of the left and right indicators
Remarks
value = left - constant
Minus(IndicatorBase, IndicatorBase, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the difference of the left and right
public static CompositeIndicator Minus(this IndicatorBase left, IndicatorBase right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIndicatorBaseThe left indicator
rightIndicatorBaseThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The difference of the left and right indicators
Remarks
value = left - right
Of<T>(T, IUpdatable, bool)
Configures the second indicator to receive automatic updates from the first by attaching an event handler to first.Updated
public static T Of<T>(this T second, IUpdatable first, bool waitForFirstToReady = true) where T : IUpdatable
Parameters
secondTThe indicator that receives data from the first
firstIUpdatableThe indicator that sends data via Updated even to the second
waitForFirstToReadyboolTrue to only send updates to the second if first.IsReady returns true, false to alway send updates to second
Returns
- T
The reference to the second indicator to allow for method chaining
Type Parameters
T
Over(IUpdatable, IUpdatable, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the ratio of the left to the right
public static CompositeIndicator Over(this IUpdatable left, IUpdatable right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The ratio of the left to the right indicator
Remarks
value = left/right
Over(IUpdatable, IUpdatable, string, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the ratio of the left to the right
public static CompositeIndicator Over(this IUpdatable left, IUpdatable right, string name, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
namestringThe name of this indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The ratio of the left to the right indicator
Remarks
value = left/right
Over(IUpdatable, double)
Creates a new CompositeIndicator such that the result will be the ratio of the left to the constant
public static CompositeIndicator Over(this IUpdatable left, double constant)
Parameters
leftIUpdatableThe left indicator
constantdoubleThe constant value denominator
Returns
- CompositeIndicator
The ratio of the left to the right indicator
Remarks
value = left/constant
Over(IndicatorBase, IndicatorBase, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the ratio of the left to the right
public static CompositeIndicator Over(this IndicatorBase left, IndicatorBase right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIndicatorBaseThe left indicator
rightIndicatorBaseThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The ratio of the left to the right indicator
Remarks
value = left/right
Plus(IUpdatable, IUpdatable, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the sum of the left and right
public static CompositeIndicator Plus(this IUpdatable left, IUpdatable right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The sum of the left and right indicators
Remarks
value = left + right
Plus(IUpdatable, IUpdatable, string, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the sum of the left and right
public static CompositeIndicator Plus(this IUpdatable left, IUpdatable right, string name, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
namestringThe name of this indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The sum of the left and right indicators
Remarks
value = left + right
Plus(IUpdatable, double)
Creates a new CompositeIndicator such that the result will be the sum of the left and the constant
public static CompositeIndicator Plus(this IUpdatable left, double constant)
Parameters
leftIUpdatableThe left indicator
constantdoubleThe addend
Returns
- CompositeIndicator
The sum of the left and right indicators
Remarks
value = left + constant
Plus(IndicatorBase, IndicatorBase, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the sum of the left and right
public static CompositeIndicator Plus(this IndicatorBase left, IndicatorBase right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIndicatorBaseThe left indicator
rightIndicatorBaseThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The sum of the left and right indicators
Remarks
value = left + right
SMA(IUpdatable, int, bool)
Initializes a new instance of the SimpleMovingAverage class with the specified name and period from the left indicator
public static SimpleMovingAverage SMA(this IUpdatable left, int period, bool waitForFirstToReady = true)
Parameters
leftIUpdatableThe SimpleMovingAverage indicator will be created using the data from left
periodintThe period of the SMA
waitForFirstToReadyboolTrue to only send updates to the second if first.IsReady returns true, false to alway send updates to second
Returns
- SimpleMovingAverage
The reference to the SimpleMovingAverage indicator to allow for method chaining
Select(IUpdatable, ArraySelectorFunctionHandler, int, int, bool, string)
Selects a DoubleArray to another DoubleArray. The result is stored in a Identity.
public static Identity Select(this IUpdatable input, ArraySelectorFunctionHandler selector, int outputCount = 1, int properties = 1, bool waitForFirstToReady = true, string name = null)
Parameters
inputIUpdatableThe indicator that sends data via Updated
selectorArraySelectorFunctionHandlerA selector to choose what DoubleArray.
outputCountintpropertiesintwaitForFirstToReadyboolInput must be ready in order to push the updates forward.
namestringName of the new returned Identity.
Returns
Select(IUpdatable, SelectorFunctionHandler, bool, string)
Selects a DoubleArray to a double. The result is stored in a Identity.
public static Identity Select(this IUpdatable input, SelectorFunctionHandler selector, bool waitForFirstToReady = true, string name = null)
Parameters
inputIUpdatableThe indicator that sends data via Updated
selectorSelectorFunctionHandlerA selector to choose a double.
waitForFirstToReadyboolInput must be ready in order to push the updates forward.
namestringName of the new returned Identity.
Returns
Slice(IUpdatable, int, int, string, bool)
Slices input at range from start to stop on the OutputCount axis/dimension.
public static SliceSelector Slice(this IUpdatable input, int start, int stop, string name = null, bool waitForFirstToReady = true)
Parameters
inputIUpdatableThe indicator to slice.
startintStart of interval. The interval includes this value. The default start value is 0.
stopintEnd of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.
namestringThe name of this indicator
waitForFirstToReadyboolTrue to only send updates to the second if input.IsReady returns true, false to alway send updates to second
Returns
- SliceSelector
A sliced IIndicator
Slice(IUpdatable, int, string, bool)
Slices input at range from start to stop on the OutputCount axis/dimension.
public static CountSelector Slice(this IUpdatable input, int index, string name = null, bool waitForFirstToReady = true)
Parameters
inputIUpdatableThe indicator to slice.
indexintnamestringThe name of this indicator
waitForFirstToReadyboolTrue to only send updates to the second if ןמפוא.IsReady returns true, false to alway send updates to second
Returns
- CountSelector
A sliced IIndicator
SliceProperty(IUpdatable, int, int, string, bool)
Slices properties of input at range from start to stop on the OutputCount axis/dimension.
public static PropertySelector SliceProperty(this IUpdatable input, int start, int stop, string name = null, bool waitForFirstToReady = true)
Parameters
inputIUpdatableThe indicator to slice.
startintStart of interval. The interval includes this value. The default start value is 0.
stopintEnd of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.
namestringThe name of this indicator
waitForFirstToReadyboolTrue to only send updates to the second if ןמפוא.IsReady returns true, false to alway send updates to second
Returns
- PropertySelector
A sliced IIndicator
SliceProperty(IUpdatable, int, string, bool)
Creates a new CompositeIndicator such that the result will be the product of the left to the right
public static PropertySelector SliceProperty(this IUpdatable input, int index, string name = null, bool waitForFirstToReady = true)
Parameters
inputIUpdatableThe left indicator
indexintnamestringThe name of this indicator
waitForFirstToReadyboolTrue to only send updates to the second if first.IsReady returns true, false to alway send updates to second
Returns
- PropertySelector
The product of the left to the right indicators
Remarks
value = left*right
ThenToList(IUpdatable, bool, bool)
Will collect updates from first into the returned List<T>.
public static List<DoubleArray> ThenToList(this IUpdatable first, bool waitForFirstToReady = true, bool resetListOnIndicatorReset = false)
Parameters
firstIUpdatableThe indicator that sends data via Updated even to the second
waitForFirstToReadyboolTrue to only send updates to the second if first.IsReady returns true, false to alway send updates to second
resetListOnIndicatorResetboolShould the returned List<T> be cleared when
firstis Resetted.
Returns
Then<T>(IUpdatable, T, bool)
Configures the second indicator to receive automatic updates from the first by attaching an event handler to first.Updated
public static T Then<T>(this IUpdatable first, T second, bool waitForFirstToReady = true) where T : IUpdatable
Parameters
firstIUpdatableThe indicator that sends data via Updated even to the second
secondTThe indicator that receives data from the first
waitForFirstToReadyboolTrue to only send updates to the second if first.IsReady returns true, false to alway send updates to second
Returns
- T
The reference to the second indicator to allow for method chaining
Type Parameters
T
Times(IUpdatable, IUpdatable, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the product of the left to the right
public static CompositeIndicator Times(this IUpdatable left, IUpdatable right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The product of the left to the right indicators
Remarks
value = left*right
Times(IUpdatable, IUpdatable, string, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the product of the left to the right
public static CompositeIndicator Times(this IUpdatable left, IUpdatable right, string name, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIUpdatableThe left indicator
rightIUpdatableThe right indicator
namestringThe name of this indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The product of the left to the right indicators
Remarks
value = left * right
Times(IUpdatable, double)
Creates a new CompositeIndicator such that the result will be the product of the left and the constant
public static CompositeIndicator Times(this IUpdatable left, double constant)
Parameters
leftIUpdatableThe left indicator
constantdoubleThe constant value to multiple by
Returns
- CompositeIndicator
The product of the left to the right indicators
Remarks
value = left*constant
Times(IndicatorBase, IndicatorBase, CompositionMethod)
Creates a new CompositeIndicator such that the result will be the product of the left to the right
public static CompositeIndicator Times(this IndicatorBase left, IndicatorBase right, CompositionMethod method = CompositionMethod.OnBothUpdated)
Parameters
leftIndicatorBaseThe left indicator
rightIndicatorBaseThe right indicator
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
The product of the left to the right indicators
Remarks
value = left*right
WeightedBy<TWeight>(IUpdatable, TWeight, int, CompositionMethod)
Creates a new CompositeIndicator such that the result will be average of a first indicator weighted by a second one
public static CompositeIndicator WeightedBy<TWeight>(this IUpdatable value, TWeight weight, int period, CompositionMethod method = CompositionMethod.OnBothUpdated) where TWeight : IUpdatable
Parameters
valueIUpdatableIndicator that will be averaged
weightTWeightIndicator that provides the average weights
periodintAverage period
methodCompositionMethodWhat method to composite the two indicators.
Returns
- CompositeIndicator
Indicator that results of the average of first by weights given by second
Type Parameters
TWeight
Window(IUpdatable, int, bool, string)
An indicator that creates a RollingWindow<T> with period for every item it receives via Update(long, DoubleArray).
public static WindowIdentity Window(this IUpdatable input, int period, bool waitForFirstToReady = true, string name = null)
Parameters
inputIUpdatableThe indicator that sends data via Updated even to the WindowIdentity
periodintThe period to delay input, must be greater than zero
waitForFirstToReadyboolTrue to only send updates to the second if input.IsReady returns true, false to alway send updates to second
namestringName of the returned Delay.
Returns
- WindowIdentity
The reference to the second indicator to allow for method chaining