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

Custom Drawing Tool Get X by SlotIndex

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

    Custom Drawing Tool Get X by SlotIndex

    How can I get the X coordinate by ChartAnchor.SlotIndex?

    If ChartAnchor.SlotIndex = 64.356987 and then I round it to the nearest int by Convert.ToInt32(64.356987) giving a value of 64, how can I get the X of SlotIndex(64).

    For an indicator it would be
    double
    xCoordinate=chartControl.GetXByBarIndex(ChartBars,100);
    where BarIndex is basically the same as SlotIndex.
    But you can not use that in a DrawingTool.

    #2
    Hello TAJTrades,

    You can use ChartControl.GetXByBarIndex().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello TAJTrades,

      You can use ChartControl.GetXByBarIndex().
      http://ninjatrader.com/support/helpG...bybarindex.htm
      In a DrawingTool copy and paste that code throws Error:
      'NinjaTrader.Gui.ChartBars' is a 'type' but is used like a 'variable'

      I also tried:
      Bars bars = GetAttachedToChartBars().Bars
      double xCoordinate = chartControl.GetXByBarIndex(bars, 100);
      Throws error:
      Argument1: cannot convert from 'NinjaTrader.Data.Bars' to 'NinjaTrader.Gui.ChartBars'

      I am not sure what the error message is telling me. Apparently Bars aren't all the same. I have tried a few other code combination but had no success.

      It would appear that what can be used for an Indicator is off limits for a DrawingTool. My guess is that it has something to do with WPF Point and SharpDX Point. Any suggested workarounds to get X By Slot Index for a drawing tool?

      Comment


        #4
        Hi TAJTrades,

        I'm not sure on this one and I will have to do some testing.

        I appreciate your patience.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea,
          No issues here. I know I am one of the few NT Users that is more interested in DrawingTools development than most as that is the mainstay of my trading. Ideally NT Development crew will build in some more functionality for DrawingTools. I would be more than happy to offer up some suggestions and be a tester in that department. Currently I am stuck on a real brain teaser that Jesse is working with me to create some type of solution. If you want to do a little cerebral stressing get up with Jesse.

          Appreciate your help.

          Comment


            #6
            Hi TAJTrades,

            Our lead has suggested to not specify the Bars property from the attached chart bars.

            (edit)
            Code:
            ChartBars bars = GetAttachedToChartBars();
            double xCoordinate = chartControl.GetXByBarIndex(bars, 100);
            (Just a heads up, this may not be good to use if you have multiple series in your script)
            Last edited by NinjaTrader_ChelseaB; 08-09-2017, 08:27 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hi TAJTrades,

              Our lead has suggested to not specify the Bars property from the attached chart bars.

              Bars bars = GetAttachedToChartBars;
              double xCoordinate = chartControl.GetXByBarIndex(bars, 100);

              (Just a heads up, this may not be good to use if you have multiple series in your script)
              Not sure I understand. Is he suggesting to not use Bars bars anywhere in the DrawingTool script?

              I f so, then how would I be able to get the Highest Bar Price of the bars within the rectangle? The suggestion would eliminate the use of bars.GetHIgh(SlotIndex); How would I go about getting the highest price?

              EDIT:
              Just to check I commented out all code Bars bars = GetAttachedToChartBars;
              used doublexCoordinate=chartControl.GetXByBarIndex(ChartBars,100); in MouseDown and OnRender. The results were exactly what I expected. Both had Error "NinjaTrader.Gui.Chart.ChartBars is a 'type' but is used like a 'variable'.

              Is it possible to somehow cast ChartBars as a variable?

              Is the any plans in the works to provide a method to get the X By SlotIndex? It would be very useful for DrawTools development.
              Last edited by TAJTrades; 08-08-2017, 06:08 PM.

              Comment


                #8
                Hello TAJTrades,

                I had to correct that in post #6.

                Should work. (Just tested)
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by algospoke, Today, 06:40 PM
                0 responses
                10 views
                0 likes
                Last Post algospoke  
                Started by maybeimnotrader, Today, 05:46 PM
                0 responses
                7 views
                0 likes
                Last Post maybeimnotrader  
                Started by quantismo, Today, 05:13 PM
                0 responses
                7 views
                0 likes
                Last Post quantismo  
                Started by AttiM, 02-14-2024, 05:20 PM
                8 responses
                168 views
                0 likes
                Last Post jeronymite  
                Started by cre8able, Today, 04:22 PM
                0 responses
                10 views
                0 likes
                Last Post cre8able  
                Working...
                X