Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Aviram Y, Today, 05:29 AM
              0 responses
              5 views
              0 likes
              Last Post Aviram Y  
              Started by quantismo, 04-17-2024, 05:13 PM
              3 responses
              27 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by ScottWalsh, 04-16-2024, 04:29 PM
              7 responses
              36 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cls71, Today, 04:45 AM
              0 responses
              6 views
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              219 views
              1 like
              Last Post PaulMohn  
              Working...
              X