Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can indicator code get info for all instruments displayed on chart?

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

    Can indicator code get info for all instruments displayed on chart?

    For a multi-instrument indicator, is there a way for the indicator code to read the symbol and other info for all instruments displayed on the chart?

    Right now I need to enter the symbol for the second instrument as a parameter for the indicator. But in many cases, the second instrument will already be displayed on the chart. If the indicator code could read the information for all of the instruments on the chart, it could make it easier to set up multi-instrument indicators.

    #2
    Unfortunately this is not supported.

    Comment


      #3
      Originally posted by kdoren View Post
      For a multi-instrument indicator, is there a way for the indicator code to read the symbol and other info for all instruments displayed on the chart?

      Right now I need to enter the symbol for the second instrument as a parameter for the indicator. But in many cases, the second instrument will already be displayed on the chart. If the indicator code could read the information for all of the instruments on the chart, it could make it easier to set up multi-instrument indicators.
      Actually I was just thinking the other day too that this would be a nice feature.

      Then I was thinking there must be some way to get this info and found this (e.g. use in Initialize):

      Code:
      [FONT=Courier New][SIZE=2][COLOR=#0000ff]
      [SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](ChartControl != [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff] for[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] i=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]; i<ChartControl.BarsArray.Length; i++)[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]     [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Print(ChartControl.BarsArray[i].Instrument.FullName + [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + ChartControl.BarsArray[i].Period.BasePeriodValue + [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + ChartControl.BarsArray[i].Period.BasePeriodType);[/SIZE][/FONT]
      [/SIZE][/FONT][/FONT][/SIZE][/SIZE][/FONT]
      Of course this is probably highly unsupported.

      Comment


        #4
        terenyi, Thanks for the tip. The following code seems to work nicely in the Properties section; if "Symbol2" is blank, when you apply the indicator it defaults to the first symbol on the chart that isn't the indicator's primary symbol:

        Code:
        [Description("Symbol 2\nDefault = Secondary chart instrument")]
        [GridCategory("Parameters")]
        // Force this parameter to be displayed second
        [Gui.Design.DisplayName ("\t\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(); }
        }
        Last edited by kdoren; 01-12-2010, 01:29 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        621 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        359 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        562 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        567 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X