Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Replay Data Connection - isseus with bar date time comparsion

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

    Replay Data Connection - isseus with bar date time comparsion

    I use the following to determine if we "cantrade" in bars_update - if not go flat - it appears to work fine in all test tick, back test, sim and live - but in a replay connection for the nasdaq 5 minute - it returns true instead of false... i think i need to set the default to false and on error set it to false then analys the log again....

    Apart from that does this look a reasonable approach to only trading at a specified time?


    int sessionStartHour=8
    int sessionStartMinute=0
    int sessionEndHour=16
    int sessionEndMinute=0
    int sessionMode=1
    int Weekends=0

    privatebool InValidSession()
    {
    //Print("InValidSession");
    bool result = true;
    try
    {
    if ((Weekends == 0) && (Time[0].DayOfWeek == DayOfWeek.Saturday || Time[0].DayOfWeek == DayOfWeek.Sunday))
    {
    result =
    false;
    }
    int TimeNow = ToTime(Time[0].Hour, Time[0].Minute, Time[0].Second);
    if (result && sessionMode == 1)
    {
    timeStart = ToTime(sessionStartHour, sessionStartMinute,
    0);
    timeEnd = ToTime(sessionEndHour, sessionEndMinute,
    0);
    result = (TimeNow >= timeStart) && (TimeNow <= timeEnd);
    }
    }
    catch (Exception ex)
    {
    Log(ex.ToString(), LogLevel.Error);
    }
     
    return result;
    }
    Last edited by MicroTrends; 12-29-2009, 03:58 PM.
    MicroTrends
    NinjaTrader Ecosystem Vendor - micro-trends.co.uk

    #2
    Someone will follow up on this post tomorrow.
    RayNinjaTrader Customer Service

    Comment


      #3
      MicroTrends, will attempt to reproduce on latest beta and get back to you - this is a reasonable approach if the bar granularity is fine enough meet all your 'trade time' conditions / comparisons.

      Comment


        #4
        MicroTrends, tested this and it would always be 'false' throughout the week, as you never set it to 'ok to trade' on weekdays -

        if (Time[0].DayOfWeek == DayOfWeek.Saturday || Time[0].DayOfWeek == DayOfWeek.Sunday)
        {
        result =
        false;
        }

        else result = true;

        Then you could proceed with checking for correct intraday trading times to be present.

        Comment


          #5
          Hi

          The weekends bit works fine - if weekends=0 then it only trades during the weekdays - that bit is fine -

          The logic is:

          on barsupdate.....
          if (!InValidSession) {
          canceltrades();
          ...
          return;

          }
          ....


          The issue was that the datetime comparisaion did not work when 5 minute data was used but it did when using tick data on the replay connection. All other data connections were fine simulator, backtest.

          E.G The session was meant to be between 9 and 18Pm but it went past 18PM

          many thanks
          MicroTrends
          NinjaTrader Ecosystem Vendor - micro-trends.co.uk

          Comment


            #6
            Hi MicroTrends - thanks for the reply and clarification, sorry I did not follow, will retest thanks.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            580 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            335 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            102 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X