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 algospoke, 04-17-2024, 06:40 PM
        3 responses
        26 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by bmartz, 03-12-2024, 06:12 AM
        3 responses
        27 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by Aviram Y, Today, 05:29 AM
        2 responses
        8 views
        0 likes
        Last Post Aviram Y  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X