public enum AutoStopMode { AsPercent, AsPoint }; public virtual void ApplyAutoStops(int Bar) public virtual void SetAutoStopMode(AutoStopMode mode) public virtual void InstallTimeBasedExit(int Bars) public virtual void InstallStopLoss(double StopLevel) public virtual void InstallTrailingStop(double Trigger, double StopLevel) public virtual void InstallReverseBreakEvenStop(double LossLevel) public virtual void InstallBreakEvenStop(double Trigger) public virtual void InstallProfitTarget(double TargetLevel) public virtual void OnProcessingComplete()
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; // < AutoStops here in PositionEx static class /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class AutoStopsDemo : WealthScript { protected override void Execute() { // Select AutoStop mode: AsPercent or AsPoint AutoStopMode AsPercent = AutoStopMode.AsPercent; //sample calls to auto stop methods PositionEx.SetAutoStopMode(AsPercent); // choose AutoStopMode PositionEx.InstallTimeBasedExit(30); PositionEx.InstallStopLoss(5); PositionEx.InstallProfitTarget(10); PositionEx.InstallBreakEvenStop(5); PositionEx.InstallReverseBreakEvenStop(3); PositionEx.InstallTrailingStop(6, (100 - 70)); for(int bar = 20; bar < Bars.Count; bar++) { // Apply auto stops this.ApplyAutoStops(bar); if (!IsLastPositionActive) { BuyAtMarket(bar + 1); } } PositionEx.OnProcessingComplete(); } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; // < AutoStops here /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class AutoStopsDemo : WealthScript { protected override void Execute() { // Create an instance of PositionHelper (class containing AutoStops), // passing a WealthScript object as "this" PositionHelper a = new PositionHelper(this); // Select AutoStop mode: AsPercent or AsPoint PositionHelper.AutoStopMode AsPercent = Community.Components. PositionHelper.AutoStopMode.AsPercent; //sample calls to auto stop methods a.SetAutoStopMode(AsPercent); // choose AutoStopMode a.InstallTimeBasedExit(30); a.InstallStopLoss(5); a.InstallProfitTarget(10); a.InstallBreakEvenStop(5); a.InstallReverseBreakEvenStop(3); a.InstallTrailingStop(6, (100 - 70)); for(int Bar = 20; Bar < Bars.Count; Bar++) { // Apply auto stops a.ApplyAutoStops(Bar); if (!IsLastPositionActive) { BuyAtMarket(Bar + 1); } } a.OnProcessingComplete(); } } }