// This code constrains trading to only certain times during the day. #region Variables // Timed Trading Variables private int tt1_Start = 90000 ; // Start Time for first trading period private int tt1_End = 120000 ; // End Time for first trading period private int tt2_Start = 103000 ; // Start Time for second trading period private int tt2_End = 103000 ; // end Time for second trading period #endregion protected override void OnBarUpdate() { if ((ToTime(Time[0]) > TT1_Start && ToTime(Time[0]) < TT1_End ) || (ToTime(Time[0]) > TT2_Start && ToTime(Time[0]) < TT2_End ) && Position.MarketPosition == MarketPosition.Flat) { // Do Something Here } } #region Properties [Description("")] [Category("Parameters")] public int TT1_Start { get { return tt1_Start; } set { tt1_Start = Math.Max(000001, value); } } [Description("")] [Category("Parameters")] public int TT1_End { get { return tt1_End; } set { tt1_End = Math.Max(000001, value); } } [Description("")] [Category("Parameters")] public int TT2_Start { get { return tt2_Start; } set { tt2_Start = Math.Max(000001, value); } } [Description("")] [Category("Parameters")] public int TT2_End { get { return tt2_End; } set { tt2_End = Math.Max(000001, value); } } #endregion }
DaveN
Comment