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

How to find the right most bar Idx (Index)

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

    How to find the right most bar Idx (Index)

    Hi!

    I've been struggling to find the right most bar index.

    ie. If the last price is on the right side of the chart, right most index is 0.
    ie. If the user scrolls back in time, so the 10th bar is on the right side, it will return 10.

    Tried:

    chartMaxBars = ChartBars.ToIndex;
    chartWidthPixels = myChartScale.Width ;
    rightMostPixel = chartWidthPixels - 1;
    rightMostIndex = ChartBars.GetBarIdxByX(ChartControl, Convert.ToInt32(rightMostPixel));

    #2
    Hello Clydewallace,

    Thanks for your post.

    I think you are looking for ChartBars.ToIndex. "An index value representing the last bar rendered on the chart. "

    reference: http://ninjatrader.com/support/helpG...rs_toindex.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul.

      I am encountering some very strange behavior. Adding .ToIndex, and even using the sample code from the link you provided is causing NT8 to hard crash. Nothing in the log. And even trying to catch errors with a Try{}Catch does not prevent a hard crash.

      Comment


        #4
        Hello Clydewallace,

        Thanks for your reply.

        Are you using the latest version 8.0.6.1?

        Please run the attached indicator which is the exact sample only and test for the issue. If the issue repeats, please create a new workspace and a single simple chart with no templates and no indicators, please be sure to completely close all other workspaces to isolate.
        Attached Files
        Last edited by NinjaTrader_PaulH; 05-17-2017, 09:46 AM.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Kaledus, Today, 01:29 PM
        0 responses
        3 views
        0 likes
        Last Post Kaledus
        by Kaledus
         
        Started by PaulMohn, Today, 12:36 PM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by yertle, Yesterday, 08:38 AM
        8 responses
        37 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by rdtdale, Today, 01:02 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by alifarahani, Today, 09:40 AM
        3 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X