Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing programmatically the border with of text objects

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

    Changing programmatically the border with of text objects

    Hi!

    Given some conditions, I've written an indicator drawing text above or below the candles. To do this, I used this syntax for Draw.Text():
    Code:
    Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)
    It works like a charm. The problem is that the border thickness is set automatically to 2 px. Is it possible to put it to 1 px from within the indicator's code?

    #2
    Hello Gianpiero,

    Assign to a variable and set the OutlineStroke property.
    Code:
    NinjaTrader.NinjaScript.DrawingTools.Text myText = Draw.Text(this, "tag1", "Text to draw", 10, High[10] + (5 * TickSize), Brushes.Black);
    myText.OutlineStroke.Width = 1;
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Thank you for your quick answer. Since this need is repetitive, I want to wrap this code into a function. How would you suggest I do that? I was thinking something like this:
      Code:
      public void myFunction(string alpha, int offset)
      {
          NinjaTrader.NinjaScript.DrawingTools.Text myText = Draw.Text(this, "tag1", alpha, 10, High[10] + (offset * TickSize), Brushes.Black);
          myText.OutlineStroke.Width = 1;​
      }​
      What do you think? Where should I put this function definition?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      631 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      566 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X