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

Why no Get in IDataSeries as in DataSeries?

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

    Why no Get in IDataSeries as in DataSeries?

    My strategy requires a lot of looping backward and forward and some of the internal structures requiring using 'absolute' bar # as indices, instead of the 'anchored at the currentbar with BarAgo' style.

    I've noticed in DataSeries there's this Get method that's the 'normal array reference' style instead of the 'BarAgo' style.

    However, the pricing OHLC are of IDataSeries with [BarAgo] style of reference.

    I know I can always switch from i to say CurrentBar-i, but this inconsistency makes my head hurt while programming, let along debugging.

    It seems to be IDataSeries to support Get is no big deal at all, why is it not?

    Any other suggestion to reduce my pain?

    #2
    Hello balancenv,

    I believe you are referring to the GetBar() method.

    While I cannot speak as to the exact reason why it was designed this way, I would imagine it would be for simplicity for coding as the current values "[0]" would be more widely used as the current values can be referenced with ease. Historical values are important as well but it would be much easier references how many bars ago since from the current instead of incrementally counting as the bars go on making it much more difficult to know what bar the current bar is.

    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      GetBar() won't work since it's based on time, not bar index.
      Well, still, please take this as a simple request for future release for IDataSeries to support the equilivant Get() method as in DataSeries.
      Thanks.

      Comment


        #4
        Hello balancenv,
        Unfortunately there are not GetBar function for a data series.

        You may look into the MRO and LRO functions as an alternative. Please refer to our help guide to know more about it.


        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Joydeep,
          you mis-understood my point.
          I want a direct index access to IDataSeries's element, similar to DataSeries.Get() method.

          Comment


            #6
            Hello balancenv,
            Thanks for the clarification.

            You can try using the below unsupported code to do it.
            Code:
            double cls  = Bars.GetClose(index);
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Joydeep View Post
              Hello balancenv,
              Thanks for the clarification.

              You can try using the below unsupported code to do it.
              Code:
              double cls  = Bars.GetClose(index);
              Can we always assume

              bars.GetClose(idx) is the same as Close[CurrentBar-idx]

              Comment


                #8
                Hello balancenv,
                Yes, they will return the same values.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by balancenv View Post
                  Can we always assume

                  bars.GetClose(idx) is the same as Close[CurrentBar-idx]
                  A mistake. If you need to get the last bar this way , it must be
                  Code:
                  bars.GetClose(CurrentBar)
                  not GetClose(0) . Checked in NT7 7.0.1000.25

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  166 responses
                  2,234 views
                  0 likes
                  Last Post sidlercom80  
                  Started by thread, Yesterday, 11:58 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post thread
                  by thread
                   
                  Started by jclose, Yesterday, 09:37 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post jclose
                  by jclose
                   
                  Started by WeyldFalcon, 08-07-2020, 06:13 AM
                  10 responses
                  1,414 views
                  0 likes
                  Last Post Traderontheroad  
                  Started by firefoxforum12, Yesterday, 08:53 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post firefoxforum12  
                  Working...
                  X