Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

New line for each text output

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

    New line for each text output

    Code:
            // Print the current 7 period SMA of range .
                DrawTextFixed("AverageDailyRange1", "Average Daily Range: " + SMA(AverageDailyRange, 7)[0].ToString("N2"), TextPosition.TopLeft);
                DrawTextFixed("AverageDailyRange2", "Stop Loss: " + ((SMA(AverageDailyRange, 7)[0])*.10).ToString("N2"), TextPosition.TopLeft);
                DrawTextFixed("AverageDailyRange3", "Target Profit: " + ((SMA(AverageDailyRange, 7)[0])*.15).ToString("N2"), TextPosition.TopLeft);
    How do I get each text line (i.e average daily range readout, stop loss read out, etc) on a seperate line. I tried \n, but they still ended up on the same line overlapping each other. Thanks.

    #2
    please disregard. the /n now works.. must have been some anomoly.

    Comment


      #3
      I guess my question would be now, how do you make the text output (default is black apparently) different, like the stop loss text red and target profit green

      Comment


        #4
        Hi ericadam,

        You can choose the coloring of the DrawTextFixed() method. Please use this syntax:

        DrawTextFixed(string tag, string text, TextPosition textPosition, Color textColor, Font font, Color outlineColor, Color backColor, int opacity)
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          tried to compile this:
          DrawTextFixed("AverageDailyRange1", "Average Daily Range: " + SMA(AverageDailyRange, 7)[0].ToString("N2"), TextPosition.TopLeft, Color.Green);

          But it fails - "No overload for method "DrawTextFixed" takes '4' arguments"

          Comment


            #6
            ericadam,

            You need to use the complete list of arguments. Please take a look at the Help Guide article on DrawTextFixed here for more information: http://www.ninjatrader-support.com/H...TextFixed.html
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              still getting errors after using the whole proper syntax:

              DrawTextFixed("AverageDailyRange2", "\nStop Loss: " + ((SMA(AverageDailyRange, 7)[0])*.10).ToString("N2"), TextPosition.TopLeft, Color.Green, Font.Bold, Color.White, Color.White, 5);

              Comment


                #8
                Give this a try:
                Code:
                DrawTextFixed("AverageDailyRange2", "\nStop Loss: " + ((SMA(AverageDailyRange, 7)[0]) * 0.10).ToString("N2"), TextPosition.TopLeft, Color.Green, new Font("Arial", 10), Color.White, Color.White, 5);
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  thanks, it worked. I guess examples of the syntax would be helpful on the help page. The font threw me off. Thx

                  Comment


                    #10
                    Is there a way to round the values to increments of .25? (i.e. the ES increment)

                    Comment


                      #11
                      Please use Round2TickSize: http://www.ninjatrader-support.com/H...2TickSize.html
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        thanks, can I get a quick example of the syntax

                        Comment


                          #13
                          nvm, got it. Just popped it around the code

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          566 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          330 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
                          547 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          548 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X