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

Converting X- Coordinate from Double to Integer

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

    Converting X- Coordinate from Double to Integer

    Dear Support,

    I want to use the available X-Coordinate, firstX from the following:

    Code:
    				startPointDX = new SharpDX.Vector2((float)firstX, (float)y);
    How to convert the above firstX from double to integer to draw a conventional ray (Draw.Ray) at that point?

    I can not find conversion script in Help.

    Thanks

    #2
    Hello aligator,


    To convert a double to an integer cast it.

    double myDouble = (int)firstX;


    You haven't mentioned this, but, are you trying to get a bar number from an x position?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello aligator,


      To convert a double to an integer cast it.

      double myDouble = (int)firstX;


      You haven't mentioned this, but, are you trying to get a bar number from an x position?
      Thanks ChelseaB,

      Yes, I am trying to use a DX x-position for Draw.Ray. However, the x.position needs to be converted to int as a bar number to start the Ray.

      I assume that is possible since ninja DX does not have non-geometric ninja draw objects (without complicated coding).

      Thanks.

      Comment


        #4
        Hello aligator,

        You are posting in the NinjaTrader 7 section of the forums..

        Is this for NinjaTrader 7?

        Overriding the Plot method for custom GDI+ graphics was not officially supported for NinjaTrader 7 so there isn't any documentation on converting x values to bar numbers or vice versa and I'm actually not aware of a way to do this..

        This is documented for NinjaTrader 8 which does support custom rendering.

        This thread will remain open for any community members that would like to assist.

        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello aligator,

          You are posting in the NinjaTrader 7 section of the forums..

          Is this for NinjaTrader 7?

          This is documented for NinjaTrader 8 which does support custom rendering.
          Thank You, ChelseaB

          My bad, posting in NT7 by mistake. My question was for NT8. Can you point me to NT8 documentation for converting a double to integer?

          Thanks.

          Comment


            #6
            Hlelo aligator,

            Thank you for your response.

            You can use the ChartBars.GetBarIdxByX(chartControl, yourVector2.X): https://ninjatrader.com/support/help...tbaridxbyx.htm

            Please let me know if you have any questions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by elirion, Today, 01:36 AM
            0 responses
            3 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            2 views
            0 likes
            Last Post gentlebenthebear  
            Started by samish18, Yesterday, 08:31 AM
            2 responses
            9 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by Mestor, 03-10-2023, 01:50 AM
            16 responses
            389 views
            0 likes
            Last Post z.franck  
            Started by rtwave, 04-12-2024, 09:30 AM
            4 responses
            33 views
            0 likes
            Last Post rtwave
            by rtwave
             
            Working...
            X