Log in to see Cloud of Tags

Wealth-Lab Wiki

Series is Above a Value


SeriesIsAboveValue: Indicator Documentation


SeriesIsAboveValue(DataSeries ds, double num, int period)
SeriesIsAboveValue(DataSeries ds, double num, int period, string description)

Parameter Description

dsData series
periodPeriod for which the data series should be above the value


Returns the number of consecutive bars that a DataSeries dshas been above a value num minus the Period bars.
  • To count the number of consecutive bars that the DataSeries has been above the value, use period = 1.
    • Note! Versions prior to 2019.03 contained a bug (now fixed). Backtest results will change if upgrading to 2019.03 or higher.
  • For any other period, SeriesIsAboveValue returns zero until the DataSeries has been above the value for at least period bars. After being above for period bars, SeriesIsAboveValue returns 1 and increments with each new bar that the DataSeries is above the value.

See also:
Series Is Below a Value
Series Is Above


This simple system takes long positions when the 2-period RSI has been above 95 for 5 consecutive bars, and short positions when it has been below 5 for consecutive bars, closing them after being in the market for a month.

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() { int period = 2; DataSeries rsi = RSI.Series(Close, 2); SeriesIsAboveValue rsiAbove95 = SeriesIsAboveValue.Series( rsi, 95, 5 ); SeriesIsBelowValue rsiBelow5 = SeriesIsBelowValue.Series( rsi, 5, 5 ); ChartPane rsiPane = CreatePane(25, true, true); PlotSeries(rsiPane, rsi, Color.Black, LineStyle.Solid, 2); ChartPane cp = CreatePane(25, true, true); PlotSeries(cp, rsiAbove95, Color.Blue, LineStyle.Histogram, 2); PlotSeries(cp, rsiBelow5, Color.Red, LineStyle.Histogram, 2); for(int bar = period * 3; bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; TimeSpan ts = Date[bar] - Date[p.EntryBar]; if (ts.Days > 29) ExitAtMarket(bar + 1, p, "Time-based"); } else { if (rsiAbove95[bar] >= 5 ) { BuyAtMarket(bar + 1); SetBackgroundColor(bar, Color.FromArgb(50, Color.Red)); } else if (rsiBelow5[bar] >= 5 ) { ShortAtMarket(bar + 1); SetBackgroundColor(bar, Color.FromArgb(50, Color.Blue)); } } } } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

ScrewTurn Wiki. Some of the icons created by FamFamFam.