stock777 Posted May 2, 2018 Report Share Posted May 2, 2018 I see you don't expose bar time in the simple editor ( as far as I can tell) , so I'm trying to get the TIMESTAMP variable to work , but not being a C programmer, and there being few examples here, I'm running into brick walls. I know this is simple. Need to compare bar time to a fixed time or range of times. Don't need date. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted May 2, 2018 Report Share Posted May 2, 2018 It would have to be done in Advanced mode. The variable is Timestamp, and it is a UTC DateTime of the beginning of the current candle. There are also session variables that are also DateTime. You do a GetTradingSessionInfo call, which would return a TradingSessionInfo structure. So - this is how you would check if you're half an hour or more into current session: var SessionInfo = GetTradingSessionInfo(Timestamp); if (Timestamp>SessionInfo.SessionStart.AddMinutes(30) && Timestamp<SessionInfo.SessionEnd) { // do something } Quote Link to comment Share on other sites More sharing options...
stock777 Posted May 2, 2018 Author Report Share Posted May 2, 2018 Right, I knew I needed advanced. I'm confused as to the format of how to compare timestamp to a specific time of day. IF (timestamp > 9:00 ) do something I tried something that and was getting errors but not enough info to know what was wrong. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted May 2, 2018 Report Share Posted May 2, 2018 As I said, the Timestamp is a UTC time. Which means that with daylight savings time, it floats, sometimes one hour up, sometimes one hour down. The easiest thing is to compare it to the session parameters as I showed. You can compare to absolute, would have to be something like if (Timestamp.TimeOfDay > new TimeSpan(9-5, 0, 0)) // since 5 hours is the current difference between UTC and CST. Adjust it as you like for other time zones ; // do something Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.