Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

8.1.3.1 64-bit Al Brooks Bar Number indicator mod request

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

    8.1.3.1 64-bit Al Brooks Bar Number indicator mod request

    559614828451392015.zip
    the attached file will plot a number under odd numbered bars. It seems to work fine and am looking to enhance it by offering a red colored font for the following bar numbers:
    11,23,35,47,63,71

    this would be shared with the forum



    Attached Files

    #2
    Hello duck_CA,

    Thank you for your post.

    If you already know exactly which numbers you want to change the color for, you can simply detect if the _barCntr variable is equal to these numbers and if so, call Draw.Text() with textBrush set to Brushes.Red.



    Please let us know if you have any further questions.

    Comment


      #3
      can you point me to someone who can code this properly ?

      Comment


        #4
        Hello duck_CA,

        You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!
        Programming Services - https://ninjatraderecosystem.com/sea...mming-services
        Educators - https://ninjatraderecosystem.com/sea...ures=education

        You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.

        This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.​
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          is there a more efficient way to write this?

          if (_barCntr == 12)
          Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);
          if (_barCntr == 18)
          Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Blue ,myFont, TextAlignment.Center, null, null, 1);
          if (_barCntr == 24)
          Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);
          if (_barCntr == 36)
          Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);
          if (_barCntr == 48)
          Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);

          Comment


            #6
            Hello duck_CA,

            I'm not aware of a better way to write that - this thread will remain open if any members of the community have a recommendation however.

            Comment


              #7
              Originally posted by duck_CA View Post
              is there a more efficient way to write this?

              if (_barCntr == 12)
              Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);
              if (_barCntr == 18)
              Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Blue ,myFont, TextAlignment.Center, null, null, 1);
              if (_barCntr == 24)
              Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);
              if (_barCntr == 36)
              Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);
              if (_barCntr == 48)
              Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);
              See if this works, same but shorter:

              if (_barCntr == 12 || _barCntr == 18 || _barCntr == 24 || ..... etc.)

              Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);

              else
              Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Blue ,myFont, TextAlignment.Center, null, null, 1);
              Last edited by aligator; 09-10-2024, 03:01 PM.

              Comment


                #8
                Originally posted by aligator View Post

                See if this works, same but shorter:

                if (_barCntr == 12 || _barCntr == 18 || _barCntr == 24 || ..... etc.)

                Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Red ,myFont, TextAlignment.Center, null, null, 1);

                else
                Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar,Brushes.Blue ,myFont, TextAlignment.Center, null, null, 1);
                that seemed to work, thank you for that.

                any ideas on how to label the first bar and every 3rd bar one color, then keep the work you did?

                so example would be bars 1,3,6,9,...81 gray, then color bars 12,24,36,48,60,72 red, then finally bar 18 is blue

                Comment


                  #9
                  Originally posted by duck_CA View Post

                  that seemed to work, thank you for that.

                  any ideas on how to label the first bar and every 3rd bar one color, then keep the work you did?

                  so example would be bars 1,3,6,9,...81 gray, then color bars 12,24,36,48,60,72 red, then finally bar 18 is blue

                  Doubtful using Switch any more efficient,
                  But possibly easier to Read and Maintain!
                  Code:
                  //Add a Private Stroke Variable to use for Dynamic Bar Text Coloring
                  private Stroke cBar = new Stroke(Brushes.Transparent, DashStyleHelper.Solid, 1);
                  //Add a Private Bool Variable for Conditional Drawing of Text
                  private bool isDraw = false;
                              
                  //Add Public Stroke Properties for All Colors (Stroke Easier than Brush!)
                  [Display(Name = "Color1", GroupName = "BarColors", Order = 0)]
                  public Stroke Color1 { get; set; }  
                  
                  [Display(Name = "Color2", GroupName = "BarColors", Order = 1)]
                  public Stroke Color2 { get; set; }  
                  
                  [Display(Name = "Color3", GroupName = "BarColors", Order = 2)]
                  public Stroke Color3 { get; set; }  
                              
                  //In State.Default Initialize (Set) All Strokes (Colors)
                  Color1    = new Stroke(Brushes.Gray, DashStyleHelper.Solid, 1);
                  Color2    = new Stroke(Brushes.Red, DashStyleHelper.Solid, 1);
                  Color3    = new Stroke(Brushes.Blue, DashStyleHelper.Solid, 1);
                  
                  //In OnBarUpdate, Use Switch to ReSet isDraw Condition OR Set Draw Color
                  isDraw = true;
                  switch (barCount)
                  {
                      case 1:
                              cBar = Color1.Clone(); //Gray
                          break;
                      case 12:
                      case 24:
                      case 36:
                      case 48:
                      case 60:
                      case 72:
                              cBar = Color2.Clone(); //Red
                          break;
                      case 18:
                              cBar = Color3.Clone(); //Blue
                          break;
                      default:
                              //If No Case Meet | Check if 3rd Bar | Color & Draw or Not
                              if(barCount % 3 == 0) cBar = Color1.Clone(); //Gray
                              else isDraw = false; //Do Not Draw
                          break;
                  }
                  
                  //Use Dynamic cBar.Brush set above for Drawing Text Color
                  if(isDraw) Draw.Text(this, CurrentBar.ToString(), true, _barCntr.ToString(), 0, _textYStartingPoint, _pixelsAboveBelowBar, cBar.Brush, myFont, TextAlignment.Center, null, null, 1);
                  This is untested and might need small tweaks,
                  but should give you idea of alternative way.


                  .
                  Be Safe in this Crazy World!


                  -=Edge=-
                  NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  592 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  343 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
                  556 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  554 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X