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

Negative parameters and reversing data series

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

    Negative parameters and reversing data series

    Hi

    Thanks again to Jesse at NT Support for helping me solve the technical problem in opening NT, for which I started a thread at:



    What obviously caused the problem (as Jesse suspected) was one of my indicators that included this code:

    Code:
    int dist = 0;
                
                if (CurrentBar < LookBack)
                            return;
                
    for (int i = -1; i < LookBack; i--)
                {
                    if(MAX(High, i)[-1] < High[0])
                    { continue; }
                
                    else
                        dist = i;
                        break;
                }
                
                Plot0.Set(dist);
            }
    For positive parameters and arguments, this works absolutely fine to find the number of bars to the previous bar at the same level. (This code is specially designed to work with up Renko bars and this is not the only way to achieve this: I’ve got the same results using a fairly simple ‘while loop’.)

    What I’m (fairly obviously) trying to achieve with the above code and the negative arguments is to find the number of bars to the next bar at the same level (if there is one).

    Overall, I'm trying to find where every bar stands in relation to the adjacent bars at the same level.

    One way this might be achieved is to reverse the data series – if this is possible. Then when working on that, what is the ‘future’ in a normal series, becomes the ‘past’. I’ve tried hard to achieve this using various C# resources but haven’t got anywhere.

    So any advice on how got the idea to work and/or how to reverse a data series will be much appreciated.

    #2
    Hello arbuthnot,

    Thank you for your post.

    I will follow up with you here shortly on this item.

    Comment


      #3
      Hello arbuthnot,

      Thank you for your patience.

      To clarify you are wanting to look to the right of the bar for future Highs form the bar being processed?

      Comment


        #4
        Thanks very much, Patrick.

        It's getting very late here across the Pond so I'm hoping to reply properly tomorrow.

        Just to say now that I'm working on a method of enumerating and categorizing 'price action' over previous bars.

        I'm not making much sense (it's 11.30pm here) so I'll leave it till tomorrow.

        Cheers.

        Comment


          #5
          Hi again Patrick

          If you would be so kind as to open the image with this post where I’ve tried to illustrate what I’m trying to achieve.

          Using the code I gave in my initial post (using of course, only positive parameters and arguments), I can find the number of bars back to the previous bar at the same level. This can of course be done up to the most recent bar. In the illustration, the bar in question has a ‘back’ quantity of 25.

          What I want to find – obviously for historical bars only – is to find the ‘forward’ quantity (here, 18). This explains why I was using negative figures – and why my system must have crashed!

          In trying to get the ‘forward’ quantity, I would of course need to exclude (not done in my code below) the most recent bars. So I would need to add some code, such as, for example:

          Code:
          if (CurrentBar > Count - 10)
                          return;
          if I wanted to exclude the ten most recent bars.

          If I have to give up the use of negative arguments, then I might be able to achieve this if I could somehow reverse the data series. Indeed, C# can reverse a list as in:

          Code:
          List<T>.Reverse()
          which I’ve found online, but I don’t know how to apply this to a data series in NinjaScript.

          The reason for this exercise is because, with the parameters such as those for the bar illustrated (25, 18), and comparing them with bars in the same 'neighborhood', I think I can find useful information about where I can have the system draw a sort of pivot line, different from the types currently used.

          Patrick, if you any ideas at all about how I can make progress with this, I’d be most grateful.
          Attached Files

          Comment


            #6
            Hello arbuthnot,

            Thank you for your response.

            There is unfortunately, no way to calculate in the future. However, the Swing indicator in NinjaTrader can be used as an example of checking for a value over the last n bars as well as for the next n bars. You can find the Swing indicator in your NinjaTrader under Tools > Edit NinjaScript > Indicator.

            Comment


              #7
              Thanks very much, Patrick for your reply and your tip about the Swing indicator.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Working...
              X