Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

time equals time is not working

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

    time equals time is not working

    I am having an issue that comparing 2 Times that are equal. It will not go into my if Statement.,






    dStartTime = this.drawList[nIndex+1].Time;
    tCheckMinuteBefore = dStartTime.AddMinutes(-1*tChartTimeFrameInMinutes);
    tOneBarBeforeTime = this.drawList[nIndex+1].Time.AddMinutes(-1*tChartTimeFrameInMinutes);


    tOneBarAfterTime = this.drawList[nIndex].Time.AddMinutes(1*tChartTimeFrameInMinutes)


    Print("dStartTime = " + dStartTime);
    Print("one minute before " + tOneBarBeforeTime);
    Print("one minute After Time " + tOneBarAfterTime);
    Print(tCheckMinuteBefore + "Check one minute before time");
    Print("The time is now " + Time[0]);




    if (tCheckMinuteBefore == Time[0])
    {
    Print("in the if statement of 1 minute before time");
    Print("pattern 45 is set to false");
    Print("Pattern 67 is set to false");
    bPattern45Found = false;
    bPattern67Found = false;
    }


    the results as you can see it never goes through this statement of IF
    if (tCheckMinuteBefore == Time[0])


    dStartTime = 2017-12-01 6:31:00 AM
    one minute before 2017-12-01 6:30:00 AM
    one minute After Time 2017-12-01 6:23:00 AM
    2017-12-01 6:30:00 AMCheck one minute before time
    The time is now 2017-12-01 6:29:00 AM


    dStartTime = 2017-12-01 6:31:00 AM
    one minute before 2017-12-01 6:30:00 AM
    one minute After Time 2017-12-01 6:23:00 AM
    2017-12-01 6:30:00 AMCheck one minute before time
    The time is now 2017-12-01 6:30:00 AM

    dStartTime = 2017-12-01 6:31:00 AM
    one minute before 2017-12-01 6:30:00 AM
    one minute After Time 2017-12-01 6:23:00 AM
    2017-12-01 6:30:00 AMCheck one minute before time
    The time is now 2017-12-01 6:31:00 AM


    how do you compare the times

    #2
    Hello,

    Thank you for the post.

    I was able to get this to work on my end with a similar test script. Could you please run the attached script on your end to see if it works? This could have something to do with AddMinutes.

    I look forward to your reply.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I have done this tonnes of times but for some reason I had to do this

      Convert.ToDateTime(this.drawList[nIndex+1].Time);

      the irony is this.drawList[nIndex+1].Time is already a datetime format

      Comment


        #4
        Hello,

        Thank you for the follow-up. I'm glad you were able to find the issue.

        Is there anything else I can assist you with?
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        4 responses
        3,281 views
        1 like
        Last Post jgualdronc  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        5 views
        0 likes
        Last Post Option Whisperer  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        8 responses
        58 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        22 views
        0 likes
        Last Post halgo_boulder  
        Started by mishhh, 05-25-2010, 08:54 AM
        19 responses
        6,189 views
        0 likes
        Last Post rene69851  
        Working...
        X