• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Sample AddOn?

  • Filter
  • Time
  • Show
Clear All
new posts

    Sample AddOn?


    I found this article in your help guide:


    There's a lot of good stuff there, but unfortunately it doesn't include a compilable version of the code. I've tried assembling it myself but to no avail.

    Can you please point me to the code for an add-on I can install, or can you please include a complete, compilable version of the example provided in your help guide?

    Thank you,


    By the way, this is where I gave up:

    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using System.Xml.Linq;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.Gui.Tools;
    //This namespace holds Add ons in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.AddOns
    	public class MyCustomAddOn : NinjaTrader.NinjaScript.AddOnBase
    		protected override void OnStateChange()
    			if (State == State.SetDefaults)
    				Description									= @"Enter the description for your new custom Add on here.";
    				Name										= "MyCustomAddOn";
    			else if (State == State.Configure)
    		protected override void OnWindowCreated(Window window)
    		  // We want to place our AddOn in the Control Center's menus
    		  ControlCenter cc = window as ControlCenter;
    		  if (cc == null)
    		  /* Determine we want to place our AddOn in the Control Center's "New" menu
    		   Other menus can be accessed via the control's "Automation ID". For example: toolsMenuItem, workspacesMenuItem, connectionsMenuItem, helpMenuItem. */
    		  existingMenuItemInControlCenter = cc.FindFirst("ControlCenterMenuItemNew") as NTMenuItem;
    		  if (existingMenuItemInControlCenter == null)
    		  // 'Header' sets the name of our AddOn seen in the menu structure
    		  addOnFrameworkMenuItem = new NTMenuItem { Header = "AddOn Framework", Style = Application.Current.TryFindResource("MainMenuItem") as Style };
    		  // Add our AddOn into the "New" menu
    		  // Subscribe to the event for when the user presses our AddOn's menu item
    		  addOnFrameworkMenuItem.Click += OnMenuItemClick;			
    		protected override void OnWindowDestroyed(Window window)
    		  if (addOnFrameworkMenuItem != null && window is ControlCenter)
    		      if (existingMenuItemInControlCenter != null && existingMenuItemInControlCenter.Items.Contains(addOnFrameworkMenuItem))
    		      addOnFrameworkMenuItem.Click -= OnMenuItemClick;
    		      addOnFrameworkMenuItem = null;
    		// Open our AddOn's window when the menu item is clicked on
    		private void OnMenuItemClick(object sender, RoutedEventArgs e)
    		  Core.Globals.RandomDispatcher.BeginInvoke(new Action(() => new AddOnFrameworkWindow().Show()));
    	/* This is where we define our AddOn window. The actual content is contained inside the tabs of the window defined in a custom class inheriting from NTTabPage.
    	   We must create a new window class which inherits from Tools.NTWindow for styling and implements the IWorkspacePersistence interface for the ability to save/restore from workspaces.*/
    	public class AddOnFrameworkWindow : NTWindow, IWorkspacePersistence
    	  public AddOnFrameworkWindow()
    	      // set Caption property (not Title), since Title is managed internally to properly combine selected Tab Header and Caption for display in the windows taskbar
    	      // This is the name displayed in the top-left of the window
    	      Caption = "AddOn Framework";
    	      // Set the initial dimensions of the window
    	      Width   = 1085;
    	      Height = 900;
    	      // TabControl should be created for window content if tab features are wanted
    	      TabControl tc = new TabControl();
    	      // Attached properties defined in TabControlManager class should be set to achieve tab moving, adding/removing tabs
    	      TabControlManager.SetIsMovable(tc, true);
    	      TabControlManager.SetCanAddTabs(tc, true);
    	      TabControlManager.SetCanRemoveTabs(tc, true);
    	      // if ability to add new tabs is desired, TabControl has to have attached property "Factory" set.
    	      TabControlManager.SetFactory(tc, new AddOnFrameworkWindowFactory());
    	      Content = tc;
    	      /* In order to have link buttons functionality, tab control items must be derived from Tools.NTTabPage
    	       They can be added using extension method AddNTTabPage(NTTabPage page) */
    	      tc.AddNTTabPage(new AddOnFrameworkTab());		  
    	     // WorkspaceOptions property must be set
    	      Loaded += (o, e) =>
    	          if (WorkspaceOptions == null)
    	              WorkspaceOptions = new WorkspaceOptions("AddOnFramework-" + Guid.NewGuid().ToString("N"), this);
    	  // IWorkspacePersistence member. Required for restoring window from workspace
    	  public void Restore(XDocument document, XElement element)
    	      if (MainTabControl != null)
    	  // IWorkspacePersistence member. Required for saving window to workspace
    	  public void Save(XDocument document, XElement element)
    	      if (MainTabControl != null)
    	  // IWorkspacePersistence member
    	  public WorkspaceOptions WorkspaceOptions { get; set; }	  
    	/* Class which implements Tools.INTTabFactory must be created and set as an attached property for TabControl
    	in order to use tab page add/remove/move/duplicate functionality */
    	public class AddOnFrameworkWindowFactory : INTTabFactory
    	  // INTTabFactory member. Required to create parent window
    	  public NTWindow CreateParentWindow()
    	      return new AddOnFrameworkWindow();
    	  // INTTabFactory member. Required to create tabs
    	  public NTTabPage CreateTabPage(string typeName, bool isTrue)
    	      return new NinjaTraderAddOnProject.AddOnPage();
    	/* This is where we define the actual content of the tabs for our AddOn window.
    	   Note: Class derived from Tools.NTTabPage has to be created if instrument link or interval link functionality is desired.
    	   Tools.IInstrumentProvider and/or Tools.IIntervalProvider interface(s) should be implemented.
    	   Also NTTabPage provides additional functionality for properly naming tab headers using properties and variables such as @FUNCTION, @INSTRUMENT, etc. */
    	public class AddOnFrameworkTab : NTTabPage, NinjaTrader.Gui.Tools.IInstrumentProvider, NinjaTrader.Gui.Tools.IIntervalProvider
    	  public AddOnFrameworkTab()
    	      Content = AddOnFrameworkWindowFactory.CreateTabPage("AddOnPage",true);

    Hello gripload,

    Thanks for your note.

    Below is a link to the Addon example created by the NinjaTrader Product Management team.

    Also, below is a link to a simplified starter example that I've posted on the forums previously.
    Last edited by NinjaTrader_Matthew; 01-09-2017, 11:56 AM.
    Chelsea B.NinjaTrader Customer Service


      Thank you!


        The NinjaScripte Editor AddOn Framework version is now located in our Help Guide, along with a version of this project that works in VisualStudio with dependent Xaml files

        Last edited by NinjaTrader_Matthew; 01-09-2017, 11:59 AM.
        MatthewNinjaTrader Product Management


        Latest Posts


        Topics Statistics Last Post
        Started by punkiy2111, Today, 04:33 PM
        0 responses
        Last Post punkiy2111  
        Started by lupearadu, Today, 01:58 PM
        5 responses
        Last Post lupearadu  
        Started by DieSlower, Today, 04:26 PM
        0 responses
        1 view
        Last Post DieSlower  
        Started by nctpar, Today, 02:13 PM
        0 responses
        Last Post nctpar
        by nctpar
        Started by rexmie888, Today, 01:47 PM
        0 responses
        Last Post rexmie888