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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      175 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      331 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      253 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      356 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      183 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X