public static Position BuyAtStopLimit(this WealthScript ws, int bar, double price) public static Position BuyAtStopLimit(this WealthScript ws, int bar, double price, string signalName) public static Position ShortAtStopLimit(this WealthScript ws, int bar, double price) public static Position ShortAtStopLimit(this WealthScript ws, int bar, double price, string signalName) public static bool SellAtStopLimit(this WealthScript ws, int bar, Position p, double price) public static bool SellAtStopLimit(this WealthScript ws, int bar, Position p, double price, string signalName) public static bool CoverAtStopLimit(this WealthScript ws, int bar, Position p, double price) public static bool CoverAtStopLimit(this WealthScript ws, int bar, Position p, double price, string signalName)public Position BuyAtStopLimit(int bar, double price) public Position BuyAtStopLimit(int bar, double price, string signalName) public Position ShortAtStopLimit(int bar, double price) public Position ShortAtStopLimit(int bar, double price, string signalName) public bool SellAtStopLimit(int bar, Position p, double price) public bool SellAtStopLimit(int bar, Position p, double price, string signalName) public bool CoverAtStopLimit(int bar, Position p, double price) public bool CoverAtStopLimit(int bar, Position p, double price, string signalName)
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 = GetTradingLoopStartBar(40); bar < Bars.Count; bar++) { if( bar < Bars.Count-1 ) // for backtesting only { if (IsLastPositionActive) { if( !this.SellAtStopLimit( bar+1, LastPosition, Lowest.Series(Low,40)[bar] ) ) this.CoverAtStopLimit( bar+1, LastPosition, Highest.Series(High,40)[bar] ); } else { if( this.BuyAtStopLimit( bar+1, Highest.Series(High,40)[bar] ) == null ) this.ShortAtStopLimit( bar+1, Lowest.Series(Low,40)[bar] ); } } } } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; // Stop/Limit orders here /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { PositionHelper ps = new PositionHelper( this ); // Pass WealthScript for(int bar = GetTradingLoopStartBar(40); bar < Bars.Count; bar++) { if( bar < Bars.Count-1 ) // for backtesting only { if (IsLastPositionActive) { if( !ps.SellAtStopLimit( bar+1, LastPosition, Lowest.Series(Low,40)[bar] ) ) ps.CoverAtStopLimit( bar+1, LastPosition, Highest.Series(High,40)[bar] ); } else { if( ps.BuyAtStopLimit( bar+1, Highest.Series(High,40)[bar] ) == null ) ps.ShortAtStopLimit( bar+1, Lowest.Series(Low,40)[bar] ); } } } } } }