public QStick(Bars bars, int period, string description) public static QStick Series(Bars bars, int period)
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() { // See how good the QStick zero line entry rule really is double stop = 0; double profit = 0; double ep = 0; DataSeries qs = QStick.Series( Bars, 24 ); ChartPane QStickPane = CreatePane( 50, true, true ); PlotSeries( QStickPane, qs, Color.DarkBlue, WealthLab.LineStyle.Solid, 2 ); for(int bar = 24; bar < Bars.Count; bar++) { if( CrossOver( bar, qs, 0 ) ) BuyAtMarket( bar+1 ); if( CrossUnder( bar, qs, 0 ) ) ShortAtMarket( bar+1 ); for (int p = ActivePositions.Count - 1; p > -1; p-- ) { Position pos = ActivePositionsp; ep = pos.EntryPrice; stop = ( pos.PositionType == PositionType.Long ) ? ep*0.8 : ep*1.2; profit = ( pos.PositionType == PositionType.Long ) ? ep*1.1 : ep*0.9; if( !ExitAtStop( bar+1, pos, stop, "Stop Loss" ) ) ExitAtLimit( bar+1, pos, profit, "Profit Target" ); } } } } }