public static MTop CheckTop(this WealthScript obj, int bar, DataSeries ds, int lookback, double pctRetrace, double threshold) public static WBottom CheckBottom(this WealthScript obj, int bar, DataSeries ds, int lookback, double pctRetrace, double threshold)public MTop CheckTop(int bar, DataSeries ds, int lookback, double pctRetrace, double threshold) public WBottom CheckBottom(int bar, DataSeries ds, int lookback, double pctRetrace, double threshold)public enum WBottom { None, Detected, PreviousDetection }; public enum MTop { None, Detected, PreviousDetection };
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() { int lookback = 200; for(int bar = lookback; bar < Bars.Count; bar++) { CommonSignalsEx.WBottom cb = this.CheckBottom(bar, Low, lookback, 8, 1.5); CommonSignalsEx.MTop ct = this.CheckTop(bar, High, lookback, 8, 1.5); if ( cb == CommonSignalsEx.WBottom.Detected ) { BuyAtClose(bar); ExitAtMarket(bar + 1, LastPosition); } else if ( ct == CommonSignalsEx.MTop.Detected ) { ShortAtClose(bar); ExitAtMarket(bar + 1, LastPosition); } if ( cb == CommonSignalsEx.WBottom.PreviousDetection ) SetBackgroundColor(bar, Color.LightBlue); if ( ct == CommonSignalsEx.MTop.PreviousDetection ) SetBackgroundColor(bar, Color.LightBlue); } } } }
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() { //before Wealth-Lab 6.2: //Calculate c = new Calculate( this ); //from Wealth-Lab 6.2+ PatternRecognition c = new PatternRecognition( this ); int lookback = 200; for(int bar = lookback; bar < Bars.Count; bar++) { WBottom cb = c.CheckBottom(bar, Low, lookback, 8, 1.5); MTop ct = c.CheckTop(bar, High, lookback, 8, 1.5); if ( cb == WBottom.Detected ) { BuyAtClose(bar); ExitAtMarket(bar + 1, LastPosition); } else if ( ct == MTop.Detected ) { ShortAtClose(bar); ExitAtMarket(bar + 1, LastPosition); } if ( cb == WBottom.PreviousDetection ) SetBackgroundColor(bar, Color.LightBlue); if ( ct == MTop.PreviousDetection ) SetBackgroundColor(bar, Color.LightBlue); } } } }