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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      61 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X