Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetSlotIndexByX produces only -1

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

    GetSlotIndexByX produces only -1

    Hi,

    the title sums up my problem; no matter what values I use for X I only get -1 as a result, even just using the code in the NT8 Help:

    [CODE]protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    // Find the index of the bar painted at x-coordinate 35
    double slotIndex = chartControl.GetSlotIndexByX(35);

    // Print the slot index of the specified time
    Print(slotIndex);
    }[/CODE

    Is there something else I need?

    #2
    Hello,

    Thank you for the question.

    I tried this sample but do see it working on my end.

    Would you mind attaching the actual script along with the specifics on the chart/instrument/settings used to test?

    I tested this using the ES 12-15 1min on Kinetick data, could you provide more details on this for me to further test or try to re create?

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

    Comment


      #3
      Jesse, thanks for the response.

      Could you try it with equidistant bar spacing turned off? I think that might be the relevant factor in getting the -1 result.

      With equidistant spacing turned on, it generally works, provided I don't have any extra space in the chart's right margin. With extra space, it plots increasingly incorrect values as x moves to the right, with the slotindex increasingly lagging the actual bar - i.e., it seems to be pegged to the canvas size rather than where the bars actually are.

      Comment


        #4
        Hello,

        Thank you for the reply.

        Yes this would be correct thinking, the equidistant bar spacing is the factor in what is happening.

        I needed to get clarification on this as I was unsure based on the help guide, it seems to be the case so the help guide will be updated. This would only work with equidistant spacing set to true, otherwise the "Slot" methods would return a -1.

        Regarding the margin, can you provide a specific example that causes this? I would just need the margin amount and syntax you are using to see that it is plotting off if possible.

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

        Comment


          #5
          Jesse,

          I'm using exactly the syntax above, the greater the right margin the greater the error. Try using a value of 100 or more. But it's easier to see what's going on if you use the mouse to input an x value in order to move it around quickly.

          I now have a workaround, which involves getting the x value for the last and first bars painted and working from there, which works fine. But it seems the NT method ought to account for the bar margin.

          Comment


            #6
            Hello,

            Thank you for the reply.

            In this case this would be the nature of this method. Being that this is dealing with pixels instead of an index, that would mean any changes to the charts size, margins or anything where the bars need moved would effect the value this produces. This would be 35 pixels from the chart edge and then whatever slot is under that location would be picked.

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by philmg, Today, 12:55 PM
            0 responses
            1 view
            0 likes
            Last Post philmg
            by philmg
             
            Started by Russ Moreland, Today, 12:54 PM
            0 responses
            1 view
            0 likes
            Last Post Russ Moreland  
            Started by f.saeidi, Today, 12:14 PM
            2 responses
            5 views
            0 likes
            Last Post f.saeidi  
            Started by TradeForge, 04-19-2024, 02:09 AM
            2 responses
            28 views
            0 likes
            Last Post TradeForge  
            Started by aprilfool, 12-03-2022, 03:01 PM
            3 responses
            327 views
            0 likes
            Last Post NinjaTrader_Adrian  
            Working...
            X