Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add another instrument to my indicator

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

    Add another instrument to my indicator

    Hi I'm adding the "ES" to an indicator that I run off my TF chart. Below is my code:

    Add("ES 12-14", PeriodType.Tick, 400);

    How do I code it so that it always selects the most current ES contract?

    Thanks

    #2
    Hello,

    Thank you for the question.

    For that statement you would want to use the instruments full name or:

    Add(Instrument.FullName, PeriodType.Tick, 400);

    There is also a Name located in Instrument but this does not include futures contract date.

    This will provide the name of whatever instrument the indicator is applied to.

    I look forward to being of further assistance.

    Comment


      #3
      thanks ... to clarify, I'm running this indicator on a TF chart (not an ES chart) but I want to check a certain condition on the ES ... so how do I point it to the most current ES instrument?

      Comment


        #4
        Hello,

        Thank you for clarifying.

        For this if the instrument has the same rollover date, you can try to use Instrument.Expiry but anything in Initalize() we generally recommend to hard code these values.

        I believe you would need to use a string "ES " + Instrument.Expiry for this to work, you would want to use a Print() statement to output to the output window to ensure the string that is generated is exactly the same as the instrument name.

        I look forward to being of further assistance.

        Comment


          #5
          can you direct me to an example

          Comment


            #6
            Hello,

            We dont really have a specific example for this as its not really a supported way of doing things.

            I will provide this, this should work in most situations, you would fill in the "Static" instrument name such as TF and then the expiry will be appended to the string with the commands that follow

            Code:
            	Print("TF " + Instrument.Expiry.Month + "-" + Instrument.Expiry.Year.ToString().Substring(2, 2));
            The substring is needed as it returns the date as 2014, the substring is just saying cut the text after 2 characters and cut 2 characters or the last 2 numbers of the date.

            Please let me know if I may be of additional assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            580 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            335 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            102 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X