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

Best way to compare different dates

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

    Best way to compare different dates

    Hi there

    I'm running into problems trying to see if two different dates are equal. I am unsure whether to to use integers from DateTime or GetBar from Bars. I'm completely confused at this point because I don't know the bar time of the first or second bar.

    For example:

    DateTime mytemp = DateTime.Today;
    int day = mytemp.Day;

    This returns an integer representing the date from today but if its not from Today then I'm stuck. I need to get the date from the bar without knowing the time. I know its Low[1] and Low[2] but Low[1] is static while Low[1] moves along with price action.

    I apolopize for making this sound more complicated than it is.

    Thx
    Irvin

    #2
    Hello,

    Thanks for the forum post.

    You do not need to use DateTime at all. Each bar has a time stamp just like it has a Low price as you pointed out.

    Time[0] is the current bars date time.

    Time[1] is the previous bars date time.

    Etc. etc.

    Its important to understand the Time[0] will ALWAYS be the current bar. You add to 0 to go back bars this is the same for Low as well.

    Low[15] is the low price of 16 bars ago. I say 16 as 0 is the current bar.

    -Brett

    Comment


      #3

      Comment


        #4
        Hello Brett,
        There is a one-minute bar chart running,and,an Indicator is running in under panel.
        When I click 5-minute bar chart from menu,the chart is refreshed.
        There is a Question:
        Is a new Indicator Created?If it is,what if I then click back 1-minute bar chart?
        If I click back and fro,Are there more and more Indicators created?
        Of course these bar charts are all running real time.

        Yours truly.

        Comment


          #5
          Hello,

          Thanks for the forum post.

          If I understand fully clicking back and forth between charts do not create indicator. The indicators will run int eh background it is the same indicator when you added it to the chart.

          It is ok to click back and forth between charts no problem you also will not lose any data doing this.

          -Brett

          Comment


            #6
            Thank you Brett,
            I have an Indicator already that calculates recent price level,eg.
            then,I want another to do more functions,
            can I inherit from the first indicator when creating new one,or I must copy codes from 1st.
            The Question is:
            Is Class inheritage for Indicator possible?
            Thank you.
            Yours truely.

            Comment


              #7
              I would recommend copying the code in this case.

              -Brett

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by michi08, 10-05-2018, 09:31 AM
              3 responses
              740 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by sightcareclickhere, Today, 01:55 PM
              0 responses
              1 view
              0 likes
              Last Post sightcareclickhere  
              Started by Mindset, 05-06-2023, 09:03 PM
              9 responses
              258 views
              0 likes
              Last Post ender_wiggum  
              Started by Mizzouman1, Today, 07:35 AM
              4 responses
              18 views
              0 likes
              Last Post Mizzouman1  
              Started by philmg, Today, 01:17 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Working...
              X