• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Access Close[5] for a TimeSeries added manually to chart, not via Add()?

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

    How to Access Close[5] for a TimeSeries added manually to chart, not via Add()?

    Hello,

    I have a single-TimeSeries indicator that I've applied to a chart with one data series (SPY), and I can access my indicator's Closes[0][5] with no problem.

    However, when I manually add a second TimeSeries to the chart (GLD) by right clicking on the NinjaTrader Chart and choosing a second TimeSeries, this second time series is not also added to the indicator on the chart, so when I call Closes[1][5] from within my indicator, an exception is thrown because my indocator still only has 1 TimeSeries.

    How can I access TimeSeries data for the second series added manually to the chart, for instance how can I get the value for the GLD Close 5 bars ago, like Closes[1][5]?

    I noticed that the ChartControl property of my indicator has meta-data about both time series in its Bars and BarsArray properties, such as the COUNT of the GLD and SPY bars, but I can't find a collection of actual TimeSeries data, like Closes or Highs, in either the Indicator properties or the indicator's CharetControl properties.

    Any ideas?

    Thanks in advance!

    EquityTrader

    #2
    Hello EquityTrader,
    Thanks for your note.

    Unfortunately there are no supported way of doing it. You can however use the unsupported ChartControl class to access the manually added Bar array on the chart. A sample code will be like

    Code:
    if (ChartControl.BarsArray >=2) ChartControl.BarsArray[1].GetClose(idx);
    The ChartControl class is not supported and thus not documented.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_Joydeep,

      This worked perfectly! Thank you so much!

      EquityTrader

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Fernand0, Today, 07:12 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by peter chang, Today, 07:02 AM
      2 responses
      11 views
      0 likes
      Last Post peter chang  
      Started by Ringo, Today, 04:50 AM
      0 responses
      12 views
      0 likes
      Last Post Ringo
      by Ringo
       
      Started by zulok, Today, 04:44 AM
      0 responses
      9 views
      0 likes
      Last Post zulok
      by zulok
       
      Started by Skyfly1715, Yesterday, 03:36 PM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Marco  
      Working...
      X