Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coding help please

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

    Coding help please

    Hi,
    I have been studying c# for a couple of months now and have coded one successful indicator thus far. I am now attempting to code a fairly complex tool in Ninja but have been having trouble getting it started so I figure I'll try to learn all the little bits and pieces simply, and separately so that it should become easier to put it all together.

    So here goes: Using mouse clicks, I would like to draw a ray, say from a high through a low on a bar chart.
    The X (price), and Y (time), values are important and are to be used in other calculations, for other functions in the code.
    So I`m thinking I`d like to store these as variables? Would that be the way to go?
    I have seen the DrawRay() method and IRay object in the help file. I think this is what I should probably use, but am uncertain as to how exactly to use them for my purpose.
    I`d love it if someone can give me further explanation than what the help file does?
    The other part of this code that is troubling me is the mouse events.
    What would the code look like to achieve what I need here?

    Thanks,
    Ken.

    #2
    No. You do not need to store them any where. See this sample.

    Comment


      #3
      The file wouldn`t import

      Originally posted by sledge View Post
      No. You do not need to store them any where. See this sample.

      http://www.ninjatrader.com/support/f...d=4&linkid=472
      The file wouldn`t import into Ninja or VS.

      Comment


        #4
        Originally posted by KennyK View Post
        The file wouldn`t import into Ninja or VS.
        Oh. Strange. What was the error?

        Well, at any rate, unzip the file and open up the indicator in a notepad.

        Comment


          #5
          Originally posted by sledge View Post
          Oh. Strange. What was the error?

          Well, at any rate, unzip the file and open up the indicator in a notepad.
          The error was that the zip file didn`t contain any Ninjascript files.
          However I deleted the first download and downloaded it again and was able to open it in VS.

          Having done so I can`t see the similarities in that code to what I am seeking to do.
          Also it appears that variables are used in that code to store the X & Y values, contrary to what you said earlier.

          But that`s for trying to help.

          Comment


            #6
            Any one else able to assist?

            Any one else able to assist?
            Originally posted by KennyK View Post
            Hi,
            I have been studying c# for a couple of months now and have coded one successful indicator thus far. I am now attempting to code a fairly complex tool in Ninja but have been having trouble getting it started so I figure I'll try to learn all the little bits and pieces simply, and separately so that it should become easier to put it all together.

            So here goes: Using mouse clicks, I would like to draw a ray, say from a high through a low on a bar chart.
            The X (price), and Y (time), values are important and are to be used in other calculations, for other functions in the code.
            So I`m thinking I`d like to store these as variables? Would that be the way to go?
            I have seen the DrawRay() method and IRay object in the help file. I think this is what I should probably use, but am uncertain as to how exactly to use them for my purpose.
            I`d love it if someone can give me further explanation than what the help file does?
            The other part of this code that is troubling me is the mouse events.
            What would the code look like to achieve what I need here?

            Thanks,
            Ken.

            Comment


              #7
              KennyK

              I don't want to get too involved in this but 2 months and mouse click x and y cords.... not easy.
              This is some play code that I did a while back - there's lots of redundant stuff in there but essentially it places a buy or sell order at the mouse click price.
              NB DO NOT USE THIS ON YOUR ACTUAL ACCOUNT. Play with it in Sim and read the notes at the top.

              Hope it's helpful and gives you a starting point.
              Attached Files

              Comment


                #8
                Thankyou, however it isn`t particularly helpful, sorry.

                Thankyou, however it isn`t particularly helpful, sorry.
                Originally posted by Mindset View Post
                KennyK

                I don't want to get too involved in this but 2 months and mouse click x and y cords.... not easy.
                This is some play code that I did a while back - there's lots of redundant stuff in there but essentially it places a buy or sell order at the mouse click price.
                NB DO NOT USE THIS ON YOUR ACTUAL ACCOUNT. Play with it in Sim and read the notes at the top.

                Hope it's helpful and gives you a starting point.

                Comment


                  #9
                  Hi Kenny, closest example probably for you would be this one in our sharing - http://www.ninjatrader.com/support/f...d=4&linkid=435

                  Drawing tool creation will be fully supported to create in our next major platform update.

                  Comment


                    #10
                    Thanks Bertrand,
                    I have that one, and have been studying the code, however it seems to be quite messily put together and makes it hard to follow what is really going on in the code.
                    You say drawing tool creation will be fully supported in NT8, when will it be available????????
                    I have not yet had a reply that addresses my questions so I may not have worded it clearly perhaps I should ask one question at a time?
                    Question #1. Can anyone give me a better explanation of how to use the DrawRay() method and the IRay object than what the help file does please?
                    Ken.

                    Comment


                      #11
                      Ken, currently there's no ETA on our next major update, we expect that to be available though in the next coming months. I would not have another sample unfortunately to point you to, officially working with mouse inputs would not be a supported area yet, as it would require deeper C# custom coding.

                      What question would you have on the DrawRay exactly?

                      The available overloads for its creation are listed here - https://www.ninjatrader.com/support/...t7/drawray.htm

                      The associated IRay object would let you change / access the objects properties then programmatically.

                      Comment


                        #12
                        Bertrand,
                        If I was to draw a Ray on the chart via mouse clicks, would the price and time values of both anchor points be available through the IRay object?
                        Ken.

                        Comment


                          #13
                          Originally posted by KennyK View Post
                          Bertrand,
                          If I was to draw a Ray on the chart via mouse clicks, would the price and time values of both anchor points be available through the IRay object?
                          Ken.
                          Yes, but you have to iterate through all the DrawObjects on the chart, and isolate the one that you want. Then you can query its properties.

                          ref: http://www.ninjatrader.com/support/h...rawobjects.htm

                          Comment


                            #14
                            Originally posted by KennyK View Post

                            Having done so I can`t see the similarities in that code to what I am seeking to do.
                            Also it appears that variables are used in that code to store the X & Y values, contrary to what you said earlier.

                            But that`s for trying to help.
                            Seriously?

                            Comment


                              #15
                              Originally posted by sledge View Post
                              Seriously?
                              Sorry Sledge, that last line was meant to read "Thanks for trying to help", not "That`s for trying to help".

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              571 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              330 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              548 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              549 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X