public static DateTime DateOfNextTradingDay(this WealthScript obj, int bar) public static DateTime DateOfNextTradingDay(this WealthScript obj, DateTime dt)public DateTime DateOfNextTradingDay(int bar) public DateTime DateOfNextTradingDay(DateTime dt)
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(1); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if (this.DateOfNextTradingDay(bar).DayOfWeek < Datebar.DayOfWeek) SellAtMarket(bar + 1, p, "It's next week!"); } else { if (this.DateOfNextTradingDay(bar).DayOfWeek == DayOfWeek.Thursday) { BuyAtMarket(bar + 1, "Buy Thurs Morning"); } } } } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { DateTimeFunctions dtf = new DateTimeFunctions(this); for(int bar = GetTradingLoopStartBar(1); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if (dtf.DateOfNextTradingDay(bar).DayOfWeek < Datebar.DayOfWeek) SellAtMarket(bar + 1, p, "It's next week!"); } else { if (dtf.DateOfNextTradingDay(bar).DayOfWeek == DayOfWeek.Thursday) { BuyAtMarket(bar + 1, "Buy Thurs Morning"); } } } } } }