Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    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 algospoke, Yesterday, 06:40 PM
      2 responses
      19 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X