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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      238 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      152 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      163 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      246 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      199 views
      0 likes
      Last Post CarlTrading  
      Working...
      X