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 stafe, 04-15-2024, 08:34 PM
        6 responses
        31 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by adeelshahzad, Today, 03:54 AM
        4 responses
        26 views
        0 likes
        Last Post adeelshahzad  
        Started by merzo, 06-25-2023, 02:19 AM
        10 responses
        823 views
        1 like
        Last Post NinjaTrader_ChristopherJ  
        Started by frankthearm, Today, 09:08 AM
        5 responses
        17 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        43 views
        0 likes
        Last Post jeronymite  
        Working...
        X