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

ToString() Replacement

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

    ToString() Replacement

    What is the NT8 replacement syntax for NT7's ToString() method? I've tried reading the available documentation right down to the alphabetical language reference and can't seem to find a method that lets one set the chart string to a name of their choosing. If you could provide a small example of how to use it in an indicator, also, that would be very helpful.

    Thanks in advance.
    Joe

    #2
    Originally posted by Joe_T View Post
    What is the NT8 replacement syntax for NT7's ToString() method? I've tried reading the available documentation right down to the alphabetical language reference and can't seem to find a method that lets one set the chart string to a name of their choosing. If you could provide a small example of how to use it in an indicator, also, that would be very helpful.

    Thanks in advance.
    Joe
    Override the DisplayName property.

    ref: http://ninjatrader.com/support/helpG...isplayname.htm

    Comment


      #3
      Hello Joe_T

      Member Koganam has provided a link to the helpguide that provides examples. Please post again if this is not what you are looking for.
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        This method does not work properly. I tested the DisplayName property, but it does two things instead of one. Lets say in my indicator, let's call it MyIndicator, I return the string "MyChartName" using the using the get { return "MyChartName"; } syntax. Then two things happen. First, when I add MyIndicator to the chart, the chart label in the upper left corner is properly changed to "MyChartName". But also, the name of the indicator in the indicator list changes to "MyChartName" also, when the name of the indicator should remain as "MyIndicator".

        I want only the chart label to change, not the indicator label in the indicator list.

        What method is used for that to occur? Or, is this an error in the DisplayName override method?

        The ToString() method used to give me the ability to change the chart label only, without affecting the name of the indicator in the indicator list.

        Comment


          #5
          Originally posted by Joe_T View Post
          ...
          I want only the chart label to change, not the indicator label in the indicator list.

          What method is used for that to occur? Or, is this an error in the DisplayName override method?

          The ToString() method used to give me the ability to change the chart label only, without affecting the name of the indicator in the indicator list.
          The indicator label in the indicator list is the Name property. Set it in State.SetDefaults.

          Comment


            #6
            The Name property of the indicator was previously set in the State.SetDefaults section of the indicator when constructed. But changing the DisplayName property over-rides it, too, and changes the name of the indicator in the indicator list. For future replies on this topic I would like replies only from NinjaTrader employees. I do not want to keep going around in circles.

            Comment


              #7
              Hello Joe_T,

              Thanks for your post.

              With reference to the helpguide link that member Koganam previously provided note that you can display your text and the name of the indicator, if you wish:

              Code:
              public override string DisplayName
              {
                get { return "My Custom Display " + Name; }
              }
              This would also show in the indicator list. You can also put the Indicator name first and then the text you wish to display. (See attached example).

              If that does not provide what you need, we can create a feature request to have the DisplayName show only the text on the chart and not change the indicator list. Please let us know if this would be your preference.
              Attached Files
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Indicator Name Changes in Indicator Configuration Panel

                Ok. So, I have experimented and found out what the behavior of the DisplayName property does in practice. 1) The DisplayName property does, in fact, change the name displayed on the chart to whatever string one sets in the custom indicator, 2) BUT it also changes the name of the Indicator in the indicator "Configured" panel that shows when you select the indicator toolbar button, 3) it does not change the name of the indicator in the "Available" list, and 4) if you 'subsequently' add another internal Ninja indicator manually, rather than via NinjaScript, the name gets concatenated with the new indicator.

                So, let's say you have a custom indicator that changes the displayed name on the chart to "My Indicator", and then manually add, say an EMA(34) to the channel panel, where the underlying chart is ES 03-17 (30 Minute), then the name displayed on the chart changes to:

                My Indicator, EMA(ES 03-17 (30 Minute), 34)

                This behavior is unacceptable for several reasons. If you want to "null out" the DisplayName entirely, so nothing is displayed on the chart, then the name of that indicator does not appear in the indicator Configured panel, and there would be confusion 'de-selecting' multiple indicators with a null name in the Configured panel.

                I believe that what many or most users want is the chart name, and chart name only, in the upper left or middle of the chart, or the "option" to have every single indicator's name, or a subset, displayed on the chart - perhaps below the chart name line.

                Right now Ninja uses the DisplayName line only to display a consecutive list of indicators, and they do not use it to display the name of the chart. I believe there are three ways Ninja could/should address this.

                First, a ChartName property could be assigned - which would be different than the indicator DisplayName property. The chart name would be positionable in the upper left or middle of the chart, and it would have the same advantage that the DisplayName property currently does - namely that prices will not scroll over the name, obscuring it. This would also have the advantage that the name of indicators in the "Configured" indicator panel would not have to change just to change the name of the chart, whether configured through NinjaScript or added manually. It would also allow users to add just the chart name to a chart without having to Null-out a long list of indicators and figure out a) which were added first, b) which were added via NinjaScript and c) which were added manually. The Draw.TextFixed method is not suitable for this as an "upper left" text added for this method does not show in the exact same location as the current DisplayName does. Also, prices can scroll over an "upper left" text added by this method. (This ChartName property could also be over-ridden, and it would not be the same as the chart TabName property).

                Second, when the DisplayName property is changed, it would be helpful 'not' to have it change in the "Configured" indicators panel, so regardless of what name one changes it to (even if it is null), it does not change in the Configured indicators panel and one can read it.

                Third, since there is always a chart TabName property, perhaps that could always be the first string in the DisplayName property, and then a user could chose to add to it or not.

                Please give your serious thought to this change because right now NinjaTrader has confused what most people want as a ChartName versus a long string of the indicators added to the chart via DisplayName, and programmatically a nightmare has been created just to name a chart.

                Yes, 'I know' you can always parse out a string to give just the "Full Instrument" name in NinjaScript, but, then, you are left with the situation that someone adds manual indicators to the chart, and the chart name again becomes longer and longer.

                Thanks,
                Joe_T

                Comment


                  #9
                  Joe
                  I went at this issue several months ago and I agree with your assessment. It needs to operate more like NT7. I am so tired of having to Blank out the labels on my custom indicators everytime I re apply them and that is Quite a bit given the crashes I have had and the number of times I have had to rebuild workspaces and templates.

                  J~

                  Comment


                    #10
                    Originally posted by Joe_T View Post
                    This behavior is unacceptable for several reasons. If you want to "null out" the DisplayName entirely, so nothing is displayed on the chart, then the name of that indicator does not appear in the indicator Configured panel, and there would be confusion 'de-selecting' multiple indicators with a null name in the Configured panel.
                    I agree.. This has been an issue since the beginning, and there currently is still no perfect solution..

                    In my case, I definitely need to overwrite the Display Name, in some cases my indys just have more parameters than need displayed, and in others I want specific information to be displayed.. But yet, no matter what I override the DisplayName to look like, I also defiantly want the ability to hide that all together if I so choose...

                    It took a bit of playing to come up with what I'm currently using as a work around, but until the issue gets fixed, and or I find a better solution, this is what I've settled for so far ..


                    Code:
                    [COLOR=#0000ff]bool      [/COLOR][COLOR=#080808]b_ConfigSet[/COLOR][COLOR=#000000] = [/COLOR][COLOR=#0000ff]false[/COLOR][COLOR=#000000];[/COLOR]
                    [COLOR=#0000ff]string    [/COLOR][COLOR=#080808]s_IndyName[/COLOR][COLOR=#000000] = [/COLOR][COLOR=#b22222]@"MyIndicatorName"[/COLOR][COLOR=#000000];[/COLOR]
                     
                    [COLOR=#0000ff]protected [/COLOR][COLOR=#0000ff]override [/COLOR][COLOR=#0000ff]void [/COLOR][COLOR=#080808]OnStateChange[/COLOR][COLOR=#000000]()[/COLOR]
                    {
                    [COLOR=#0000ff]    if[/COLOR]([COLOR=#080808]State[/COLOR] == [COLOR=#080808]State[/COLOR].[COLOR=#080808]SetDefaults[/COLOR])
                         {
                    [COLOR=#080808]         Description[/COLOR] = [COLOR=#b22222]@"Hide Indicator Chart Display Name Sample"[/COLOR];
                    [COLOR=#080808]         Name[/COLOR] = [COLOR=#080808]s_IndyName[/COLOR];
                    [COLOR=#080808]         Calculate[/COLOR] = [COLOR=#080808]Calculate[/COLOR].[COLOR=#080808]OnBarClose[/COLOR];
                    [COLOR=#080808]         IsOverlay[/COLOR] = [COLOR=#0000ff]true[/COLOR];
                    [COLOR=#080808]         DrawOnPricePanel[/COLOR] = [COLOR=#0000ff]true[/COLOR];
                    [COLOR=#080808]         ScaleJustification[/COLOR] = [COLOR=#080808]NinjaTrader[/COLOR].[COLOR=#080808]Gui[/COLOR].[COLOR=#080808]Chart[/COLOR].[COLOR=#080808]ScaleJustification[/COLOR].[COLOR=#080808]Right[/COLOR];
                    [COLOR=#080808]         IsSuspendedWhileInactive[/COLOR] = [COLOR=#0000ff]true[/COLOR];
                    [COLOR=#080808]         B_HideName[/COLOR] = [COLOR=#0000ff]false[/COLOR];
                         }
                    [COLOR=#0000ff]    else[/COLOR] [COLOR=#0000ff]if[/COLOR]([COLOR=#080808]State[/COLOR] == [COLOR=#080808]State[/COLOR].[COLOR=#080808]Configure[/COLOR]) { [COLOR=#080808]b_ConfigSet[/COLOR] = [COLOR=#0000ff]true[/COLOR]; }
                    [COLOR=#0000ff]    else[/COLOR] [COLOR=#0000ff]if[/COLOR]([COLOR=#080808]State[/COLOR] == [COLOR=#080808]State[/COLOR].[COLOR=#080808]DataLoaded[/COLOR]) { [COLOR=#0000ff]if[/COLOR]([COLOR=#0000ff]this[/COLOR].[COLOR=#080808]ChartControl[/COLOR] != [COLOR=#0000ff]null[/COLOR] && [COLOR=#080808]b_ConfigSet[/COLOR]) { [COLOR=#0000ff]if[/COLOR]([COLOR=#080808]B_HideName[/COLOR]) [COLOR=#080808]Name[/COLOR] = [COLOR=#b22222]""[/COLOR]; } }
                    [COLOR=#0000ff]    else[/COLOR] [COLOR=#0000ff]if[/COLOR]([COLOR=#080808]State[/COLOR] == [COLOR=#080808]State[/COLOR].[COLOR=#080808]Terminated[/COLOR]) { [COLOR=#0000ff]if[/COLOR]([COLOR=#0000ff]this[/COLOR].[COLOR=#080808]ChartControl[/COLOR] != [COLOR=#0000ff]null[/COLOR] && [COLOR=#080808]b_ConfigSet[/COLOR]) { [COLOR=#080808]Name[/COLOR] = [COLOR=#080808]s_IndyName[/COLOR]; } }
                    }
                     
                    [COLOR=#0000ff]protected [/COLOR][COLOR=#0000ff]override [/COLOR][COLOR=#0000ff]void [/COLOR][COLOR=#080808]OnBarUpdate[/COLOR][COLOR=#000000]() { }[/COLOR]
                     
                    [COLOR=#0000ff]public [/COLOR][COLOR=#0000ff]override [/COLOR][COLOR=#0000ff]string [/COLOR][COLOR=#080808]DisplayName[/COLOR][COLOR=#000000]{ [/COLOR][COLOR=#0000ff]get[/COLOR][COLOR=#000000] { [/COLOR][COLOR=#0000ff]return[/COLOR][COLOR=#080808]s_IndyName[/COLOR][COLOR=#000000] + [/COLOR][COLOR=#b22222]"("[/COLOR][COLOR=#000000] + [/COLOR][COLOR=#080808]B_HideName[/COLOR][COLOR=#000000].[/COLOR][COLOR=#080808]ToString[/COLOR][COLOR=#000000]() + [/COLOR][COLOR=#b22222]")"[/COLOR][COLOR=#000000]; } }[/COLOR]
                     
                    [[COLOR=#080808]Display[/COLOR]([COLOR=#080808]ResourceType[/COLOR] = [COLOR=#0000ff]typeof[/COLOR]([COLOR=#080808]Custom[/COLOR].[COLOR=#080808]Resource[/COLOR]), [COLOR=#080808]Name[/COLOR]= [COLOR=#b22222]"HideName"[/COLOR], [COLOR=#080808]Description[/COLOR]= [COLOR=#b22222]"Hide Indicator Chart Display Name"[/COLOR], [COLOR=#080808]Order[/COLOR]=[COLOR=#ff8c00]0[/COLOR], [COLOR=#080808]GroupName[/COLOR]= [COLOR=#b22222]"Misc"[/COLOR])]
                    [COLOR=#0000ff]public [/COLOR][COLOR=#0000ff]bool [/COLOR][COLOR=#080808]B_HideName[/COLOR][COLOR=#000000] { [/COLOR][COLOR=#0000ff]get[/COLOR][COLOR=#000000]; [/COLOR][COLOR=#0000ff]set[/COLOR][COLOR=#000000]; }[/COLOR]

                    -=Edge=-
                    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                    Comment


                      #11
                      Hello Joe_T,

                      Thanks for your post.

                      We will create a feature request for this. If one already exists your vote (and JerryWars and Edge's, thanks' guys) will be added to this. We will update this thread when we have further information.

                      Thanks for your suggestions on how we can improve NinjaTrader 8.
                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        I agree with the others about the feature request.

                        Also, can someone help me with the following.......

                        Code:
                        public override string DisplayName
                        		{
                        			get { return Name + "(" + Bars.ToChartString() + ")" ;}
                        		}
                        I get an unhandled exception error which I am guessing is because I need to do a null reference check for the Bars.ToChartString()

                        Comment


                          #13
                          Hello,

                          Thanks for your post.

                          To use get { return Name + "(" + Bars.ToChartString() + ")" ;} you will need to replace Bars.ToChartString() with a string variable that you previously declare with some temporary contents. Then in State == State.DataLoaded assign Bars.ToChartString() to that variable. The string variable you create will then populate with the values in State.DataLoaded.
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            ToString() Replacement

                            Originally posted by NinjaTrader_Paul View Post
                            Hello Joe_T,

                            Thanks for your post.

                            We will create a feature request for this. If one already exists your vote (and JerryWars and Edge's, thanks' guys) will be added to this. We will update this thread when we have further information.

                            Thanks for your suggestions on how we can improve NinjaTrader 8.
                            Has there been any progress on this feature request? May we have an update please? Recall basically we are looking for two things: 1) a "Chart Title" property that we set independently of the name of an indicator, which will also show when we take a snapshot of the chart for printing or publication, as used to occur with NT7, and 2) a way to set the indicator display name on a chart - or null it out - that does not affect the name of the indicator in the configured indicators list.

                            Thank you.
                            Joe_T
                            Last edited by Joe_T; 03-08-2017, 05:39 AM.

                            Comment


                              #15
                              One of the Reasons, I want to null out the Name is that I do not want to display the complete
                              list of indicator inputs along with the name especially given that NT8 displays the Hex representation
                              of colors. Maybe there could be a separate UI input added for "Display Indicator Inputs"

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Started by usazencortex, Today, 12:43 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post usazencortex  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              168 responses
                              2,266 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X