Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding own Account Selector to Chart Trader linked to specific strategy

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

    Adding own Account Selector to Chart Trader linked to specific strategy

    Hello,

    Do you have a sample showcasing how to add a 2nd Account Selector to the Chart Trader?
    To be used with the specific strategy loaded on the chart in place of the default Chart Trader Account Selector.
    The function should be accessing and selecting account for the specific strategy from the 2nd Chart Trader Account Selector.

    I managed to add buttons to a Chart Trader 2nd child grid but can't find insights on adding a 2nd Account Selector control.

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class ChartTrader2ndAccountSelector : Strategy
    {
    private NinjaTrader.Gui.Tools.AccountSelector accountSelector;

    //.....
    protected override void OnStateChange()
    {

    //.....
    if (State == State.SetDefaults)
    {
    else if (State == State.Historical)
    {
    if (ChartControl != null)
    {
    ChartControl.Dispatcher.InvokeAsync(() =>
    {
    CreateWPFControls();
    });
    }
    }

    else if (State == State.Terminated)
    {
    if (ChartControl != null)
    {
    ChartControl.Dispatcher.InvokeAsync(() =>
    {
    DisposeWPFControls();
    });
    }
    ​​​
    //.....

    protected void CreateWPFControls()
    {
    accountSelector = (Window.GetWindow(ChartControl.Parent).FindFirst(" ChartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector);

    //...
    System.Windows.Controls.Grid.SetColumn(accountSele ctor, 0);
    System.Windows.Controls.Grid.SetRow(accountSelecto r, 1);

    //...


    protected void CreateWPFControls()
    {

    accountSelector = new AccountSelector();

    //...
    System.Windows.Controls.Grid.SetColumn(accountSele ctor, 0);
    System.Windows.Controls.Grid.SetRow(accountSelecto r, 1);

    //...


    ///.....


    This just takes the default chart trader Account selector and superimposes over the default instrument chart trader selector.​
    accountSelector = (Window.GetWindow(ChartControl.Parent).FindFirst(" ChartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector);


    This does not display anything in the new child grid​
    accountSelector = new AccountSelector();


    I'd appreciate just using a NT native Account Selector object over recreating a WPF one.

    #2
    Hello PaulMohn,

    Thank you for your post.

    Could you share your full code for the CreateWPFControls method? If the selector is not displaying, this could indicate it was not added to the grid or perhaps has the incorrect column/row set.

    Additionally, are you planning to change the account the strategy is using? As a heads up, this would not be supported.

    I look forward to assisting further.

    Comment


      #3
      Hello @NinjaTrader_Gaby​,

      Strategies don't allow dynamic changing the account? only indicators/addons?
      ok. I'll test with indicator asap.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X