Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IText and ITextFixed: Alternating colors for each row in a text box

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

    IText and ITextFixed: Alternating colors for each row in a text box

    Hello:

    I am simply trying to change the text color for each row of a text box when specific code conditions are met. Here is a simplified version of code where only text is displayed:

    #region Variables
    // Wizard generated variables
    // User defined variables
    // DrawText and DrawTextFixed code
    private Color textColor0 = Color.Blue;
    private Color textColor1 = Color.SaddleBrown;
    private Color textColor2 = Color.Red;
    private Font textFont = new Font("Arial", 8, FontStyle.Bold);

    ...

    protectedoverridevoid OnBarUpdate()
    {
    ITextFixed text0 = DrawTextFixed("DayType0", "Current Bar is a Buy Day.", TextPosition.Center, textColor0, textFont, Color.ForestGreen, Color.White, 7);

    ITextFixed text1 = DrawTextFixed("DayType1", "Current Bar is a Sell Day.", TextPosition.Center, textColor1, textFont, Color.ForestGreen, Color.White, 7);
    if (TTTcycle().Day[0] == 1)
    {
    add row displaying text with text0 color in text box;
    }

    if (TTTcycle().Day[0] == 2)
    {
    add row displaying text with text1 color in textbox;

    }
    }

    Perhaps I shouldn't use a text box, and instead use Itext and place each row at specific locations on the y-axis. However, there is still the problem of how to change each row color based on the conditions set in OnBarUpdate. Thanks.

    Tony

    #2
    Hello,

    This would be unfortunately unsupported by NinjaScript. You would need to separate text boxed to have different colors.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      You certainly cannot do what you want with ITextFixed. You should be able to do it with IText, but you will have to figure out how to place the textboxes, so that they are always visible.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X