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 cmoran13, Yesterday, 01:02 PM
      0 responses
      25 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      17 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      160 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      94 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      148 views
      2 likes
      Last Post CaptainJack  
      Working...
      X