public VarianceRatio(Bars bars, DataSeries ds, int lookback, int period) public VarianceRatio(Bars bars, DataSeries ds, int lookback, 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 RSI_VarianceRatio_Filter : WealthScript { protected override void Execute() { LineStyle ls = LineStyle.Solid; LineStyle ld = LineStyle.Dotted; Color silver = Color.Silver; VarianceRatio vr = VarianceRatio.Series(Bars, Close, 20, 400); double sensitivity = 0.9; ChartPane vr_p = CreatePane(30, true, false); PlotSeries(vr_p, vr, Color.Blue, ls, 1 ); DrawHorzLine(vr_p, sensitivity, Color.Red, ls, 2 ); RSI rsi_s = RSI.Series(Close, 14); ChartPane RSI_p = CreatePane( 30, true, false ); int RSI_lower = 30; int RSI_upper = 70; PlotSeries( RSI_p, rsi_s, Color.Blue, ls, 1 ); DrawHorzLine(RSI_p, RSI_lower, silver, ld, 2 ); DrawHorzLine(RSI_p, 50, silver, ld, 2 ); DrawHorzLine(RSI_p, RSI_upper, silver, ld, 2 ); for(int bar = 20; bar < Bars.Count; bar++) { if (vrbar > sensitivity) SetBackgroundColor(bar, Color.FromArgb(50,Color.LightGreen)); if( ( ActivePositions.Count > 0 ) & CrossOver(bar, rsi_s, RSI_upper) ) SellAtMarket( bar + 1, Position.AllPositions, "RSI Exit" ); if( CrossOver(bar, rsi_s, RSI_lower) & (vrbar > sensitivity) ) BuyAtMarket( bar + 1, "RSI Entry" ); } } } }