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 Waxavi, Today, 02:10 AM
        0 responses
        3 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        9 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Working...
        X