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

how to add text near indicator lines

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

    how to add text near indicator lines

    Dear friend.
    How to add text near indicator line. For example near pivot line I want to add price value of those pivot and it's description, like on picture bellow.

    #2
    Hello,

    Thanks for the forum post!

    This would need to be done in the scripting for the indicator.

    This can be added in with the following DrawText() command.



    Let me know if I can be of further assistance.

    Comment


      #3
      Code:
                  Plot0.Set(Lows[1][0]);
                  Plot1.Set(Lows[2][0]);
                  Plot2.Set(Lows[3][0]);
                  Plot4.Set(Lows[4][0]);
                  //------------------------
                  Plot5.Set(Highs[1][0]);
                  Plot6.Set(Highs[2][0]);
                  Plot7.Set(Highs[3][0]);
                  Plot8.Set(Highs[4][0]);
                      DrawText("tag1", "D P", 0, Lows[1][0], Color.Black);
                      DrawText("tag2", "D R1", 0, Lows[2][0], Color.Black);
                      DrawText("tag3", "D S1", 0, Lows[3][0], Color.Black);
                      DrawText("tag4", "D R2", 0, Lows[4][0], Color.Black);
                      DrawText("tag5", "D S2", 0, Highs[1][0], Color.Black);
                      DrawText("tag6", "D R3", 0, Highs[2][0], Color.Black);
      I try to use this code to draw lines and text.
      I try to draw high and low of previos bar.

      Comment


        #4
        But chart is empty.
        I add this construction for stability. Because it was writen in manual.
        Code:
                    if (CurrentBar < 1)
                        {
                return;
                        }

        Comment


          #5
          Hello,

          Are you getting any errors in the log tab in the control center.

          Also this code would end up with text on the last bar of the chart only is this what you intend?

          Also if I understand your code right you have 5 data series in total? Can I see code in Initialize()?


          -Brett

          Comment


            #6
            Code:
             protected override void Initialize()
                    {
                        Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Square, "Plot1"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.TriangleRight, "Plot2"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.Firebrick), PlotStyle.TriangleLeft, "Plot4"));
                        //---------------
                                    Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "Plot5"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.Brown), PlotStyle.Square, "Plot6"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.Magenta), PlotStyle.TriangleRight, "Plot7"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.Navy), PlotStyle.TriangleLeft, "Plot8"));
                        Add("6E 12-11", PeriodType.Minute, 60);
                        Add("6E 12-11", PeriodType.Minute, 240);
                        Add("6E 12-11", PeriodType.Minute, 1440);
                        Add("6E 12-11", PeriodType.Day, 5);
            //Instrument.MasterInstrument.Name
                        Overlay                = true;
                    }
            
                 
              
                    protected override void OnBarUpdate()
                    {
            
                            if (CurrentBar < 1)
                            {
                    return;
                            }
                        Plot0.Set(Lows[1][0]);
                        Plot1.Set(Lows[2][0]);
                        Plot2.Set(Lows[3][0]);
                        Plot4.Set(Lows[4][0]);
                        //------------------------
                        Plot5.Set(Highs[1][0]);
                        Plot6.Set(Highs[2][0]);
                        Plot7.Set(Highs[3][0]);
                        Plot8.Set(Highs[4][0]);
                            DrawText("tag1", "D P", 0, Lows[1][0], Color.Black);
                            DrawText("tag2", "D R1", 0, Lows[2][0], Color.Black);
                            DrawText("tag3", "D S1", 0, Lows[3][0], Color.Black);
                            DrawText("tag4", "D R2", 0, Lows[4][0], Color.Black);
                            DrawText("tag5", "D S2", 0, Highs[1][0], Color.Black);
                            DrawText("tag6", "D R3", 0, Highs[2][0], Color.Black);
                
                    }
            It's all source code.
            I have no erros in a log window. And I want to have lines above and belove candles, and text only at last bar at chart.
            I attch picture at next post.

            Comment


              #7

              Comment


                #8
                Hello,

                You have a black background with black color text. Are you sure its not just blended together?

                -Brett

                Comment


                  #9
                  Originally posted by NinjaTrader_Brett View Post
                  Hello,

                  You have a black background with black color text. Are you sure its not just blended together?

                  -Brett
                  it's picture from another terminal, and I am rewriting ready made indicator for nt7.
                  I have white background at nt7 chart.
                  Please give me advise how to draw 4 lines along last 10 bars with values of low price from hour time frame, 4 hours, 1 day and 1 week. What is the main trouble in my code?

                  Comment


                    #10
                    Hello,

                    When I run your code on my side I get the following in the log:

                    11/29/2011 7:28:21 AM Default Error on calling 'OnBarUpdate' method for indicator 'MTFCurrentHL' on bar 1: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.


                    I had to add a CurrentBars check since just CurrentBar is not good enough for MTF.

                    I then had another problem since you skiped Plot3 that I had to resolve as well, please see the revised code that works in this .cs file.
                    Attached Files

                    Comment


                      #11
                      Originally posted by NinjaTrader_Brett View Post
                      Hello,

                      When I run your code on my side I get the following in the log:

                      11/29/2011 7:28:21 AM Default Error on calling 'OnBarUpdate' method for indicator 'MTFCurrentHL' on bar 1: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.


                      I had to add a CurrentBars check since just CurrentBar is not good enough for MTF.

                      I then had another problem since you skiped Plot3 that I had to resolve as well, please see the revised code that works in this .cs file.
                      Thanks for your code. I have load it. I can't see any errors in a log window.
                      But I can't any lines and text on chart.

                      Comment


                        #12
                        Hello,

                        How many days of data are you loading? I have to load upwards of 20 days since you are loading a 5 day chart series you need at least 10 days of data for anything to plot.

                        -Brett

                        Comment


                          #13
                          Originally posted by NinjaTrader_Brett View Post
                          Hello,

                          How many days of data are you loading? I have to load upwards of 20 days since you are loading a 5 day chart series you need at least 10 days of data for anything to plot.

                          -Brett
                          Did it works correctly on your computer? Please attach screen of your chart with working indicator. I try to load as much history as it's posible.

                          Comment


                            #14
                            Hello,

                            Sure, Attached:
                            Attached Files

                            Comment


                              #15
                              Originally posted by NinjaTrader_Brett View Post
                              Hello,

                              Sure, Attached:
                              Ok, thx, but try to make once more post, becuse I dont see it.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pibrew, Today, 06:37 AM
                              0 responses
                              0 views
                              0 likes
                              Last Post pibrew
                              by pibrew
                               
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              12 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              15 views
                              0 likes
                              Last Post AaronKoRn  
                              Working...
                              X