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

Wrong bar index.

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

    Wrong bar index.

    Hello.

    When I try to get bar index by
    Code:
     ChartControl.GetSlotIndexByX(X)
    sometimes I get wrong bar index. Sometimes it misses bar I'm not sure why.
    I've also tried
    Code:
    ChartBars.GetBarIdxByX(ChartControl,X);
    X coordinate I obtain from mouse click -
    Code:
    GetPosition(ChartControl).X
    .
    The issue occurs only on one PC.
    On others PCs it works well.

    Listed below is my code.

    Code:
    void OnLeftClick(object sender,MouseEventArgs mouse)
    {
    SplitFromCLick((int)mouse.GetPosition(ChartControl).X(float)mouse.GetPosition(ChartControl).Y);
    }	
    public void SplitFromCLick(int X, float Y)
    {
     Print(String.Format("bar_index {0}",ChartControl.GetSlotIndexByX(X)));
    }
    Last edited by blekdzhon; 06-29-2017, 10:33 PM.

    #2
    Hello,

    Thank you for the post.

    To find specific Bars, you should be using GetBarIdxByX.


    GetSlotIndexByX would return the area that can hold a bar which may or may not contain the bar in question.


    Have you tried using the example from the first link and how it gets the mouse point? ChartControl.MouseDownPoint



    If that does not aid in correcting the problem, could you provide an example as a .cs file that I could test to see the specific syntax and how it is used?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Did you finally resolve this? I have the same issue on one PC, but not on the other

      Comment


        #4
        Originally posted by stnk56 View Post
        Did you finally resolve this? I have the same issue on one PC, but not on the other
        Hi. Yes I use the following function to obtain correct x coordinate.
        Code:
        ChartingExtensions.ConvertToHorizontalPixels(mouse.GetPosition(ChartPanel as IInputElement).X, ChartControl.PresentationSource);

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        21 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X