DataSeries DerivativeOscillator (DataSeries ds, int periodRSI, int periodEMA1, int periodEMA2, int periodSMA)
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 DerivativeOscDemo : WealthScript { private StrategyParameter paramPeriodRSI; private StrategyParameter paramPeriod1; private StrategyParameter paramPeriod2; private StrategyParameter paramPeriod3; public DerivativeOscDemo() { paramPeriodRSI = CreateParameter("RSI Period", 14, 2, 30, 1); paramPeriod1 = CreateParameter("EMA Period 1", 5, 2, 20, 1); paramPeriod2 = CreateParameter("EMA Period 2", 3, 2, 10, 1); paramPeriod3 = CreateParameter("SMA Period", 9, 2, 20, 1); } protected override void Execute() { int perRSI = paramPeriodRSI.ValueInt; int perEMA1 = paramPeriod1.ValueInt; int perEMA2 = paramPeriod2.ValueInt; int perSMA = paramPeriod3.ValueInt; DerivativeOscillator derivOsc = DerivativeOscillator.Series( Close,perRSI,perEMA1,perEMA2,perSMA ); for(int bar = GetTradingLoopStartBar(derivOsc.FirstValidValue * 3); bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( CrossUnder( bar, derivOsc, 0 ) ) SellAtMarket( bar+1, LastPosition ); } else { if( CrossOver( bar, derivOsc, 0 ) ) BuyAtMarket( bar+1 ); } } ChartPane doPane = CreatePane( 40,true,true ); PlotSeries( doPane, derivOsc, Color.Navy, LineStyle.Histogram, 4 ); HideVolume(); } } }