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

Drawing text in indicator panel

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

    Drawing text in indicator panel

    I draw four horizontal dotted lines in an indicator panel (values 0, 0.5, 1, and 1.5), and I change the colors for each bar depending on price action. I would add to add a label (text) to the left on each of those lines to indicate their function. I would obviously like for the label to remain in the same place (left-most side of the indicator panel) as I scroll through time. How do I do this?

    #2
    You can set DrawOnPricePanel to false and then use DrawTextFixed() with a left side alignment -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi, unfortunately the suggestion doesn't work for what I am trying to do. I have attached a screen print to show you my indicator (http://www.screencast.com/t/Yjk1MjMwM). As you can see it displays five lines of diamonds. I would like to ask a word of text to the left of those lines of diamond to explain which study the line relates to. DrawText may be the solution and the y value is not a problem, however I don't know how to reference the x/time value to coincide with the left most side of the screen. Thanks in advance for your help.

      Comment


        #4
        You have to use DrawTextFixed() if you want it to correspond with left edge as opposed to a certain bar. DrawText() is tied to bars and as you scroll around it will move while DrawTextFixed() is "fixed" onto the chart on certain corners.

        If you want it to be "fixed" but at locations of your choosing unfortunately this is not supported and you would have to override the Plot() method and custom program that in yourself.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Any good example out there of overriding the Plot() method?

          Comment


            #6
            Overriding the Plot() method is outside the scope of what we can offer support for and we unfortunately do not have any samples.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Overriding Plot() in panel 2...

              I just would like to know *if it is possible* to override Plot() in panel 2? I know "how" to do it just want to know if it is possible, yes or no.

              Comment


                #8
                I'll answer that -> yes it is

                Comment


                  #9
                  The x-coordinate value for the left side of the screen would be ChartControl.FirstBarPainted, so the value you would use for the startBarsAgo witl be (CurrentBar - ChartControl.FirstBarPainted).

                  Example:


                  Code:
                  int LeftSideOfScreen = ChartControl.FirstBarPainted;
                  DrawText("Test", false, "Text to show at left side of screen", 
                  (CurrentBar - LeftSideOfScreen), Close[0], 0, Color.Blue, new Font("Arial" , 12), 
                  StringAlignment.Near, Color.Transparent, Color.Transparent, 5);
                  Since you are going to be using that line a whole lot, you should probably initialize the font in OnStartUp(), after declaring it in the Variables region, and then dispose of the font in OnTermination().

                  Be aware that all use of ChartControl functions will not get any support from NT, so use at your own risk. It could change in the future, which I am sure, is partly why they refuse to provide any support for it.
                  Last edited by koganam; 06-27-2011, 09:37 AM.

                  Comment


                    #10
                    Just remember to check for Bounds.Max and Bounds.Min in the panel where you are overriding the plot.

                    Comment


                      #11
                      Nice example.... thanks Koganam

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by yertle, Yesterday, 08:38 AM
                      7 responses
                      28 views
                      0 likes
                      Last Post yertle
                      by yertle
                       
                      Started by bmartz, 03-12-2024, 06:12 AM
                      2 responses
                      20 views
                      0 likes
                      Last Post bmartz
                      by bmartz
                       
                      Started by funk10101, Today, 12:02 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post funk10101  
                      Started by gravdigaz6, Yesterday, 11:40 PM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by MarianApalaghiei, Yesterday, 10:49 PM
                      3 responses
                      10 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Working...
                      X