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 zstheorist, Today, 07:52 PM
        0 responses
        3 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        149 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        5 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        5 views
        0 likes
        Last Post tkaboris  
        Working...
        X