Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Typical way to draw information from variables on a chart?

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

    Typical way to draw information from variables on a chart?

    I'm creating an indicator, that so far just needs to display various information on the price panel.

    If I had maybe 3-4 variables I would like to output to the screen, what would be a good way to do this? I would like to use a function that would somehow keep it together, so that when resizing bars or scrunching the chart together, all of the values do not get too close to each other, or loose their spacing.

    If anyone knows of an indicator that has done this (I can't think of any), that might get me started as well.

    Might look something like this pic.

    Forrest
    Attached Files

    #2
    Hello,

    Thanks for the forum post.

    Quick question, is this text static meaning it will be some data you always want to see on the screen or will it be tied to the price bars so then when you scroll the chart back the text will go with it.

    -Brett
    BrettNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Brett View Post
      Hello,

      Thanks for the forum post.

      Quick question, is this text static meaning it will be some data you always want to see on the screen or will it be tied to the price bars so then when you scroll the chart back the text will go with it.

      -Brett
      It will be static.... so like always in the upper left, or lower left, or some fixed position on the screen no matter where the chart is scrolled.

      Comment


        #4
        Hello,

        Ok thanks for that information.

        Please use the following method to do this and let me know if you have any questions.

        BrettNinjaTrader Product Management

        Comment


          #5
          Thanks Brett.

          It looks like a sample command would be:
          DrawTextFixed("tag1", "Text to draw", TextPosition.TopRight);

          If I replace "text to draw" with say one of my variables, upon compling it complains.

          Also, if I have several variables I want to display on my screen simultaneously, in the same box, it looks like this function 'DrawTextFixed' has 5 locations. Will I be able to display all of my variables in the same location?

          Comment


            #6
            Hello,

            Can you please post the compiler error and the line of code you used.

            Also, you can stack more then one variable will be no problem.
            BrettNinjaTrader Product Management

            Comment


              #7
              Here is the error in the attached pic. The variable I am using is called 'skew' and it is a data series, hence the index [0]. It contains values of type double.

              When you say 'stack,' I know what you mean. But can you give an example of how to put more than one variable in that function? And how I would go about arranging them, i.e. side by side, or on top of each other.
              Attached Files

              Comment


                #8
                Hello,

                Try adding Skew[0].ToString() and using this as the text to display. Does this do the trick?

                Finally, you may want to create a string variable so that you can create the string. See how I use the plus sign to add values to create one long string.

                For example:

                string stringToOutput = "The Value I want to output: " + outputValue.ToString();

                DrawTextFixed("tag1", stringToOutPut, TextPosition.TopRight);
                BrettNinjaTrader Product Management

                Comment


                  #9
                  Originally posted by NinjaTrader_Brett View Post
                  Hello,

                  Try adding Skew[0].ToString() and using this as the text to display. Does this do the trick?

                  Finally, you may want to create a string variable so that you can create the string. See how I use the plus sign to add values to create one long string.

                  For example:

                  string stringToOutput = "The Value I want to output: " + outputValue.ToString();

                  DrawTextFixed("tag1", stringToOutPut, TextPosition.TopRight);
                  Howdy.

                  Yes that worked. Here is a picture of what I have done.

                  So I have two questions.
                  1.) How would I do this so that I can print these all out, the 4 variables I have in lines on top of one another? You see I added another line in there, in the same quadrant as the first, and it printed the statement 'blah blah' right on top of the other one. I would like them to be ordered so that I can see them. Is there a way to insert a carriage return or something?

                  2.) The number I get is usually in the size of pips. But I am getting the big huge number. How do I go about rounding off so that it only shows a number like "0.0001" instead of "0.0001234567788" for example?

                  I multiplied by "TickSize" but that's not what I want to do I see.
                  Attached Files

                  Comment


                    #10
                    For the carriage return, found the "\n" referenced in this post:


                    Not sure how to format it though.

                    Here'a a line of code. Each string is the new line I want to print.
                    Code:
                    DrawTextFixed("tag1", stringToSkew  + stringToDeviation + stringToSkewPercent, TextPosition.TopRight);

                    Comment


                      #11
                      Ah, got it!

                      Just need to figure out how to round off these numbers.
                      Attached Files

                      Comment


                        #12
                        Hello,

                        Glad to hear.

                        If * TickSize isnt doing what you want you will then need to just to a simple rounding.

                        Math.Round(); is the c# method you will use. This isnt a NinjaScript method. It is instead a c# function.



                        please see this help guide on how to use it. You can also google it to get examples.

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

                        Comment


                          #13
                          Originally posted by forrestang View Post
                          Ah, got it!

                          Just need to figure out how to round off these numbers.
                          Code:
                          Instrument.MasterInstrument.Round2TickSize(double price)

                          Comment


                            #14
                            For the rounding yesterday, I wound up using this to round those numbers:

                            Code:
                            			//Round these numbers 
                            			skew[0] = Math.Round(skew[0], 4);
                            			stdDevSize[0] = Math.Round(stdDevSize[0], 4);
                            			skewPercent[0] = Math.Round(skewPercent[0], 2);

                            Comment


                              #15
                              Originally posted by NinjaTrader_Brett View Post
                              Hello,

                              Thanks for the forum post.

                              Quick question, is this text static meaning it will be some data you always want to see on the screen or will it be tied to the price bars so then when you scroll the chart back the text will go with it.

                              -Brett
                              Brett. If I am wanting to use text that will instead be tied to price bars and not always default to the most recent bar on the charts, what is the common way of accomplishing that?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              577 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