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 RubenCazorla, Today, 09:07 AM
        2 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by i019945nj, 12-14-2023, 06:41 AM
        7 responses
        81 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by timmbbo, 07-05-2023, 10:21 PM
        4 responses
        158 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by tkaboris, Today, 08:01 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Lumbeezl, 01-11-2022, 06:50 PM
        31 responses
        819 views
        1 like
        Last Post NinjaTrader_Adrian  
        Working...
        X