I am writing my first FX scalping model, but I am having trouble setting up trading times.  I want the model to trade between 8am est and 12pm only.  I see there is a scheduler method, but fail to see how it works for time intervals.  I wrote a static method for calculating time, but it seems to be only for working with system time rather than backtesting time.  How do I access those variable.  Below is what I was working with.  Help would be appreciated!

 

        public static bool isTradeTime() {
            /*
            Only trade from 8am to 12 est
            */
            TimeSpan start = new TimeSpan(8, 0, 0);
            TimeSpan end = new TimeSpan(12, 0, 0);
            TimeSpan now = DateTime.Now.TimeOfDay;
            if ((now > start) && (now < end)) {
                return true;
            }
            return false;
        }

Author