using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators; // requires version 2011.4.0.0 minnamespace WealthLab.Strategies { public class SemiCupDetector : WealthScript { StrategyParameter _minCupBars; StrategyParameter _reversalPct; public SemiCupDetector() { _minCupBars = CreateParameter("Min Cup Bars", 20, 20, 100, 10); _reversalPct = CreateParameter("Pk Rev. %", 5, 0.5, 8, 0.5); } protected override void Execute() { DataSeries peakBars = PeakBar.Series(Close, _reversalPct.Value, PeakTroughMode.Percent); SemiCups semiCups = new SemiCups(this, _minCupBars.ValueInt, peakBars); // semiCups.ProcessSemiCups(); // not required for TASCIndicators 2011.4.0.1 semiCups.Draw(); int bar = Bars.Count - 1; // Scan for current pattern foreach (KeyValuePair<int, SemiCup> kvp in semiCups.Cups) { SemiCup sc = kvp.Value; if (sc.Active && sc.Status[bar] == CupStatus.SemiCupDetected) BuyAtMarket(Bars.Count); } } } }