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

Simple indicator that prints the instrument name

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

    Simple indicator that prints the instrument name

    Hi,
    See the screenshot. Is there an indicator that prints text for the current instrument on the chart and keeps it in the top left corner? I take a lot of screenshots and it would be handy to have something like this.
    Thanks.
    Attached Files

    #2
    Hello Grantx, and thank you for your question.


    Attached is a code sample that accomplishes this goal. Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.


    Please let us know if there are any other ways we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Great thank you very much. Ill test it out a little later.

      Comment


        #4
        Originally posted by NinjaTrader_JessicaP View Post
        Hello Grantx, and thank you for your question.


        Attached is a code sample that accomplishes this goal. Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.


        Please let us know if there are any other ways we can help.
        Jessica can you please tell me how to import this?
        Thanks

        Comment


          #5
          I would be happy to.

          1. Copy the attached file to (My) Documents\NinjaTrader 8\bin\Custom\Indicators
          2. In NT8, New -> NinjaScript Editor
          3. Press F5 to compile

          The indicator is now installed and ready to be added to a chart
          Jessica P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_JessicaP View Post
            Attached is a code sample that accomplishes this goal.
            Is there a reason for placing the Draw.TextFixed methods in OnBarUpdate() as opposed to OnStateChange() if (State == State.Historical) ?

            Comment


              #7
              Just habit When I write very short simple scripts I tend to treat OnBarUpdate as my main entry point. I tend to view OnStateChange as a set-up routine. Your suggestion would be more efficient than mine which repeatedly draws the same symbol, as your suggestion would only draw this symbol once.
              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Would you be able to tell me how to import this to NT7 please Jessica?

                Thanks

                Comment


                  #9
                  This tool was written for NinjaTrader 8, and would need to be re-written by yourself or a community member for NinjaTrader 7.

                  For general information on converting NS, please visit this page,



                  For detailed advice on the topic, please visit this forums page,



                  If any specific questions come up, please ask them here, and we will be happy to help.
                  Jessica P.NinjaTrader Customer Service

                  Comment


                    #10
                    Bloody marvellous! Works perfectly. Thank you Jessica!

                    Comment


                      #11
                      Originally posted by tradesmart View Post
                      Is there a reason for placing the Draw.TextFixed methods in OnBarUpdate() as opposed to OnStateChange() if (State == State.Historical) ?
                      Hi Tradesmart, Jessica says that your way is more efficient. Could you tell me how to change to your suggestion?
                      Also (sorry Im being a bit picky here), how would I get the background to the default slategrey colour of Ninja?

                      Comment


                        #12
                        The attached script contains a more efficient one-time execution (I needed to use State.Realtime instead of State.Historical to have access to all the index data that I use), and the final Brush, the background brush, has been changed to Brushes.Transparent from Brushes.Black.

                        This said, having run this script, I recommend using the original script if you run this one overnight. Since this only executes one time, the time never updates in this script, and so the date will not either. Comparing this script to the last one to see how to change the background to either Transparent or SlateGrey I will leave as an exercise to you. You can also use this more efficient form, replacing every instance of Time[0] by DateTime.Now .

                        Please let us know if there are any other ways we can help.
                        Attached Files
                        Last edited by NinjaTrader_JessicaP; 03-23-2017, 02:02 PM.
                        Jessica P.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_JessicaP View Post
                          The attached script contains a more efficient one-time execution (I needed to use State.Realtime instead of State.Historical to have access to all the index data that I use), and the final Brush, the background brush, has been changed to Brushes.Transparent from Brushes.Black.

                          This said, having run this script, I recommend using the original script if you run this one overnight. Since this only executes one time, the time never updates in this script, and so the date will not either. Comparing this script to the last one to see how to change the background to either Transparent or SlateGrey I will leave as an exercise to you. You can also use this more efficient form, replacing every instance of Time[0] by DateTime.Now .

                          Please let us know if there are any other ways we can help.
                          You are my new favourite person Jessica. Thank you so much for doing this!

                          Comment


                            #14
                            Hi, Jessica, can you advise how to get the text to show the tab name? I replaced Instrument.FullName with ChartControl.ChartTab.ActualTabName but it returned the error "Error on calling 'OnBarUpdate' method on bar 0: The calling thread cannot access this object because a different thread owns it."

                            Kindly assist. Thanks!

                            Comment


                              #15
                              Hello Rainmakersg,

                              Thanks for your reply.

                              It is a thread/timing issue. You would need to use a dispatcher to pull the information in OnStateChanges State.RealTime. Reference: https://ninjatrader.com/support/help...-threading.htm

                              For example this works:

                              if (ChartControl != null)
                              {
                              ChartControl.Dispatcher.InvokeAsync(new Action(() =>
                              {
                              NinjaTrader.Gui.Tools.SimpleFont myBigFont = new NinjaTrader.Gui.Tools.SimpleFont("Lucida Sans Unicode", 24) { Size = 50, Bold = true };
                              NinjaTrader.Gui.Tools.SimpleFont myMediumFont = new NinjaTrader.Gui.Tools.SimpleFont("Lucida Sans Unicode", 18) { Size = 25, Bold = true };
                              Draw.TextFixed(this, "Line 2", "\r\n\r\n" + Time[0].ToString("dd/MM/yyyy"), TextPosition.TopLeft, Brushes.Silver, myMediumFont, Brushes.Black, Brushes.Transparent, 100);
                              Draw.TextFixed(this, "Line 1", ChartControl.ChartTab.ActualTabName, TextPosition.TopLeft, Brushes.Silver, myBigFont, Brushes.Black, Brushes.Transparent, 100);
                              }));
                              }


                              Paul H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by BarzTrading, Today, 07:25 AM
                              2 responses
                              19 views
                              1 like
                              Last Post BarzTrading  
                              Started by devatechnologies, 04-14-2024, 02:58 PM
                              3 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by tkaboris, Today, 08:01 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post tkaboris  
                              Started by EB Worx, 04-04-2023, 02:34 AM
                              7 responses
                              163 views
                              0 likes
                              Last Post VFI26
                              by VFI26
                               
                              Started by Mizzouman1, Today, 07:35 AM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X