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

Specify any time days ago

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

    Specify any time days ago

    I would like to get the price for a specified any time on yesterday. For example. Now it is 10:40AM Friay. I would like to get 3:00 price for 3:00 PM yesterday.

    I find a similar one but not exactly what i need. Here is the one to get the same time for yesterday: GetBar(Time[0].AddDays(-1)). Any way to change that so it can get a time yesterday that is not the same as today?

    Thanks.

    #2
    You need to just tell it which time you want. If you are using Time[0] you are looking at the current bar's timestamp.

    Create yourself a new DateTime object.
    GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day - 1, hour, minute, second));

    hour, minute, and second are ints.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      removing all drawobjects on all days prior to yesterdays first bar.

      hello i want to remove all drawobjects on all days prior to yesterdays first bar.
      how would i have to create such a statement

      if yesterday
      is this the statement for yesterday:?
      (ToTime(Time[0]) == GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day - 1, hour, minute, second));

      && firstbarofsession

      RemoveDrawObjects()


      Originally posted by NinjaTrader_Josh View Post
      You need to just tell it which time you want. If you are using Time[0] you are looking at the current bar's timestamp.

      Create yourself a new DateTime object.
      GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day - 1, hour, minute, second));

      hour, minute, and second are ints.

      Comment


        #4
        That would not work. You are no longer processing those old bars so your condition will not evaluate to true.

        You need to decide a point in time which you want to clear out the old draw objects. Then you need to loop through all the old ones and clear them out.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        6 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,235 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        3 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        7 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,415 views
        0 likes
        Last Post Traderontheroad  
        Working...
        X