HasCrossedAbove


Summary

Returns true, if dataseries1 has crossed above dataseries2, over the specified Period.

Remarks

HasCrossedAbove will compare the crossing dataseries to the crossed dataseries starting from the current value of the series going back the specified period. If period is zero only the current bar values will be compared. If period is one the current bar values will be compared as well as the previous. e.g. Functions.HasCrossedAbove(sma.Result, MarketSeries.Close, 0) will only compare the current values which are not completed until the close of the bar. It is not uncommon that the function will return true and by the end of the bar the two series will uncross.

Syntax

public static bool HasCrossedAbove(DataSeries crossingSeries, DataSeries crossedSeries, int period)
public static bool HasCrossedAbove(DataSeries crossingSeries, double value, int period)

Parameters

NameDescription

Example 1

public override void Calculate(int index)
{
    if(Functions.HasCrossedAbove(sma.Result, MarketSeries.Close, 0))
    {
        //Do something
    }
    // May be invoked as an extension method as well
    
    if(sma.Result.HasCrossedAbove(MarketSeries.Close, 0))
    {
        //Do something
    }
}