Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Drawing Tool

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

    Custom Drawing Tool

    I'm looking to be pointed in the right direction regarding creating a custom drawing tool (or adding to an existing one).

    For example, taking the simple line tool and adding a new, optional parameter to output the line's angle, "rise over run", just as an example. (I don't need help with the calculations, just how to add any new functionality/parameters to an existing tool)

    Is it possible to expand/add to the existing drawing tools or do I need to completely create a new "line tool" that has my custom additions? (it's be great if I could do both!)

    I understand that the drawing tools are located within "\bin\Custom\DrawingTools". Where is a good place to start? Create my own CS file in that directory? If I create my own, how do I add it to the drawing tool drop down?

    Are there any examples of this to reference? (I couldn't find any) Thanks!

    As an aside, I'm sure you're aware of the odd behavior/bug when drawing a line into the future bar area.

    Any help is greatly appreciated!

    #2
    You can add to an existing drawing tool but keep in mind that when you have to re-install or update you will lose that addition. In, this case it is easier to create a new one. You can copy and paste the existing line tool and rename it, so it doesn't conflict in the code.

    A good place to start is read over the existing ones in the editor and see how they are built and used for the functionality. You can then use the help guide (WIP) for any terms you don't understand.

    Additionally, they will automatically get added to the drop down so long as it is located in the DrawingTool folder.

    There is a property you can set in the SetDefaults state of the drawing tool so that it does or doesn't appear on the drop down menu - DisplayOnChartsMenus

    I know I have reported that bug and I think others as well. As, to the nature of where it stands we will need to let NT answer that for us.

    I have done a bunch of drawing tools already so if you have any questions on them feel free to ask

    Comment


      #3
      Thanks for the quick reply! Yeah, I was really hoping to not edit existing CS files, but merely extend/add functionality via my own CS file. Perhaps that is not possible.

      How do you define the icon that appears in the drop down? Have you been able to create your own, custom drop down (completely separate from the drawing tools one)?

      Do you have any "hello world" (or better) type drawing tools you could share?

      Thanks!

      Comment


        #4
        Yeah not really feasible for this.

        I haven't been able to add it in the Menu item for the Drawing tools but as for a separate drop down yes but I don't have sample code readily available for it (currently away from home)

        I'll try to get some sample stuff together for ya but the best thing you can do now is check out the Line Drawing tool. Lots of good info there on the methods and how its all being handled with inheritance.

        Comment


          #5
          Attached is a very simple Drawing Tool which just displays Text "Hello World" on the chart, similar to the manner a ChartMarker work. I think this should help understand how the different OnMouse events, Drawing States, and getting selection points should work.

          Beyond the NT8 beta documentation, setting breakpoints in Visual Studio is a great a way to run through these various events to get an idea of what is going.

          If you want to render more advanced objects than just simple text, please refer to the Lines as Calonious suggested. All rendering is done through the SharpDX API, there is additional documentation for those unique methods and classes on their site.

          The default behavior of a drawing tool will show up on the menu. Around line 200 is how you can customize/override the Icon object. I just use a simple unicode character, but there's a lot you can do here if you're so inclined

          Code:
          public override object Icon
          {         
             get 
             {
                //use a unicode character as our string which will render a unique character
                string uniCodeArrow = "\u0E4F";            
                return uniCodeArrow; 
             }   
          }
          Attached Files
          MatthewNinjaTrader Product Management

          Comment


            #6
            Thank you for all the help. I've created my custom line drawing tool, but have a couple more questions.

            Is there a flag to set to make an individual line object "snap to bar"? I can do it manually, but that leads me to my next question...

            Is seems simple enough, but how do you access the bars? It seems as if the OHLC data series are not accessible.

            Is there a clean way to add a hot key and make it display in the Drawing Tools drop down? I figured out a more brute force method for NT7, but would be nice if it was more integrated.

            Thanks again!

            Comment


              #7
              Originally posted by neoikon View Post
              Is there a flag to set to make an individual line object "snap to bar"? I can do it manually, but that leads me to my next question...
              You cannot force a drawing tool to use "snap to bar" as this is a chart setting, but what you can do is use the IgnoresSnapping = true, which would ignore whatever the user has set, and then program in your own snaplogic. When you set your anchor, just do a quick test to see where the anchor is relation to a bar, and if offset, just move the anchor to the nearest bar.


              Originally posted by neoikon View Post
              Is seems simple enough, but how do you access the bars? It seems as if the OHLC data series are not accessible.
              Use the GetChartBars() method where you can obtain the absolute index of those series

              Code:
              double high = GetAttachedToChartBars().Bars.GetHigh(idx);
              Originally posted by neoikon View Post
              Is there a clean way to add a hot key and make it display in the Drawing Tools drop down? I figured out a more brute force method for NT7, but would be nice if it was more integrated.
              Your custom drawing tool should be automatically added to the Hot Keys manager so you can define your own hot key combo through this window. There is no way to programmatically assign a specific hot key combo because it's pretty likely that two will conflict - we leave it up to the end user to define their hot keys.
              MatthewNinjaTrader Product Management

              Comment


                #8
                unable to find source code mentioned

                found this thread, which is useful, thanks guys - and I am looking to do something similar, except rather than modify the existing Line, I want to modify the existing Fibonacci retracements and expansions.

                However, having done exhaustive searches of my installed copy of NinjaTrader, I cannot find a "DrawingTools" folder in "C:\Program Files (x86)\NinjaTrader 7\".

                I found the source code for the Indicators (eg Documents\bin\Custom\[email protected]) in the 'Documents\NinjaTrader 7' folder, as well as those for MarketAnalyser, Strategy and Type.

                However, I cannot find the source code for any of the Drawing Tools anywhere on my PC. Can someone point me to their location please?

                Comment


                  #9
                  This is because its not available for NT7 this is only available for NT8 which is in closed beta currently

                  Comment


                    #10
                    Hello DamoL,

                    Thank you for your post and welcome to the NinjaTrader Support Forum!

                    Calonious is correct, custom drawing tools are not supported in NinjaTrader 7.

                    Comment


                      #11
                      Originally posted by NinjaTrader_Matthew View Post
                      You cannot force a drawing tool to use "snap to bar" as this is a chart setting, but what you can do is use the IgnoresSnapping = true, which would ignore whatever the user has set, and then program in your own snap logic. When you set your anchor, just do a quick test to see where the anchor is relation to a bar, and if offset, just move the anchor to the nearest bar.
                      .
                      As one who is creating custom drawing tools, I would like to see NT8 expand the already provided snapping capabilities for tools. IgnoresSnapping = true, Why can I only go one way with this. I would think it should be Snapping = true or false. or OverrideSnapping = Snap or NoSnap. So, currently I need to insure all charts are using Snapping. Not a big deal, but giving a tool the ability to choose to snap or not is much more flexible. One of the tools I am working on create angles / lines into the future, and being off a bar can lead to close, but false assumptions.

                      Just my 2 cents

                      John

                      Comment


                        #12
                        Hello joromero,

                        Thank you for your response.

                        The Snappping is for all drawing objects on the chart, so ignoring it gives you the option to always behave a certain way.

                        What are you looking for instead? Would it be more like setting the snapping mode as a hard coded and unchangeable setting for the individual drawing tool?

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bmartz, 03-12-2024, 06:12 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_Zachary  
                        Started by Aviram Y, Today, 05:29 AM
                        4 responses
                        13 views
                        0 likes
                        Last Post Aviram Y  
                        Started by algospoke, 04-17-2024, 06:40 PM
                        3 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by gentlebenthebear, Today, 01:30 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by cls71, Today, 04:45 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X