Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Higher Hi's code question

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

    Higher Hi's code question

    I am trying to get a code that checks for x higher hi's in a row.
    I tried the code below but it did not work. I'm not sure why it looks fine to me.....

    The idea here is that on each new bar, it checks for whether the high of this bar was higher than the high of the last bar, and continues checking this for the last x bars (hence int i increases from o to 1 less than x and it runs the High check and if the High check is true it adds to count)


    protected override void OnBarUpdate()
    {
    int count = 0;

    for (int i = 0; i < x; i++)
    {
    if (High[i] >= High[i+1]) {count ++;};
    }
    if ( count >= x) {isHH = true; count = 0;}
    else {isHH = false; }

    if (isHH)
    { EnterLong(DefaultQuantity, "");}


    Can anyone offer some help with this .... I would normally debug this kind of code in VisualStudio but I dunno if it's possible at all to debug NT code (anyone know how to do this?)

    Thanks!

    #2
    Hello,

    You state:
    >>I am trying to get a code that checks for x higher hi's in a row.

    By "in a row" do you mean consecutive? Or are you looking for the "first" x number of higher highs?

    Let me know and I will assist you with the code for this.
    DenNinjaTrader Customer Service

    Comment


      #3
      Ben,

      Yup I mean consecutive. As soon as the consecutive series breaks, it should return false

      I.e if you have 100, 101, 102, 103 that is 3 consecutive higher hi's so we have isHH = true
      now if the series continues 100, 101, 102, 103, 102, then you no longer have 3 consectuvie higher hi's, so isHH should now return false.

      if the series continues further 100, 101, 102, 103, 102, 103, 104, 105, then isHH should return true again.



      Thanks for your help!

      Comment


        #4
        Hello,

        I am sorry this is still not completely clear to me. Are you trying to trade if there has been 3 consectutive higher highs?

        If so try this:
        if (High[0] > High[1] && High[1] > High[2] && High[2] > High[3])
        isHH = true;

        If not, please provide the entire context in which you are using this.
        DenNinjaTrader Customer Service

        Comment


          #5
          Ben,

          I think he might be looking for BoolSeries.

          if(High[0] > High[1])
          BoolSeries.Set(true)
          else
          BoolSeries.Set(false)

          He than then do a check for false to "Do Something"

          Comment


            #6
            Yes you are exactly right, that is what I am trying to emulate.

            The reason why I cannot simply just use that code is because I will need to add other operations to it to get my final code (such as calculating the difference between each bar and then having a rolling sum of the difference etc)

            I am trying to get the simple stuff working first and then add on to it : )

            Comment


              #7
              coolraz,

              Then you may need to add multiple DataSeries to the indicator such as the difference between the highs. You can then do SMA(DataSeries, 20). Then bring it all together be checking the DataSeries and BoolSeries on the same bar to trigger action. With the robustness of NT all this can be done but take it one step at time with each Series acting independently and checking the OutPut Window for accuracy on each.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              582 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              338 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              552 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X