Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reset variables at specific time using DateTime now

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Reset variables at specific time using DateTime now

    Hi,

    I have a problem with the following code and was wondering why it may not be working.

    In the variables section I have;
    TimeSpan sessionReset = new TimeSpan(00,55,00);

    In OnMarketData
    DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now);

    if(now.TimeOfDay == sessionReset)
    {
    //Reset Variables
    }

    Regards,
    suprsnipes

    P.S. Just noticed when using
    Print(now.TimeOfDay + " " + sessionReset);

    The now.TimeOfDay includes milliseconds, would this be causing issues?
    Last edited by suprsnipes; 09-10-2014, 01:49 AM. Reason: Added more information

    #2
    That's correct suprsnipes, would not expect that to trigger. I would define your reset simply as int

    private int sessionReset = 05500;

    ...and then use as compare

    if(ToTime(now) == sessionReset)
    {
    do your reset stuff
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    173 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    90 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    129 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    208 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    186 views
    0 likes
    Last Post CarlTrading  
    Working...
    X