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

Dataseries containing selected members of another dataseries

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

    #16
    Hello bkool,

    Thank you for your reply.

    I'm not quite certain what you're trying to achieve here:

    bM1Close = Closes[10][myBarsAgoValue];
    bM2Close = Closes[10][myBarsAgoValue];

    Closes[10][myBarsAgoValue] would give you the Close price of a 10th additional data series at a index equal to the value of myBarsAgo value. Is this intentional?

    Also, CurrentBars[10] would give you the current bar number of the 10th dataseries. I am also unsure if this is intentional.

    Please clarify if possible; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #17
      Hi Kate W.

      thank for your question.
      Everything mentioned above is intentional and works fine.
      What I need is to relate between current & several previous Closes[10] [x] values, as NT works with data series, where x = 0 for the current Close, x= 1 for the previous one, etc.
      So I guess myBarsAgoValue should act as data series holding accessible index values.
      Hope I made my point clear.


      Comment


        #18
        Hello bkool,

        Thank you for your reply.

        Ah, I follow now, I just needed to look back on what we discussed last week.

        CurrentBars[10] is just going to hold the bar number of the most recent bar in the 10th data series, so that's why it prints out the same every time you loop through the loop - you haven't gone to a different bar yet.

        So, trueBarIndexes already is holding the bar number of each bar for which either signal 1 or signal 2 was true. So let's say I want to access the close of the 5th time ago that this was true and compare it to the close of the 10th time ago that this was true.

        I could do something like this:

        if(Closes[10][CurrentBars[10] - trueBarIndexes[4] ] > Closes[10][CurrentBars[10] - trueBarIndexes[9]])
        {
        //do something here
        }

        Please let us know if we may be of further assistance to you.

        Kate W.NinjaTrader Customer Service

        Comment


          #19
          Thanks Kate W.
          Yes, this is the type of relations I'm looking for. it seems that since trueBarIndex is holding all the correct values, it just needs proper indexing...

          best.

          Comment


            #20
            Hello Kate w.

            Could you please suggest a way to solve that ?

            Comment


              #21
              Hello bkool,

              Thank you for your reply.

              I'm not sure what you are referring to solving. This previous post below already demonstrated how you can retrieve the values you seek for each bar for which either signal 1 or signal 2 was true. Please clarify.

              Originally posted by NinjaTrader_Kate View Post
              Hello bkool,

              Thank you for your reply.

              Ah, I follow now, I just needed to look back on what we discussed last week.

              CurrentBars[10] is just going to hold the bar number of the most recent bar in the 10th data series, so that's why it prints out the same every time you loop through the loop - you haven't gone to a different bar yet.

              So, trueBarIndexes already is holding the bar number of each bar for which either signal 1 or signal 2 was true. So let's say I want to access the close of the 5th time ago that this was true and compare it to the close of the 10th time ago that this was true.

              I could do something like this:

              if(Closes[10][CurrentBars[10] - trueBarIndexes[4] ] > Closes[10][CurrentBars[10] - trueBarIndexes[9]])
              {
              //do something here
              }

              Please let us know if we may be of further assistance to you.
              Kate W.NinjaTrader Customer Service

              Comment


                #22
                Hello Kate W.,

                Sorry, I couldn't have the above solution working for me.
                I always get an error message: "You are accessing an index with a value that is invalid since its out of range".
                Could you please show me the code used for testing so I can reproduce this ?

                Thanks, bkool
                Last edited by bkool; 07-14-2019, 01:22 AM.

                Comment


                  #23
                  Hello bkool,

                  Thank you for your reply.

                  The error you're receiving is due to trying to access something in one of those arrays that doesn't exist (the index is out of range). I think you're probably running into issues with having multiple data series. Are you adding items to the trueBarIndexes list from all of the data series? If so, you could well be trying to access a bar number that doesn't exist for a certain bar series because it was added when another bar series was processing. Can you provide a reduced version of your strategy that illustrates the behavior you're seeing?

                  Thanks in advance; I look forward to assisting you further.
                  Kate W.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by funk10101, Today, 09:43 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post funk10101  
                  Started by pkefal, 04-11-2024, 07:39 AM
                  11 responses
                  37 views
                  0 likes
                  Last Post jeronymite  
                  Started by bill2023, Yesterday, 08:51 AM
                  8 responses
                  44 views
                  0 likes
                  Last Post bill2023  
                  Started by yertle, Today, 08:38 AM
                  6 responses
                  26 views
                  0 likes
                  Last Post ryjoga
                  by ryjoga
                   
                  Started by algospoke, Yesterday, 06:40 PM
                  2 responses
                  24 views
                  0 likes
                  Last Post algospoke  
                  Working...
                  X