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

draw text with different colors

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

    draw text with different colors

    Hi,
    i want to draw a text on 1 horizontal line with some letters/nbrs with a different color.
    Ex.: RSI=30 XX=80 YY=50 etc...
    RSI=30 has to be changed to a different color, below 30 or above 70.
    Same for XX, YY, etc..

    No problem to do that vertically but i don't find how to do it on 1 horizontal line.

    #2
    Hi,

    You should just be able to draw the different text under the conditional check for RSI.

    How are you accomplishing this vertically? What would the difference be?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Let me clarify my example. (drawing on the chart as text)
      RSI and XX and YY are on 1 line.
      The colors for RSI, XX and YY should be changed to another color individually, when they trespassed the 80 and 20 state.
      Of course vertically the problem do not exist because a DrawFixedText with a carriage return can do that, but this is not what i want.

      Comment


        #4
        You would need to break each string text/value into a separate DrawText function to draw colors individually.

        This may get a little tricky depending on where you want these values to be drawn. You would have more control by over riding the Plot method and custom drawing in there.

        I'd suggest looking at the CustomPlotSample under Tools--> Edit NinjaScript--> Indicator. We do not have any additional documentation on this custom plotting, but you can refer to general MSDN documentation on drawing to help you accomplish your goal
        MatthewNinjaTrader Product Management

        Comment


          #5
          Originally posted by NinjaTrader_Matthew View Post
          You would need to break each string text/value into a separate DrawText function to draw colors individually.
          I did, but after a DrawFixedText function automaticaly a carriage return occur.
          So can't get the text one after an other.

          Comment


            #6
            Can you give me a snippet of the code that generated an error?
            MatthewNinjaTrader Product Management

            Comment


              #7
              This is my code:
              Font indicFont = new Font("Deja Vu Sans Mono", 8, FontStyle.Bold);
              // rsiValue.ToString("N0"); N0 means 0 decimal, N means 1 decimal, etc
              DrawTextFixed("Indicators","\n\n\n\n\nRSI=" + rsiValue.ToString("N0")+" IMI=" + imiValue.ToString("N0")+" MFI=" + mfiValue.ToString("N0")+" Bol%=" + bolPerc.ToString("N0")+" .", TextPosition.BottomRight,Color.Blue,indicFont,Colo r.Transparent, Color.Transparent,0);
              /* DrawTextFixed("Indicators"," IMI=" + imiValue.ToString("F"), TextPosition.TopLeft,Color.Blue,indicFont,Color.Tr ansparent, Color.Transparent,0);
              DrawTextFixed("Indicators"," MFI=" + mfiValue.ToString("F"), TextPosition.TopLeft,Color.Red,indicFont,Color.Tra nsparent, Color.Transparent,0);
              DrawTextFixed("Indicators"," Bol%=" + bolPerc.ToString("F"), TextPosition.TopLeft,Color.Green,indicFont,Color.T ransparent, Color.Transparent,0);
              */
              There is no error, i can't only get it coded as it has to be.

              Comment


                #8
                Originally posted by mate41 View Post
                I did, but after a DrawFixedText function automaticaly a carriage return occur.
                So can't get the text one after an other.
                DrawTextFixed() is a NT-specific method that has its own parameters and restrictions. One of those is that you cannot directly manipulate the properties of the individual strings within another complete string.

                To do what you want, you will have to use C# directly. The simplest way is with a custom Plot, as NT provides enough encapsulation to manipulate individual elements in the Plot method. The other way is to get the ChartControl context and draw directly on it.
                Last edited by koganam; 04-08-2013, 06:13 PM. Reason: Corrected grammar.

                Comment


                  #9
                  Thanks, i'll try a custom plot.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by junkone, Today, 11:37 AM
                  2 responses
                  14 views
                  0 likes
                  Last Post junkone
                  by junkone
                   
                  Started by frankthearm, Yesterday, 09:08 AM
                  12 responses
                  43 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by quantismo, 04-17-2024, 05:13 PM
                  5 responses
                  35 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by proptrade13, Today, 11:06 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by love2code2trade, 04-17-2024, 01:45 PM
                  4 responses
                  35 views
                  0 likes
                  Last Post love2code2trade  
                  Working...
                  X