Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to express a fixed time?

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

    how to express a fixed time?

    Dear Support Team,
    Say, I want to long at 1:30pm and exist at 1:45pm. How to express this strategy?

    #2
    hl685,

    What you can do is check the timestamps of the bars. When the timestamp of the bar is of the time you want to exit, then place in your exit.

    Untested code to give you an idea.
    Code:
    if (ToTime(Time[0]) == 133000)
         EnterLong();
    else if (ToTime(Time[0]) == 134500)
         ExitLong();
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks! Could you also let me know how to get the price at a certain time, say, it's 1:30pm now, I need the price for 1:15pm, or just 15 minutes agao?

      Comment


        #4
        If you are using 1 min charts you can just use Close[15] to go back to the time you want.

        Otherwise you will need to use GetBar() to determine what [] index value you should pass in to get the bar you want.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thank you very much!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          656 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          371 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          579 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X