Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is there a way to get properties of secondary instrument?

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

    Is there a way to get properties of secondary instrument?

    In a multi-instrument indicator/strategy, I can pass the symbol of the secondary instrument as a parameter, then Add() it.

    Is there a way to look up properties such as PointValue, etc, that can be looked up for the MasterInstrument? If not there should be...

    #2
    Right now you can't access .Instrument property in Initialize(). This was something people complained about. We will change this with next update so you e.g. could do something like .Instrument.MasterInstrument.PointValue in Initialize().

    Comment


      #3
      I'm asking about a secondary instrument. Even in OnBarUpdate, can I look up the PointValue or other properties of a secondary instrument? i.e. if my indicator has a parameter "Symbol2" which is the symbol for a secondary instrument, and I Add() Symbol2 in Initialize(), is there any way to look up the PointValue of Symbol2, even in OnBarUpdate?

      Thanks

      Comment


        #4
        Sure, in OnBarUpdate() you just could go with .Instruments[1].MasterInstrument... Same like with multi-series strategies in NT6.5

        Comment


          #5
          The same with NT 6.5 multi-instrument strategy :

          This is NT7 beta forum but the issue is relevant for NT 6.5 either.

          What I wanted to do is to add secondary instruments having the same PeriodType and Period value as the master instrument.

          From my own experiments and from your answer to Kevin I understand it's impossible , because we can know master instrument properties only in OnBarUpdate and of course it is too late to Add() new instruments there.

          My workaround to this problem is to add all instruments including replicated master instrument, specifying PeriodType and its period for all instruments participating in my strategy, e.g. add EUR , JPY , EURJPY , everyone of them is Range 20 , despite my master instrument, EURJPY , Range 20 already exists.
          It works , but it wastes precious resources . May be , in NT7 with its supposedly better memory management it's not an issue at all.

          Comment


            #6
            It's not hard, see code below. I made the property getter a bit more complicated so it will default to a secondary instrument displayed on the chart.


            Code:
            in Variables:
            
            private string symbol2 = "";
            
            
            in Initialize:
            
            Add(Symbol2, BarsPeriod.Id, BarsPeriod.Value);
            
            
            in Properties:
            
            [Description("Symbol 2; i.e. SPY or ES 03-10\nDefault = Secondary chart instrument")]
            [GridCategory("Parameters")]
            // Force this parameter to be displayed first
            [Gui.Design.DisplayName ("\tSymbol 2")]
            public string Symbol2
            {
                 get 
                 { 
                      if ((symbol2 == "") && (ChartControl != null) && (Instruments != null))             
                           for(int i=0; i<ChartControl.BarsArray.Length; i++)
                                if (ChartControl.BarsArray[i].Instrument.FullName != Instruments[0].FullName)
                                {
                                     symbol2 = ChartControl.BarsArray[i].Instrument.FullName;
                                     break;
                                }
                      return symbol2; 
                 }
                 set { symbol2 = value.ToUpper(); }
            }

            Comment


              #7
              Originally posted by kdoren View Post
              It's not hard, see code below. I made the property getter a bit more complicated so it will default to a secondary instrument displayed on the chart.
              Thank you, it's not exactly what I'm looking for, but it helped me.
              I used just:

              Code:
                          if ( ChartControl != null)
                              {
                              sPr = ChartControl.BarsArray[0].ToString() ; 
                              }
              Where sPr includes all needed information about the master instrument, it only needs to be parsed.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              597 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              343 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              556 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              555 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X