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

How to Invoke a Custom Drawing Tool From Code

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

    How to Invoke a Custom Drawing Tool From Code

    I am trying to modify the Shortcut Toolbar by NinjaAddons.com to include custom Drawing Tools.

    The original code is located here:
    HTML Code:
    https://ninjatraderecosystem.com/user-app-share-download/shortcut-toolbar-by-ninjaaddons-com/
    I am able to pull the custom tools from the Drawing Tools menu using the NTMenuItem.ItemCollection, like the original code does for the standard tools.

    The Addon uses the NTMenuItem.Command property for each tool to invoke the drawing tool from the new sidebar menu. My problem is the NTMenuItem.Command property is null for any custom tool, so I am not able to use this to invoke the tool from the Addon sidebar menu.

    The custom tools are invoked just fine from the Drawing Tool menu. So I have a couple of questions:

    1) How does the Drawing Tool menu invoke Custom Drawing Tools?
    2) How can I invoke a Custom Drawing Tool with code?

    The code I added for the custom tools, mirrors the code for the standard tools.
    Code:
    public class NinjaAddonsToolBar : AddOnBase
    {[INDENT]private string[] CUSTOMTOOL_HEADERS = new string[3] { "Risk Reward 3", "Measured Move", "Horizontal Line Segment" };
    [/INDENT][INDENT]// existing code [/INDENT][INDENT]protected override void OnWindowCreated(Window window)
    {[/INDENT][INDENT=2]// existing code
    
    #region -- Add Custom Tools --
    else if (CUSTOMTOOL_HEADERS.Contains(mnItem.Header.ToString()))
    {[/INDENT][INDENT=3]verticalStackPanel.Children.Add(new NTMenuItem()[/INDENT][INDENT=4]{
    ToolTip = mnItem.Header,
    Style = mnItem.Style,
    Icon = mnItem.Icon,
    [COLOR=#c0392b][B]Command = mnItem.Command,[/B][/COLOR]
    Margin = new Thickness(1),
    Width = ITEM_WIDTH,
    HorizontalAlignment =
    HorizontalAlignment.Left
    });[/INDENT][INDENT=3]}[/INDENT]

    Thanks, Greg
    The Trading Mantis
    NinjaTrader Ecosystem Vendor - The Trading Mantis

    #2
    Hello Greg,

    You may want to contact the original author for further details about the unsupported / undocumented custom code.

    The custom drawing tools do not have a supported way of creating a command.

    Below is a link to a thread on this topic.


    The other approach is to find the hotkey from the NinjaTrader.Gui.HotKeys.IHotKeysContainer, but custom drawing objects also will not have a system hotkey.

    Unfortunately, I'm not aware of a work around for this.



    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,

      The info you provided was very helpful!

      Using a hot key will allow me to work around this. I'll just have to hard code the hot key for each custom tool, instead of pulling it from the IHotKeysContainer.

      I'll post another reply, which includes the workaround, once I have the coding worked out.
      The Trading Mantis
      NinjaTrader Ecosystem Vendor - The Trading Mantis

      Comment


        #4
        Here is an updated code file that use SendKeys (with the tool's hotkey) to invoke a custom drawing tool.
        Attached Files
        Last edited by TheTradingMantis; 01-16-2021, 06:52 PM.
        The Trading Mantis
        NinjaTrader Ecosystem Vendor - The Trading Mantis

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        28 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        21 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        5 views
        0 likes
        Last Post funk10101  
        Started by gravdigaz6, Yesterday, 11:40 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Yesterday, 10:49 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X