Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Out of the last x bars mark bars with the same high/low

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

    #16
    Please use the following statement for drawing text:

    DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 2, High[2], 10, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #17
      Originally posted by ninZa View Post
      Please use the following statement for drawing text:
      Thanks,ninZa!

      Can you please suggest how to lift the message a bit?Please,consult the image attached.It seems that the message itself a little bit blurred,as well.

      Another thing is,i`m not sure how that gentleman intended to use all this,as with this combination:

      Code:
      if(Low[0] == Low[1] && Low[1] == Low[2] && Low[2] == Low[3] && Low[0] == Low[Math.Min(CurrentBar, 5)]) {
      DrawLine("high" + CurrentBar, false, 10, Low[0], -10, Low[0], Color.Black, DashStyle.Solid, 2);
      DrawText("txt" + CurrentBar, AutoScale, "3Bars Lows", 10, Low[2], 10, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
      }
      
      
      if(High[0] == High[1] && High[1] == High[2] && High[2] == High[3] && High[0] == High[Math.Min(CurrentBar, 5)]) {
      DrawLine("high" + CurrentBar, false, 10, High[0], -10, High[0], Color.Black, DashStyle.Solid, 2);
      DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 10, High[10], 10, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
      i only found one single occurrence over a month span,provided the Bar type is completely seamless, without any gaps
      Attached Files

      Comment


        #18
        Please change the red value to offset the text to a higher or lower place, depending on whether you set it positive or negative:

        DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 2, High[2], 30, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
        If you find it blurred, I think there are 4 or 5 bars of equal highs, so the indicator draw 2 or 3 texts very close to one another. If that's the case, I will help you handle this issue.

        Pi
        ninZa
        NinjaTrader Ecosystem Vendor - ninZa.co

        Comment


          #19
          Originally posted by ninZa View Post
          Please change the red value to offset the text to a higher or lower place, depending on whether you set it positive or negative:



          If you find it blurred, I think there are 4 or 5 bars of equal highs, so the indicator draw 2 or 3 texts very close to one another. If that's the case, I will help you handle this issue.

          Pi
          Yes,that`s the issue.It doubles/tripples the text.

          Comment


            #20
            Use this version outsource. You can adjust "minimumBars" to your preference.

            int lastBar; // last texted bar
            int minimumBars = 6; // 2 consecutive texts must be at least this number of bars apart


            protected override void OnBarUpdate() {
            if (CurrentBar < 2) return;

            if(High[0] == High[1] && High[1] == High[2] && CurrentBar - lastBar >= minimumBars) {
            lastBar = CurrentBar;
            DrawLine("high" + CurrentBar, false, 2, High[0], 0, High[0], Color.Black, DashStyle.Solid, 2);
            DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 2, High[2], 10, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
            }
            }
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment


              #21
              Originally posted by ninZa View Post
              Use this version outsource. You can adjust "minimumBars" to your preference.
              i get compiler error:

              Use of unassigned local variable 'lastBar'

              Comment


                #22
                Oh oh. Then plz try assigning lastBar to zero at its initiation.
                ninZa
                NinjaTrader Ecosystem Vendor - ninZa.co

                Comment


                  #23
                  Please declare lastBar outside OnBarUpdate as I showed above, outsource.
                  ninZa
                  NinjaTrader Ecosystem Vendor - ninZa.co

                  Comment


                    #24
                    Oops looks like the thread has taken off

                    I just want a solution that does the job.

                    If someone can post it all well and good.

                    There are 100s of much more complicated free indicators etc here and at Big Mike's.

                    If I cannot get it that way I will get someone to code it for me.

                    Comment


                      #25
                      A couple of questions,while we are at it,if you don`t mind.

                      1)what this bold statement are actually doing?

                      && CurrentBar - lastBar >= minimumBars) {
                      lastBar = CurrentBar;


                      How the calculation goes,in general,what is minimumBars,Currentbar - lastBar,etc...

                      2)Where do you get the extra furniture,that lacking in the default Ninja Guide you`ve added to the DrawText synthax?And it`s somehow under the ''drawarrowdown'',beside all that,but that`s cool

                      I outlined some of them.

                      Code:
                      DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 2, High[2], 30, Color.Black, [U]ChartControl.Font[/U], [U]StringAlignment.Near[/U], Color.Transparent, Color.Transparent, 0);

                      Comment


                        #26
                        Sorry skiguy, outsource asked and I answered :|

                        1. As I commented in the code, lastBar is the most recent bar where text is printed.
                        mimimumBars is the minimum number of bars between 2 texts. In the code I set it to 6, this means 2 consecutive texts must be at least 6 bars apart, so we won't have "blurred" effect due to double/triple texts.

                        2. The version of DrawText you used is a very simple one (that I have never used). I just use the standard version to draw text. You can learn more about it at: http://www.ninjatrader.com/support/h...l?drawtext.htm

                        Pi
                        ninZa
                        NinjaTrader Ecosystem Vendor - ninZa.co

                        Comment


                          #27
                          To Support

                          Maybe Support will figure it ,why the DrawText() chapter`s link is under the 'drawarrowdown' link??

                          Comment


                            #28
                            Originally posted by ninZa View Post
                            Sorry skiguy, outsource asked and I answered :|

                            1. As I commented in the code, lastBar is the most recent bar where text is printed.
                            mimimumBars is the minimum number of bars between 2 texts. In the code I set it to 6, this means 2 consecutive texts must be at least 6 bars apart, so we won't have "blurred" effect due to double/triple texts.

                            2. The version of DrawText you used is a very simple one (that I have never used). I just use the standard version to draw text. You can learn more about it at: http://www.ninjatrader.com/support/h...l?drawtext.htm

                            Pi
                            1.Got it.But is there a way to exclude those extra text?

                            2.This link you`ve posted,i`ve referred to,but re-directed to this link somehow:

                            And yet,i din`t see there those extra stuff you`ve added...Maybe some book on coding,that you can recommend to read?.....Anyways,thanks!Nice job!

                            Comment


                              #29
                              @Outsource I don't know what you mean. I don't see any redirect to drawarrowdown. Perhaps there is a browser issue on your end.

                              @skiguy Your project is not a straightforward one, if you want to code it yourself.
                              ninZa
                              NinjaTrader Ecosystem Vendor - ninZa.co

                              Comment


                                #30
                                Originally posted by outsource View Post
                                Maybe Support will figure it ,why the DrawText() chapter`s link is under the 'drawarrowdown' link??

                                http://www.ninjatrader.com/support/h...warrowdown.htm
                                NP.

                                Outsource can you take up your query in another thread or via PM to ninZa please.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by CarlTrading, 03-31-2026, 09:41 PM
                                1 response
                                149 views
                                1 like
                                Last Post NinjaTrader_ChelseaB  
                                Started by CarlTrading, 04-01-2026, 02:41 AM
                                0 responses
                                84 views
                                1 like
                                Last Post CarlTrading  
                                Started by CaptainJack, 03-31-2026, 11:44 PM
                                0 responses
                                129 views
                                2 likes
                                Last Post CaptainJack  
                                Started by CarlTrading, 03-30-2026, 11:51 AM
                                0 responses
                                125 views
                                1 like
                                Last Post CarlTrading  
                                Started by CarlTrading, 03-30-2026, 11:48 AM
                                0 responses
                                102 views
                                0 likes
                                Last Post CarlTrading  
                                Working...
                                X