Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting the resolution name and value in DisplayName()

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

    Getting the resolution name and value in DisplayName()

    Hi,

    How can I access the resolution (like minute or day) and value (like 10 or 1) in the `DisplayName()` override method?

    I thought the `BarsPeriod.Value` and `BarsPeriod.BarsPeriodType` properties would do, but they generate an error ("Unhandled Exception: Object reference not set to an instance of an object").

    Edit: `Instrument.FullName` generates the same exception; so I'd also like to know how to get the instrument's name in the `DisplayName()` method.

    Thanks,

    ------
    Code:
    public override string DisplayName
            {
                get
                {
                    return Name + " (" + 
                        // Symbol
                        //Instrument.FullName + ", " +
                        // Resolution
                        BarsPeriod.Value + " " +
                        BarsPeriod.BarsPeriodType + " [" +
                        //// Parameters
                        Period_Slow + ", " +
                        K_Slow + ", " +
                        Period_Quick + ", " +
                        K_Quick + ", " +
                        Filter_Signals +
                        "])";
                }
            }
    Last edited by J_o_s; 10-09-2015, 10:39 AM.

    #2
    Hello J_o_s,

    Thank you for your post.

    Use a string to hold these objects and assign them in the Configure State. The information from the instrument or bars needs to load first before we call it. So all you have to do is set the value to null and check if it is null until it gets assigned in the Configure State.

    For example:
    Code:
    		private string info = null;
    		protected override void OnStateChange()
    		{
    		...
    		if (State == State.Configure)
    			{
    				info = Instrument.FullName;
    			}
    		}
    		public override string DisplayName
    		{
    		    get { return (info != null ? info : ""); }
    
    		}

    Comment


      #3
      Thanks Patrick for the quick reply and knowledgeable response. Works like a charm now. Thanks!

      Comment


        #4
        Custom display string causes indicator name to disappear from list

        This works great except for one thing. When you add the indicator to a chart, in the list of configured indicators on the left side of the indicators page where the name of the indicator should be, there is an empty string. The indicator is there and its properties appear if you click on the appropriate, empty, line.

        Maybe related to this?

        Comment


          #5
          Originally posted by Ricam View Post
          This works great except for one thing. When you add the indicator to a chart, in the list of configured indicators on the left side of the indicators page where the name of the indicator should be, there is an empty string. The indicator is there and its properties appear if you click on the appropriate, empty, line.
          I fixed that by using

          Code:
          public override string DisplayName
          {
              get { return (displayName != null ? displayName : Name ); }
          }
          This way the full, custom indicator name (`displayName`) is displayed when that string has been created. If it has not, then the default `Name` is displayed.

          That way you'll see the indicator name in the properties window, and the custom indicator name on the chart.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X