SeriesIsAbove: Indicator Documentation
Syntax
SeriesIsAbove(DataSeries ds1, DataSeries ds2, int period)
SeriesIsAbove(DataSeries ds1, DataSeries ds2, int period, string description)
Parameter Description
ds1 | First data series |
ds2 | Second data series |
period | Period for which the 1st data series should be above the 2nd data series |
Description
Returns the number of consecutive bars that Series1 has been above Series2 minus the Period bars.
- To count the number of consecutive bars that Series1 has been above Series2 use period = 1.
- For any other period, SeriesIsAbove returns zero until Series1 has been above Series2 for at least period bars. After being above for period bars, SeriesIsAbove returns 1 and increments with each new bar that Series1 is above Series2.
See
Series Is Below.
Example
This example illustrates the indicator's application by plotting a histogram output for the number of consecutive bars that the 20-period
SMA is above/below the 50-period
SMA:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
HideVolume();
SMA ds1 = SMA.Series( Close, 20 );
SMA ds2 = SMA.Series( Close, 50 );
PlotSeries( PricePane, ds1, Color.Blue, LineStyle.Solid, 1 );
PlotSeries( PricePane, ds2, Color.Red, LineStyle.Solid, 1 );
SeriesIsAbove sa = SeriesIsAbove.Series( ds1, ds2, 1);
SeriesIsBelow sb = SeriesIsBelow.Series( ds1, ds2, 1);
ChartPane psa = CreatePane( 30, true, true );
ChartPane psb = CreatePane( 30, false, true );
PlotSeries( psa, sa, Color.Blue, LineStyle.Histogram, 2 );
PlotSeries( psb, sb, Color.Red, LineStyle.Histogram, 2 );
}
}
}