<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Add On > NinjaTrader Controls >


Previous page Return to chapter overview Next page


InstrumentSelector is a UI element users can interact with for selecting instruments. This can be used with instrument linking between windows.    


Events and Properties


Disposes of the InstrumentSelector (Note: calling the NTTabPage base.Cleanup() is sufficient to clean up this control)


An Instrument representing the selected instrument


Event handler for when the instrument changes on the instrument selector




This example demonstrates how to use the instrument selector and properly link its behavior to windows linking.



private InstrumentSelector instrumentSelector;


private DependencyObject LoadXAML()


    // Note: pageContent (not demonstrated in this example) is the page content of the XAML


    // Find the Instrument selector

    instrumentSelector = LogicalTreeHelper.FindLogicalNode(pageContent, "instrumentSelector") as InstrumentSelector;

    if (instrumentSelector != null)

         instrumentSelector.InstrumentChanged += OnInstrumentChanged;



// This method is fired when our instrument selector changes instruments

private void OnInstrumentChanged(object sender, EventArgs e)


    Instrument = sender as Cbi.Instrument;



// IInstrumentProvider member. Required if you want to use the instrument link mechanism in this Add On window

public Cbi.Instrument Instrument


    get { return instrument }



         instrument = value;

        if (instrumentSelector != null)

              instrumentSelector.Instrument = value;


         // Send instrument to other windows linked to the same color





// NOTE: Don't forget to clean up resources and unsubscribe to events

// Called by TabControl when tab is being removed or window is closed

public override void Cleanup()
    // Clean up our resources
    if (instrumentSelector != null)
        instrumentSelector.InstrumentChanged -= OnInstrumentChanged;      




<Page        xmlns=""









         <ColumnDefinition Width="Auto"/>

         <ColumnDefinition Width="*"/>



    <Tools:InstrumentSelector x:Name="instrumentSelector" Grid.Column="0" LastUsedGroup="MyAddOn"/>