Announcement

Collapse
No announcement yet.

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.

    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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        82 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        43 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        68 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        56 views
        0 likes
        Last Post CarlTrading  
        Working...
        X