public static StochK Series(Bars source, int period) public StochK(Bars source, int period, string description)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { //A system based on Fast Stochastic Extreme Levels DataSeries stK = StochK.Series( Bars, 14 ); ChartPane StochPane = CreatePane( 30, true, true ); PlotSeries( StochPane, stK, Color.Purple, LineStyle.Solid, 2 ); for(int bar = 14; bar < Bars.Count; bar++) { if( CrossUnder( bar, stK, 20 ) ) BuyAtMarket( bar+1 ); if ( ( ActivePositions.Count > 0 ) && CrossOver( bar, stK, 20 ) ) { // Let's work directly with the list of active positions, introduced in WL5 for( int p = ActivePositions.Count - 1; p > -1 ; p-- ) SellAtMarket( bar+1, ActivePositions[p] ); } } } } }