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

ChartBars.GetBarIdxByX(chartControl, cursorPointX)

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

    ChartBars.GetBarIdxByX(chartControl, cursorPointX)

    Hello,

    Something is strange. I did a for loop:

    Code:
    for(int barIndex = ChartBars.GetBarIdxByX(chartControl, cursorPointX); barIndex <= index1; barIndex++)
                    {
                    }
    When i click on the chart to know what bar is clicked i use
    Code:
      int clickedBarIndex = (ChartBars.GetBarIdxByX(chartControl, cursorPointX));
    and it return the right clicked bar. 4700

    But Printing barIndex in the for loop return the wrong bars. How is it possible?

    For exemple, clickedBarIndex = 4700 but the for loop return bars 4750 to 4800. 4800 is index1. It should return bars 4700 to 4800 ??

    Ty

    #2
    Hi frankduc, thanks for your question.

    You should try Printing the values from the for loop to make sure they are matching up with expectations. Print out the value of ChartBars.GetBarIdxByX(chartControl, cursorPointX) and that will confirm what the for loop is iterating on.

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      my bad wrong variable at the wrong place

      Comment


        #4
        Just one thing bothering me.

        In
        Code:
        string textString = "BarsIndex:" + clickedBarIndex.ToString() + "\nTime:" + timeValue.ToString("H:mm:ss") + "\nclist:" + clist[c].ToString("N4");
        I can get in the chart the clist but color red is flashing turning pale red to bold red from time to time. Any idea why?

        Comment


          #5
          Hello frankduc, thanks for your reply.

          I apologize, I must ask for more context. What is clist and what component of the chart is turning different colors unexpectedly?

          I look forward to hearing from you.
          Chris L.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          32 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          4 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          19 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          6 views
          0 likes
          Last Post cre8able  
          Started by Haiasi, Today, 06:53 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X