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

Plotting Text

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

    Plotting Text

    Hi,

    I want to plot different text codes above or below certain bars. I know I can do it with the standard objects, but I'm a bit confused about how to do it with text. I've looked through the drawtext object, and I'm guessing my answer lies there, but I'm not sure how I would use the y axis in relation to a bar.

    Any guidance?

    Thanks,

    Rich

    #2
    richp6, yes you can use the DrawText for this, but then the Y Axis value would need to be a price value - if you like to get access to the Y axis boundary to be able to plot at a constant distance from it then this would unfortunately not be supported but possible with the ChartControls methods / properties - as an intro you can look into the CustomPlotSample we install per default.

    Another idea would be something like this custom script - http://www.ninjatrader.com/support/f...Numbers&desc=1
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Ok, I got it to work, kind of. If I replace this statement:

      Star1.Set(High[0] + 1);

      With this one:

      DrawText("Shooting Star", false, "SS", 0, High[0] + 3, 0, Color.Black, new Font("Arial", 10, FontStyle.Bold), StringAlignment.Center, Color.Empty, Color.Yellow, 5) ;

      Then I get it work once. No other text markers on the chart. Is there something I'm missing, so it will do more than one?

      Thanks,

      Rich

      Comment


        #4
        Hi Rich,

        To draw on more than one bar, you need a unique tag. You can do this with:

        Code:
        DrawText([COLOR="RoyalBlue"]"Shooting Star" + CurrentBar[/COLOR], false, "SS", 0, High[0] + 3, 0, Color.Black, new Font("Arial", 10, FontStyle.Bold), StringAlignment.Center, Color.Empty, Color.Yellow, 5) ;
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I have long been frustrated with DrawText(). The Help sections DrawText() section includes this sample...

          DrawText("tag1", "Text to draw", 10, 1000, Color.Black);DrawText("tag1", "Text to draw", 10, 1000, Color.Black);

          If I put that into an indicator under OnBarUpdate I get nothing drawn.

          So I tried your example:

          DrawText("Shooting Star" + CurrentBar, false, "SS", 0, High[0] + 3, 0, Color.Black, new Font("Arial", 10, FontStyle.Bold), StringAlignment.Center, Color.Empty, Color.Yellow, 5) ;
          And still get nothing. It should run everytime OnBarUpdate runs.... but I get no text drawn.

          The reference code example, Indicator: Drawing unique objects and objects that update, says in its discription that it includes DrawText(), but it doesn't... it only has examples for DrawTriangle() etc.

          I really need to figure out how to use DrawText() as DrawTextFixed() is so limited.

          Why will even the example youhave given cut and pasted into my indicator not draw?

          Comment


            #6
            Hi Crassius,

            I'm not sure why you aren't seeing it draw. I tried that line here and am seeing SS over every bar. I would check your Overlay and DrawOnPricePanel properties to make sure it's drawing in the price panel. I've attached an example script you can work from as well.
            Attached Files
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Thanks Ryan... I'll play around with your attachment. You gave me some clues to check as well. I need to figure this out.

              Comment


                #8
                Well, its been a long time and I have just been working around not ever being able to draw on a chart... I still can't do it. Now I must figure this out once and for all.

                Even if I load Ryan's script from the post below (DrawTextExample) onto a chart nothing appears.

                On the indicator I am currently working on and trying to draw arrows on the chart when conditions are met, I have

                Overlay = true;
                PriceTypeSupported =
                true;
                DrawOnPricePanel =
                true;

                There must be some simple thing like a setting I have set that I don't know about that is preventing anything from drawing on the charts.

                Indicator plots work, and DrawTextFixed works, but none of the other draw methods ever work for me.

                Any ideas?

                Comment


                  #9
                  Hello Crassius,

                  When you loaded Ryan's script, do you get any errors on the log tab of the Control Center? If so, what do these errors report?
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    No. I just opened a new clean chart and loaded Ryan's script and get no errors in the Log... nothing drawing on the screen either.

                    Comment


                      #11
                      Hello,

                      How many bars/days do you have loaded on your chart? Are there at least 20 bars?

                      Can you please send me a screen shot of your current chart and include the data series menu so I can compare here.
                      MatthewNinjaTrader Product Management

                      Comment


                        #12
                        Sure Thanks for th ehelp... need to get to te bottom of this. 30 days loaded... amny many more than 20 bars.
                        Attached Files

                        Comment


                          #13
                          Hello,

                          Thanks - I was able to duplicate using the Forex chart. In your original example, you had used High[0] + 3

                          When using a forex instrument, this going to plot the object at the high of the current bar plus a whole value of 3.

                          So when the high of the bar is 1.3480 and you are adding + 3, you are telling this to draw at 4.3480.

                          You wanted this to draw at 3 pips above the high, you'd use + .0003. Please try the following example:
                          Code:
                          DrawText("Shooting Star" + CurrentBar, true, "SS", 0, High[0] + .0003, 0, Color.Black, new Font("Arial", 10, FontStyle.Bold), StringAlignment.Center, Color.Empty, Color.Yellow, 5);
                          Or instead of using .0003, you could use

                          Code:
                          High[0] + 3 * TickSize
                          You would want to adjust these two approach to what works best for you.
                          MatthewNinjaTrader Product Management

                          Comment


                            #14
                            It Works

                            Thanks a million. I know it was something simple.... you can't imagine the time I have wasted trying to figure that out !

                            Comment


                              #15
                              Crassius,

                              Glad to hear I was able to help - when troubleshooting draw objects, you might want to switch the auto scale bool from false to true.

                              This will ensure that whatever is drawn will be automatically scaled in the current chart.
                              MatthewNinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by futtrader, 04-21-2024, 01:50 AM
                              4 responses
                              41 views
                              0 likes
                              Last Post futtrader  
                              Started by Option Whisperer, Today, 09:55 AM
                              1 response
                              12 views
                              0 likes
                              Last Post bltdavid  
                              Started by port119, Today, 02:43 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post port119
                              by port119
                               
                              Started by Philippe56140, Today, 02:35 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post Philippe56140  
                              Started by 00nevest, Today, 02:27 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post 00nevest  
                              Working...
                              X