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 Base Instrument ticker next to Indicator

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

    Plotting Base Instrument ticker next to Indicator

    How do you modify (what lines of code) an indicator to plot a floating Ticker name of the base instrument next to the current value of the indicator on a chart . See example attached:
    Attached Files

    #2
    Hello aligator,
    Please try the below code to do it
    Code:
    DrawText("txt", Instrument.FullName, -10, ADX(14)[0], Color.Blue);
    DrawEllipse("ecl", -15, ADX(14)[0] + 5 * TickSize, -5, ADX(14)[0] - 5 * TickSize, Color.AliceBlue);
    Please let me know if I can assists you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Joydeep View Post
      Hello aligator,
      Please try the below code to do it
      Code:
      DrawText("txt", Instrument.FullName, -10, ADX(14)[0], Color.Blue);
      DrawEllipse("ecl", -15, ADX(14)[0] + 5 * TickSize, -5, ADX(14)[0] - 5 * TickSize, Color.AliceBlue);
      Please let me know if I can assists you any further.
      Thank You Joydeep,

      I used just the Draw Text line and nothing was plotted beside the indicator.

      Thanks again.

      Comment


        #4
        Hello aligator,
        Plesae see the attached screenshot where I could draw the objects.

        Please make sure to drag the chart on the left.
        Attached Files
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Thanks Jooydeep.

          I just copied your two lines and pasted them at the end as shown below:

          double diPlus = 100 * (sumTr[0] == 0 ? 0 : sumDmPlus[0] / sumTr[0]);
          double diMinus = 100 * (sumTr[0] == 0 ? 0 : sumDmMinus[0] / sumTr[0]);
          double diff = Math.Abs(diPlus - diMinus);
          double sum = diPlus + diMinus;

          Value.Set(sum == 0 ? 50 : ((Period - 1) * Value[1] + 100 * diff / sum) / Period);
          DrawText("txt", Instrument.FullName, -10, ADX(14)[0], Color.Blue);
          DrawEllipse("ecl", -15, ADX(14)[0] + 5 * TickSize, -5, ADX(14)[0] - 5 * TickSize, Color.AliceBlue);
          }
          }

          Then I compile it and nothing happens on the chart (after using F5 to refresh the chart). Not sure what am I missing.

          Thank You.

          p.s.Could you possibly post your Atest file?
          Last edited by aligator; 06-13-2012, 08:07 AM.

          Comment


            #6
            Hello aligator,
            Please find the code.

            Also please set DrawOnPricePanel to false to draw the objects on the indicator panel


            Please let me know if I can assist you any further.
            Attached Files
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Thank you again Joydeep for your help and excellent quick responses.

              Your approach is great and works as a separate indicator. What I was really attempting to do was to modify the original ADX, RSI, etc. or any other indicator to simply draw the instrument name next to the indicator. I am using ADX to figure out a generic solution.

              If I paste the added two lines into the NT default ADX indicator, the indicator will not draw the text. Also, can I use Value[0] instead of ADX(period)[0] inside those two lines?

              Many thanks for your fantastic support!

              Comment


                #8
                Hello Aligator,
                Yes that would work. The below code will be the last 2 lines in OnBarUpdate in the ADX indicator (copy of the ADX indicator to be precise) for example.
                Code:
                DrawText("txt", Instrument.FullName, -10, Value[0], Color.Blue);
                DrawEllipse("ecl", -15, Value[0] + 5 * TickSize, -5, Value[0] - 5 * TickSize, Color.AliceBlue);
                Also please do remember to append the below code in the Initialize section of the code.
                Code:
                DrawOnPricePanel = false;
                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Joydeep, many thanks and such a great help you have been.

                  The indicator works fine now and plots text. However, now I have to figure out a way so that the color of the text will be the same as color of the line indicator, if I change the indicator color under the parameters menu. The basic idea is to be able to drop the same indicator into the same panel for instruments and use the labeling to identify which one is which.

                  Have a great day!!

                  Comment


                    #10
                    Hello aligator,
                    You can set the color as
                    Code:
                    DrawText("txt", Instrument.FullName, -10, ADX(14)[0],[B] Plots[0].Pen.Color[/B]);
                    Please let me know if I can assist you any further.
                    JoydeepNinjaTrader Customer Service

                    Comment


                      #11
                      Joydeep, marvelous!!!!!!!!!!!!!!!

                      Thanks a bunch. works like a charm. Wonderful!

                      Comment


                        #12
                        Hello Aligator,
                        Thanks for your note.
                        Please let me know if I can assist you any further.
                        JoydeepNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Joydeep View Post
                          Hello aligator,
                          You can set the color as
                          Code:
                          DrawText("txt", Instrument.FullName, -10, ADX(14)[0],[B] Plots[0].Pen.Color[/B]);
                          Please let me know if I can assist you any further.
                          Joydeep, Hi,

                          Since you are fresh on this subject I have a follow-up question:

                          The above modifications plot text for and base indicator, I think. However, it does not seem to work for a derivative on an indicator, i.e. the smoothed average of RSI. RSI plots the RSI indicator and its smoothed average together. If I want to have only the Ave plotted then either I will make RSI transparent or will comment out the Add statement for the RSI plot. However, if I do that and change the rsiValue[0] to Ave[0] in the draw text statement the text will not be plotted at all.

                          Regards.

                          Comment


                            #14
                            Hello Aligator,
                            Simply commenting the Add wont set the RSI Avg to Plots[0]. You have to modify the properties also.

                            Can you send a toy code* to support[AT]ninjatrader[DOT]com replicating the exact scenario.

                            Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

                            I look forward to assisting you further.

                            The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
                            JoydeepNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by rhyminkevin, Today, 04:58 PM
                            3 responses
                            47 views
                            0 likes
                            Last Post Anfedport  
                            Started by iceman2018, Today, 05:07 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post iceman2018  
                            Started by lightsun47, Today, 03:51 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post lightsun47  
                            Started by 00nevest, Today, 02:27 PM
                            1 response
                            14 views
                            0 likes
                            Last Post 00nevest  
                            Started by futtrader, 04-21-2024, 01:50 AM
                            4 responses
                            50 views
                            0 likes
                            Last Post futtrader  
                            Working...
                            X