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 gm7_forum, Today, 05:51 PM
        0 responses
        1 view
        0 likes
        Last Post gm7_forum  
        Started by cre8able, Today, 03:20 PM
        1 response
        9 views
        0 likes
        Last Post cre8able  
        Started by fiddich, Today, 05:25 PM
        0 responses
        3 views
        0 likes
        Last Post fiddich
        by fiddich
         
        Started by gemify, 11-11-2022, 11:52 AM
        6 responses
        804 views
        2 likes
        Last Post ultls
        by ultls
         
        Started by ScottWalsh, Today, 04:52 PM
        0 responses
        4 views
        0 likes
        Last Post ScottWalsh  
        Working...
        X