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 AttiM, 02-14-2024, 05:20 PM
        12 responses
        213 views
        0 likes
        Last Post DrakeiJosh  
        Started by cre8able, 02-11-2023, 05:43 PM
        3 responses
        238 views
        0 likes
        Last Post rhubear
        by rhubear
         
        Started by frslvr, 04-11-2024, 07:26 AM
        8 responses
        117 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        10 responses
        47 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by rocketman7, Today, 09:41 AM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X