• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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().
    http://ninjatrader.com/support/helpG...bybarindex.htm
    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 xsgex, Yesterday, 09:46 PM
                0 responses
                2 views
                0 likes
                Last Post xsgex
                by xsgex
                 
                Started by Steve L, Yesterday, 09:36 PM
                0 responses
                3 views
                0 likes
                Last Post Steve L
                by Steve L
                 
                Started by krugman25, Yesterday, 09:34 PM
                0 responses
                4 views
                0 likes
                Last Post krugman25  
                Started by indy73, Yesterday, 04:42 PM
                0 responses
                15 views
                0 likes
                Last Post indy73
                by indy73
                 
                Started by Italianforex, Yesterday, 06:20 AM
                2 responses
                13 views
                0 likes
                Last Post gplatis
                by gplatis
                 
                Working...
                X