Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Modifications to chart WPF elements and tab considerations

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

  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    You are adding two rows to that area?

    Are you properly counting the rows when altering them? That is probably where the issue. I would look closer at the custom logic you have for this.

    What if you add your buttons in one row?

    Leave a comment:


  • SystemTrading
    replied
    The original script doesn't have the issue because it adds one row to the chartTraderGrid, and one row to the chartTraderButtonsGrid. If the original script is modified to add both rows to the chartTraderGrid, the issue occurs.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    The original script does not do this because it removes the added rows when a different tab is selected.

    Give it a try. Open multiple tabs and add the original script to each tab so there are multiple instances but only one instance on each tab. Are you seeing the same behavior?

    If opening an new tab and adding the indicator is causing the buttons to be added to incorrect rows, this would lead me to believe that when switching a way from that tab, the rows are not be removed correctly.

    Leave a comment:


  • SystemTrading
    replied
    I believe the issue is caused because two instances of the indicator are adding/removing controls from the chart trader panel. Everything works fine with multiple tabs if I only load one instance of the indicator. It shows 7 rows before adding the buttons, and 9 rows after adding the buttons. When I switch tabs and the controls are removed, it shows 9 rows before removing the buttons and 7 rows afterwards. When I load the indicator in another tab, one instance of the indicator works properly and shows the same row counts as mentioned. The other instance shows 9 rows before adding the buttons, and 11 rows afterwards. Similarly, it also shows 11 rows before removing the buttons, and 9 rows afterwards. I believe that the non-working instance is adding the controls to rows 10 and 11, and those rows are then being immediately removed by the working instance. As a result, all of the buttons end up in row 9.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    The issue is the row the buttons are being added to, correct?

    Each time the tab is changed and then changed back a new row is added and the buttons are added to the new row, is this correct?

    But the row count is correct?

    Something is off there. I think if the buttons are being added to the wrong row, then that row is likely not being removed.

    What is the row count before adding the buttons on a new chart (that hasn't been modified yet)?

    What is the row count after the buttons are added the first time, and what is the row number the buttons are added to?

    What is the row count after changing to a new tab and back, and what is the row number the buttons are added to?

    Leave a comment:


  • SystemTrading
    replied
    In the tab where the buttons display properly, the grid row count does go back to the original value after removing the rows. The row count in the non working tab shows extra rows until the indicator is reloaded. I can load the script multiple times in a single tab and the controls are added/removed in the correct location.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    Is the grid row count back to the original value after all objects are removed?

    Switching to a new tab should be removing all of the added objects and removing all added rows and all of the WPF should be reset back to the original state

    If there is interference when another tab is opened, this is likely indicating that things are not being reset to the original state when changing tabs or removing the script.

    If the script is reloaded several times, are the WPF controls added and removed from the correct location each time?

    Leave a comment:


  • SystemTrading
    replied
    Original Version:

    Code:
    public void InsertWPFControls()
            {
                if (panelActive)
                    return;
    
                // add a new row (addedRow1) for upperButtonsGrid to the existing buttons grid
                chartTraderButtonsGrid.RowDefinitions.Add(addedRow1);
                // set our upper grid to that new panel
                System.Windows.Controls.Grid.SetRow(upperButtonsGrid, (chartTraderButtonsGrid.RowDefinitions.Count - 1));
                // and add it to the buttons grid
                chartTraderButtonsGrid.Children.Add(upperButtonsGrid);
    
                // add a new row (addedRow2) for our lowerButtonsGrid below the ask and bid prices and pnl display            
                chartTraderGrid.RowDefinitions.Add(addedRow2);
                System.Windows.Controls.Grid.SetRow(lowerButtonsGrid, (chartTraderGrid.RowDefinitions.Count - 1));
                chartTraderGrid.Children.Add(lowerButtonsGrid);
    
                panelActive = true;
            }
    
    protected void RemoveWPFControls()
            {
                if (!panelActive)
                    return;
    
                if (chartTraderButtonsGrid != null || upperButtonsGrid != null)
                {
                    chartTraderButtonsGrid.Children.Remove(upperButtonsGrid);
                    chartTraderButtonsGrid.RowDefinitions.Remove(addedRow1);
                }
    
                if (chartTraderButtonsGrid != null || lowerButtonsGrid != null)
                {
                    chartTraderGrid.Children.Remove(lowerButtonsGrid);
                    chartTraderGrid.RowDefinitions.Remove(addedRow2);
                }
    
                panelActive = false;
            }
    Modified Version:
    Code:
    public void InsertWPFControls()
            {
                if (panelActive)
                    return;
    
                // add a new row (addedRow1) for upperButtonsGrid to the existing buttons grid
                chartTraderGrid.RowDefinitions.Add(addedRow1);
                // set our upper grid to that new panel
                System.Windows.Controls.Grid.SetRow(upperButtonsGrid, (chartTraderGrid.RowDefinitions.Count - 1));
                // and add it to the buttons grid
                chartTraderGrid.Children.Add(upperButtonsGrid);
    
                // add a new row (addedRow2) for our lowerButtonsGrid below the ask and bid prices and pnl display            
                chartTraderGrid.RowDefinitions.Add(addedRow2);
                System.Windows.Controls.Grid.SetRow(lowerButtonsGrid, (chartTraderGrid.RowDefinitions.Count - 1));
                chartTraderGrid.Children.Add(lowerButtonsGrid);
    
                panelActive = true;
            }
    
    protected void RemoveWPFControls()
            {
                if (!panelActive)
                    return;
    
                if (chartTraderGrid != null || upperButtonsGrid != null)
                {
                    chartTraderGrid.Children.Remove(upperButtonsGrid);
                    chartTraderGrid.RowDefinitions.Remove(addedRow1);
                }
    
                if (chartTraderGrid != null || lowerButtonsGrid != null)
                {
                    chartTraderGrid.Children.Remove(lowerButtonsGrid);
                    chartTraderGrid.RowDefinitions.Remove(addedRow2);
                }
    
                panelActive = false;
            }

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    Are the buttons removed from the correct location?

    Leave a comment:


  • SystemTrading
    replied
    The original script places 2 buttons above the Instrument/TIF selector controls, and 2 buttons below the bid/ask labels. I'm trying to get all 4 buttons below the bid/ask labels, but I'm having this small issue.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    My guess would be that they are not being removed from the correct place.

    The original script already places buttons there. Why not just use those and rename them and change the method?

    Leave a comment:


  • SystemTrading
    replied
    My mistake, I changed lines 181-185. The change was necessary to move the buttons below the default controls (see the attached images). Everything works properly until I load the indicator in a second tab.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    The original already places buttons in the chartTraderGrid. Changing this may have been unnecessary.
    The code from the original script on lines 188 to 190.
    Code:
    chartTraderGrid.RowDefinitions.Add(addedRow2);
    System.Windows.Controls.Grid.SetRow(lowerButtonsGrid, (chartTraderGrid.RowDefinitions.Count - 1));
    chartTraderGrid.Children.Add(lowerButtonsGrid);
    In your script, are you checking that there are not empty objects or rows being added unnecessarily and that the buttons are being removed from the correct location or object and that the rows are being removed properly?

    Leave a comment:


  • SystemTrading
    replied
    I only changed lines 188-190 by replacing "chartTraderButtonsGrid" with "chartTraderGrid".

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello SystemTrading,

    The original does not appear to have this behavior with buttons added below the chart trader area.
    https://drive.google.com/file/d/1b4C...w?usp=drivesdk

    What modifications did you make?

    My guess would be that the incorrect grid row numbers are being used or possibly the buttons are being added to a different area.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
51 views
0 likes
Last Post cmoran13  
Started by PaulMohn, 04-10-2026, 11:11 AM
0 responses
31 views
0 likes
Last Post PaulMohn  
Started by CarlTrading, 03-31-2026, 09:41 PM
1 response
165 views
1 like
Last Post NinjaTrader_ChelseaB  
Started by CarlTrading, 04-01-2026, 02:41 AM
0 responses
100 views
1 like
Last Post CarlTrading  
Started by CaptainJack, 03-31-2026, 11:44 PM
0 responses
161 views
2 likes
Last Post CaptainJack  
Working...
X