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

Typical way to draw information from variables on a chart?

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

    #16
    Hello,

    You would use DrawText() for this, part of the DrawText() method is specify which bar its tied too.

    Comment


      #17
      One question about DrawText().

      Can this be tied to a quadrant on the chart like the DrawTextFixed() can? In looking through all of the inputs for it, it seems like you can position the DrawText() function a certain number of bars back as the x position, and a certain height up as the y position. I can see how this would change depending on the scaling of the charts.

      The DrawTextFixed() on the other hand will allow you to simply place your text box in a quadrant, i.e. upper left, lower right etc.

      Comment


        #18
        Originally posted by forrestang View Post
        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?
        BTW.... just for clarification, When I mean 'tied to a price bar' what I was meaning was that the information displayed on the text will be displayed for whatever the latest bar visible on the chart was.

        So that if one where to scroll back in history on a chart, that information would change depending on what the latest bar on the chart was.

        Comment


          #19
          I am currently using the DrawTextFixed() to display some information on the chart.

          I see there is a way to control the font. Is there an example somewhere of this? As Initially I would just like to make all my text bigger.

          Also, I am wondering if there is a way to control all of the variables I have being plotted in the text I have below. As I would like to gain control of the colors of each of the strings I have being outputted. I could draw each one individually I suppose, but I would like to maintain a certain spacing and look on my chart, while being able to keep my text box always in the same location on the chart.

          Here is the code I am using for this now along with a picture of it's current output:

          Code:
          			string stringToEx1 = "Ex: " +High[1].ToString();	
          			string stringToHi = " Hi: " +High[0].ToString();
          			string stringToT = " T: " +(High[1]+filter).ToString();
          			
          			string stringToOp = "Op: " +Open[0].ToString();	
          			string stringToCl = " Cl: " +Close[0].ToString();
          			string stringToR = " R: " +(High[0]-Low[0]).ToString();	
          			
          			string stringToEx2 = "Ex: " +Low[1].ToString();	
          			string stringToLo = " Lo: " +Low[0].ToString();
          			string stringToT2 = " T: " +(High[1]-filter).ToString();		
          			
          			//Added this to not disturb original		        //4 decimal places				
          			double temp5 = acclTop[0];					temp5 = Math.Round(temp5, 4);	string stringToAcclTop = "AcclTop: " +temp5.ToString();	
          			double temp6 = acclTop[0] - acclBot[0];		temp6 = Math.Round(temp6, 4);	string stringToAcclRange = "Accl Band Range: " +temp6.ToString();
          			double temp7 = acclBot[0];					temp7 = Math.Round(temp7, 4);	string stringToAcclBot = "AcclBottom: " +temp7.ToString();				
          			
          			string stringToStopShort = "SL for Short: " +stopTop[0].ToString();	
          			string stringToStopLong = "SL for Long: " +stopBot[0].ToString();			
          			
          			DrawTextFixed("Box1", 
          									stringToEx1 + stringToHi + stringToT + "\n" 
          									+ stringToOp + stringToCl + stringToR + "\n"
          									+ stringToEx2 + stringToLo + stringToT2 + "\n" + "\n"
          									+ stringToAcclTop + "\n" 
          									+ stringToAcclRange + "\n"
          									+ stringToAcclBot + "\n" + "\n"
          									+ stringToStopShort + "\n"
          									+ stringToStopLong 
          																				, TextPosition.TopLeft );
          Attached Files

          Comment


            #20
            To have a table with consistent look and feel, you will need to use a monospaced font and custom string formatting.

            Comment


              #21
              Originally posted by koganam View Post
              To have a table with consistent look and feel, you will need to use a monospaced font and custom string formatting.

              http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
              So this can still be done with the DrawTextFixed() method correct? This that you posted is just defined in each string I am using?

              Comment


                #22
                Originally posted by forrestang View Post
                So this can still be done with the DrawTextFixed() method correct? This that you posted is just defined in each string I am using?
                Yes, you can format the text any which way with DrawTextFixed(). The text are strings that obey all the rules of C# formatting.

                The color, however is applied to the function as a whole, and color formatting cannot be applied to individual text in DrawTextFixed().

                Comment


                  #23
                  Originally posted by koganam View Post
                  Yes, you can format the text any which way with DrawTextFixed(). The text are strings that obey all the rules of C# formatting.

                  The color, however is applied to the function as a whole, and color formatting cannot be applied to individual text in DrawTextFixed().
                  Right. But is it possible to define the color of the string itself when I create the string, PRIOR to the use of it in the DrawTextFixed() function?

                  I thought that was what you were saying initially?

                  Comment


                    #24
                    If I can't do this, it seems I will need another way of drawing text on a chart, as I want to keep it in a box of some sort so it stay organized and in a certain location on the chart, along with being able to individually color the text based on some conditions each time onBarUpdate() occurs.

                    Comment


                      #25
                      Originally posted by forrestang View Post
                      If I can't do this, it seems I will need another way of drawing text on a chart, as I want to keep it in a box of some sort so it stay organized and in a certain location on the chart, along with being able to individually color the text based on some conditions each time onBarUpdate() occurs.
                      In that case, you will have to create a custom dataBox, by overriding the Plot() method. DrawTextFixed() is a custom function within the NT framework, that has its own restrictions, as do all functions in any product.

                      Comment


                        #26
                        Ok gotcha.

                        Comment


                          #27
                          I've switched to using: public override void Plot(), that is residing under my main OnBarUpdate().

                          And I am getting it to display in exactly the manner I want! But I have a simple question: Can I pass it variables from the main portion of my script?

                          I don't actually need it to return anything out of it, just to recieve some variables, and display them on the chart.

                          Can this be done?
                          Attached Files

                          Comment


                            #28
                            Originally posted by forrestang View Post
                            Can I pass it variables from the main portion of my script?

                            I don't actually need it to return anything out of it, just to recieve some variables, and display them on the chart.

                            Can this be done?
                            The answer is YES! Although indirectly.

                            The variables created in main function declared globally are available to that function.

                            Also, if you have this in a separate study as I do, and what the study just to draw some text on a chart..... you can first capture into the main body of script variables from OTHER studies, and then those variables are available to the plot() function.

                            Comment


                              #29
                              Hi forestang,

                              Would you be kind enough to share your code for formatting the text as you have?

                              This is just what I need to do.

                              Thanks in advance for any help

                              Comment


                                #30
                                Originally posted by marty087 View Post
                                Hi forestang,

                                Would you be kind enough to share your code for formatting the text as you have?

                                This is just what I need to do.

                                Thanks in advance for any help
                                Couple indies in here, but "FP_LinkonAdvisors" is the indie that puts text on the chart.
                                Attached Files

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by sidlercom80, 10-28-2023, 08:49 AM
                                177 responses
                                2,400 views
                                0 likes
                                Last Post jeronymite  
                                Started by algospoke, Today, 06:36 PM
                                0 responses
                                6 views
                                0 likes
                                Last Post algospoke  
                                Started by ETFVoyageur, Yesterday, 06:05 PM
                                8 responses
                                53 views
                                0 likes
                                Last Post ETFVoyageur  
                                Started by futtrader, 04-21-2024, 01:50 AM
                                7 responses
                                69 views
                                0 likes
                                Last Post NinjaTrader_Eduardo  
                                Started by pibrew, Today, 06:10 PM
                                0 responses
                                13 views
                                0 likes
                                Last Post pibrew
                                by pibrew
                                 
                                Working...
                                X