public static bool CrossOverWithin(this int bar, DataSeries Series1, DataSeries Series2, int WithinBars)public bool CrossOverWithin(int bar, DataSeries Series1, DataSeries Series2, int WithinBars)
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() { for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) { //code your exit rules here } else { if (bar.CrossOverWithin (Close, SMA.Series(Close,20), 5)) BuyAtMarket( bar+1 ); } } } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { // create an instance of the SeriesHelper object SeriesHelper sh = new SeriesHelper(this); for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) { //code your exit rules here } else { if (sh.CrossOverWithin (bar, Close, SMA.Series(Close,20), 5)) BuyAtMarket( bar+1 ); } } } } }