public CandleCode(Bars ds, string description) public static CandleCode Series(Bars ds)
/* CandleCode System*/ using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { // Create and Plot CandleCode with a 20 day SMA DataSeries cc = CandleCode.Series(Bars); DataSeries smaCC = SMA.Series(cc, 20); ChartPane cp = CreatePane(40, true, true); PlotSeries(cp, cc, Color.Blue, LineStyle.Histogram, 1); PlotSeries(cp, smaCC, Color.Red, LineStyle.Solid, 1); //Simple CandleCode trading system PlotStops(); for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) { // 20% stop and 15% Profit Target Position p = LastPosition; if (p.PositionType == PositionType.Long) { if( ! SellAtStop(bar + 1, p, p.EntryPrice * 0.8, "Stop Loss") ) SellAtLimit(bar + 1, p, p.EntryPrice * 1.15, "Profit Target"); } else if( ! CoverAtStop(bar + 1, p, p.EntryPrice * 1.2, "Stop Loss") ) CoverAtLimit(bar + 1, p, p.EntryPrice * 0.85, "Profit Target"); } else { if( CrossUnder(bar, smaCC, -25) ) BuyAtMarket(bar + 1); else if( CrossOver(bar, smaCC, 25) ) ShortAtMarket(bar + 1); } } } } }