Table of Contents

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

input IUpdatable

The indicator that sends data via Updated even to the ArrayRollingWindow

period int

The period to delay input, must be greater than zero

waitForFirstToReady bool

True to only send updates to the second if input.IsReady returns true, false to alway send updates to second

name string

Name of the returned Delay.

Returns

ArrayRollingWindow

The reference to the second indicator to allow for method chaining

BreakOnUpdate<T>(T, int)

Makes the give updatable to trigger Break() when Updated is fired.

public static T BreakOnUpdate<T>(this T updatable, int interval = 1) where T : IUpdatable

Parameters

updatable T
interval int

On 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

input IUpdatable

The indicator that sends data via Updated even to the second

period int

The period to delay input, must be greater than zero

waitForFirstToReady bool

True to only send updates to the second if input.IsReady returns true, false to alway send updates to second

name string

Name 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

left IUpdatable

The ExponentialMovingAverage indicator will be created using the data from left

period int

The period of the ExponentialMovingAverage indicators

smoothingFactor double?

The percentage of data from the previous value to be carried into the next value

waitForFirstToReady bool

True 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

input IUpdatable

An indicator

waitForFirstToReady bool

True 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

updatable IUpdatable

Returns

string

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

first IUpdatable

The indicator that sends data via Updated even to the math op

op UnaryArrayFunctionHandler

The operation to perform on the DoubleArray passed from first.

selector ArraySelectorFunctionHandler

A selector to choose what DoubleArray to pass to math op. By default, the unchanged DoubleArray is used.

waitForFirstToReady bool

First must be ready in order to push the updates forward.

name string

Name of the new returned Identity representing the op.

Returns

Identity

Function(IUpdatable, UnaryFunctionHandler, SelectorFunctionHandler, bool, string)

Performs a math op over Value or value from selector. The result is stored in a Identity.

public static Identity Function(this IUpdatable first, UnaryFunctionHandler op, SelectorFunctionHandler selector = null, bool waitForFirstToReady = true, string name = null)

Parameters

first IUpdatable

The indicator that sends data via Updated even to the math op

op UnaryFunctionHandler

The operation to perform on Value.

selector SelectorFunctionHandler

A selector to choose what double to pass to math op. By default Value is used.

waitForFirstToReady bool

First must be ready in order to push the updates forward.

name string

Name of the new returned Identity representing the op.

Returns

Identity

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

left IUpdatable

The Maximum indicator will be created using the data from left

period int

The period of the Maximum indicator

waitForFirstToReady bool

True 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

left IUpdatable

The Minimum indicator will be created using the data from left

period int

The period of the Minimum indicator

waitForFirstToReady bool

True 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

name string

The name of this indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

constant double

The 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

left IndicatorBase

The left indicator

right IndicatorBase

The right indicator

method CompositionMethod

What 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

second T

The indicator that receives data from the first

first IUpdatable

The indicator that sends data via Updated even to the second

waitForFirstToReady bool

True 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

name string

The name of this indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

constant double

The 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

left IndicatorBase

The left indicator

right IndicatorBase

The right indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

name string

The name of this indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

constant double

The 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

left IndicatorBase

The left indicator

right IndicatorBase

The right indicator

method CompositionMethod

What 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

left IUpdatable

The SimpleMovingAverage indicator will be created using the data from left

period int

The period of the SMA

waitForFirstToReady bool

True 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

input IUpdatable

The indicator that sends data via Updated

selector ArraySelectorFunctionHandler

A selector to choose what DoubleArray.

outputCount int
properties int
waitForFirstToReady bool

Input must be ready in order to push the updates forward.

name string

Name of the new returned Identity.

Returns

Identity

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

input IUpdatable

The indicator that sends data via Updated

selector SelectorFunctionHandler

A selector to choose a double.

waitForFirstToReady bool

Input must be ready in order to push the updates forward.

name string

Name of the new returned Identity.

Returns

Identity

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

input IUpdatable

The indicator to slice.

start int

Start of interval. The interval includes this value. The default start value is 0.

stop int

End 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.

name string

The name of this indicator

waitForFirstToReady bool

True 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

input IUpdatable

The indicator to slice.

index int
name string

The name of this indicator

waitForFirstToReady bool

True 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

input IUpdatable

The indicator to slice.

start int

Start of interval. The interval includes this value. The default start value is 0.

stop int

End 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.

name string

The name of this indicator

waitForFirstToReady bool

True 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

input IUpdatable

The left indicator

index int
name string

The name of this indicator

waitForFirstToReady bool

True 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

first IUpdatable

The indicator that sends data via Updated even to the second

waitForFirstToReady bool

True to only send updates to the second if first.IsReady returns true, false to alway send updates to second

resetListOnIndicatorReset bool

Should the returned List<T> be cleared when first is Resetted.

Returns

List<DoubleArray>

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

first IUpdatable

The indicator that sends data via Updated even to the second

second T

The indicator that receives data from the first

waitForFirstToReady bool

True 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

right IUpdatable

The right indicator

name string

The name of this indicator

method CompositionMethod

What 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

left IUpdatable

The left indicator

constant double

The 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

left IndicatorBase

The left indicator

right IndicatorBase

The right indicator

method CompositionMethod

What 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

value IUpdatable

Indicator that will be averaged

weight TWeight

Indicator that provides the average weights

period int

Average period

method CompositionMethod

What 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

input IUpdatable

The indicator that sends data via Updated even to the WindowIdentity

period int

The period to delay input, must be greater than zero

waitForFirstToReady bool

True to only send updates to the second if input.IsReady returns true, false to alway send updates to second

name string

Name of the returned Delay.

Returns

WindowIdentity

The reference to the second indicator to allow for method chaining