• 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

Last Bar on Chart in Multi Series Environment

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

    Last Bar on Chart in Multi Series Environment

    Hi,

    I know this is not supported but I thought I'd ask in case someone knows. If you have a single data series on a chart then you can get the last bar on the chart from

    int lastBar = Math.Min(this.ChartControl.LastBarPainted, this.ChartControl.Bars.Count - 1);

    What is the equivalent if you have multiple series on a single chart? I tried

    int lastBar = Math.Min(this.ChartControl.BarsArray[1].LastBarIdx, this.ChartControl.BarsArray[1].Count - 1);

    and this does not work as
    this
    .ChartControl.BarsArray[seriesIndex].LastBarIdx
    always returns -1.

    Any thoughts would be greatly appreciated. Thank you.

    #2
    Hello Zeos6,

    You may want to switch using Closes[], Opens[], Highs[]. and Lows[] to better access data in a Multi-Series NinjaScript.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thank you for the reply but the reply does not even come close to answering the question. The question is:

      If you have multiple series on a single chart, how do you calculate the last bar on the chart for each of the series?

      Thank you.

      Comment


        #4
        Hello,
        Originally posted by Zeos6 View Post
        If you have multiple series on a single chart, how do you calculate the last bar on the chart for each of the series?
        Perhaps we need some further clarification as to what you're trying to achieve.

        Based on this statement you would need to use Add() to add the other series to the indicator/strategy and then you would use BarsInProgress, Closes[][], Highs[][], etc to access the different values.

        For using multiple series: http://www.ninjatrader.com/support/h...nstruments.htm

        Example of getting the closing value for the last bar on a chart with multiple series: http://www.ninjatrader.com/support/h...tml?closes.htm

        Please let me know if I can be of further assistance.
        LanceNinjaTrader Customer Service

        Comment


          #5
          Thanks for the reply Lance. I understande about Closes[][], Highs[][] but the issue is simple. If I have a single series on a chart I can calculate the last bar on the chart as indicated:

          int lastBar = Math.Min(this.ChartControl.LastBarPainted, this.ChartControl.Bars.Count - 1);

          What is the equivalent for each data series if you have multiple series on a single chart? BarsInProgress will not work since the series are being added manually rather than programatically via Add().

          Alternativelly, what is the equivalent for ChartControl.LastBarPainted for the second or third series in a scenario of multiple series added manually onto the same chart?

          Comment


            #6
            Hello,

            Unfortunately I would only have guesses as to where you would begin with this.

            Try comparing the Count and CurrentBar for each BarsArray
            Code:
            bool[] lastBars = new bool[BarsArray.Length];
            for (int x = 0 ; x < BarsArray.Length; x++)
            lastBars[x] = CalculateOnBarClose ? CurrentBar == Count - 2 : CurrentBar == Count - 1;
            Please be aware I have not tested the above code and will not be able to provide further support on this

            I would suggest you post this question in this thread as you may find some further guidance there: http://ninjatrader.com/support/forum...ad.php?t=22435
            LanceNinjaTrader Customer Service

            Comment


              #7
              Thank you very much Lance. I appreciate this and will play with it.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by saltminer, Today, 11:06 PM
              0 responses
              5 views
              0 likes
              Last Post saltminer  
              Started by saltminer, Today, 10:14 PM
              0 responses
              5 views
              0 likes
              Last Post saltminer  
              Started by Mykro, Today, 10:03 PM
              0 responses
              4 views
              0 likes
              Last Post Mykro
              by Mykro
               
              Started by coolTrade, Today, 09:37 PM
              0 responses
              7 views
              0 likes
              Last Post coolTrade  
              Started by PatrickM, Today, 08:43 PM
              0 responses
              8 views
              0 likes
              Last Post PatrickM  
              Working...
              X