I think Bars.MarketInfo was null due to the security I was using not the day of week, or time, I was doing the test. I got a null reference when I backtested symbol 'QQQQ' whereas symbol 'ADM' worked fine.
Initially I was using this calculation as the following:
CODE:
Please log in to see this code.
Mainly I was looking for a starting point for my loop when I had a combination of intraday bars and daily bars.
Cone, Bars.IntradayBarNumber will only give me the current bar number. I want to know how many bars for the current day. I'd like to have a test to get me the current bar number and then test how close that bar is to closing.
I've been trying to figure out what a good technique is to test for the last hour of the day. I may want to do special trading at the end of the day (but not SellAtClose). For example, SellAtLimit until the last hour of closing, and then switch to SellAtStop in case the last hour is going up, but then SellAtMarket in the last couple of bars.
If I know the closing time, I could use Date[bar].TimeOfDay to test against Bars.MarketInfo.CloseTimeNative.TimeOfDay. For example, action in the last 15 minutes of trading:
CODE:
Please log in to see this code.
These were just some ideas; however, Bars.MarketInfo doesn't appear to be the right variable to accomplish special trading at end of day at the moment.