public static bool ExitAtPrice(this WealthScript obj, Bars bars, int bar, Position p, double price, string signalName)public bool ExitAtPrice(Bars bars, 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 AtPriceDemo : WealthScript { protected override void Execute() { // initialize your average series however you like DataSeries avgSer = 0.5 * Open + 0.5 * Close; /* In the trading loop here's the buy signal that uses your peeking data. It won't create an Alert because they're peeking results. Not a tradeable script! */ for(int bar = 1; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( true ) // some condition to exit at the average price this month this.ExitAtPrice(Bars, bar, LastPosition, avgSer[bar], "Out"); } else { if( true ) // some condition to buy at the average price this month this.EnterAtPrice(Bars, bar, avgSer[bar], PositionType.Long, "In"); } } } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; // Support for enter/exit at price here /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class AtPriceDemo: WealthScript { protected override void Execute() { // Create an instance of the PositionHelper class, passing WealthScript as "this" PositionHelper ph = new PositionHelper( this ); // initialize your average series however you like DataSeries avgSer = 0.5 * Open + 0.5 * Close; /* In the trading loop here's the buy signal that uses your peeking data. It won't create an Alert because they're peeking results. Not a tradeable script! */ for(int bar = 1; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( true ) // some condition to exit at the average price this month ph.ExitAtPrice(Bars, bar, LastPosition, avgSer[bar], "Out"); } else { if( true ) // some condition to buy at the average price this month ph.EnterAtPrice(Bars, bar, avgSer[bar], PositionType.Long, "In"); } } } } }