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
    {
    private string[] CUSTOMTOOL_HEADERS = new string[3] { "Risk Reward 3", "Measured Move", "Horizontal Line Segment" };
    // existing code
    protected override void OnWindowCreated(Window window) {
    // existing code #region -- Add Custom Tools -- else if (CUSTOMTOOL_HEADERS.Contains(mnItem.Header.ToString())) {
    verticalStackPanel.Children.Add(new NTMenuItem()
    { ToolTip = mnItem.Header, Style = mnItem.Style, Icon = mnItem.Icon, Command = mnItem.Command, Margin = new Thickness(1), Width = ITEM_WIDTH, HorizontalAlignment = HorizontalAlignment.Left });
    }

    Thanks, Greg

    #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.
    https://ninjatrader.com/support/foru...-from-a-button

    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.

      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 gregschr; 01-16-2021, 06:52 PM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by vitalpilot, Yesterday, 11:14 PM
        1 response
        3 views
        0 likes
        Last Post ezrollin  
        Started by PaulMohn, 09-15-2021, 05:25 AM
        21 responses
        106 views
        0 likes
        Last Post omololu
        by omololu
         
        Started by mcosta72, Yesterday, 04:09 PM
        0 responses
        17 views
        1 like
        Last Post mcosta72  
        Started by Quanto, Yesterday, 02:50 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by Trader108, Yesterday, 01:45 PM
        2 responses
        16 views
        0 likes
        Last Post Trader108  
        Working...
        X