public static double LimitPriorityLong(this WealthScript ws, double p, int bar)public double LimitPriorityLong(double p, int bar)
public static double IntradayFillPriorityEstimate(this WealthScript ws, bool longPos, bool limit, double price, int eodBar)public double IntradayFillPriorityEstimate(bool longPos, bool limit, double price, int eodBar)
... if (BuyAtLimit(bar + 1,price) != null) { LastActivePosition.Priority = this.IntradayFillPriorityEstimate(true, true, price, bar + 1);
using Community.Components; // IntradayFillPriorityEstimate is here /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/... // Create an instance of the PositionHelper class PositionHelper ph = new PositionHelper( this );... for(int bar = 20; bar < Bars.Count-1; bar++) { ... if (BuyAtLimit(bar + 1,price) != null) { LastActivePosition.Priority = ph.IntradayFillPriorityEstimate(true, true, price, bar + 1); ... }
public static void SetTimeOfDayPriority(this WealthScript ws, IList<Position> positions, string intradayDataSet) // baseline method syntax public static void SetTimeOfDayPriority(this WealthScript ws, int barInterval) public static void SetTimeOfDayPriority(this WealthScript ws, int barInterval, DataSource dataSource)public void SetTimeOfDayPriority(IList<Position> positions, string intradayDataSet) public void SetTimeOfDayPriority(int barInterval) // This call is valid only for the Fidelity DataStore
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() { ClearDebug(); for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if (bar - p.EntryBar > 2) SellAtMarket(bar + 1, p); } else { double limitPrice = 0.96 * Close[bar]; Position p = BuyAtLimit(bar + 1, limitPrice); } } /* Call the method after the trading loop */ // For Fidelity WLP users with Fidelity intraday data (only) //this.SetTimeOfDayPriority(5); // Universal approach for any intraday data provider this.SetTimeOfDayPriority(Positions, "[i] ActiveTrader Standard Stock Portfolio (M5)"); /* Check priority - OPTIONAL! */ //int j = 0; //foreach (Position p in Positions) //{ // j++; // PrintDebug(Bars.Symbol + "\t" + j + "\t" + p.Priority + "\t" + p.EntryDate.ToShortDateString()); //} } } }