SeriesIsAboveValue(DataSeries ds, double num, int period) SeriesIsAboveValue(DataSeries ds, double num, int period, string description)
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 = Datebar - Datep.EntryBar; if (ts.Days > 29) ExitAtMarket(bar + 1, p, "Time-based"); } else { if (rsiAbove95bar >= 5 ) { BuyAtMarket(bar + 1); SetBackgroundColor(bar, Color.FromArgb(50, Color.Red)); } else if (rsiBelow5bar >= 5 ) { ShortAtMarket(bar + 1); SetBackgroundColor(bar, Color.FromArgb(50, Color.Blue)); } } } } } }