Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why don't I see my custom grid in the chart?

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

    Why don't I see my custom grid in the chart?

    Hi boys !!!!!
    I am trying to make a grid of at least 3 rows that is aligned to the Bottom Left within the graph and I have the following example code, the code does not give me any errors when compiling the strategy but the grid or the texts are not seen in the graph, I do not know where the problem is, or if this is the best way to do it. Can you help me see where the error is to know why the grid is not visible? The code is the following:


    // Crear un Grid para organizar los botones en filas y columnas
    var gridPatrones = new System.Windows.Controls.Grid
    {
    HorizontalAlignment = HorizontalAlignment.Left,
    VerticalAlignment = VerticalAlignment.Bottom,
    Margin = new Thickness(0, 0, 10, 0) // Margen para separar del borde derecho
    };

    // Definir las filas del Grid
    gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Primera fila
    gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Segunda fila
    gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Tercera fila
    gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Cuarta fila

    // Definir las columnas del Grid (4 columnas para la primera fila, 3 para la segunda, tercera y cuarta)
    gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 0
    gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 1
    gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 2
    gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 3 (nueva columna)

    // Crear el TextBlock para "Gustaff 1" en la primera fila
    var textBlockGustavito1 = new System.Windows.Controls.TextBlock
    {
    Text = "Gustff 1",
    Foreground = System.Windows.Media.Brushes.White,
    Background = System.Windows.Media.Brushes.Green,
    HorizontalAlignment = HorizontalAlignment.Center,
    VerticalAlignment = VerticalAlignment.Center,
    Padding = new Thickness(10)
    };

    // Añadir el TextBlock a la primera fila (fila 0) y columna 0
    System.Windows.Controls.Grid.SetRow(textBlockGusta vito1, 0);
    System.Windows.Controls.Grid.SetColumn(textBlockGu stavito1, 0);
    gridPatrones.Children.Add(textBlockGustavito1);

    // Crear el TextBlock para "Gusti 2" en la segunda fila
    var textBlockGusti2 = new System.Windows.Controls.TextBlock
    {
    Text = "Gusti 2",
    Foreground = System.Windows.Media.Brushes.White,
    Background = System.Windows.Media.Brushes.Red,
    HorizontalAlignment = HorizontalAlignment.Center,
    VerticalAlignment = VerticalAlignment.Center,
    Padding = new Thickness(10)
    };

    // Añadir el TextBlock a la segunda fila (fila 1) y columna 0
    System.Windows.Controls.Grid.SetRow(textBlockGusti 2, 1);
    System.Windows.Controls.Grid.SetColumn(textBlockGu sti2, 0);
    gridPatrones.Children.Add(textBlockGusti2);



    Thank you very much !!!

    #2
    Hello gustavobp,

    It would be difficult to know why that is happening by just looking at the code, you likely would have to add prints to the code to check that values being used are correct and also color the grids background to see if you can see it anywhere. This also depends on what control you are adding the grid to, the chart has the UserControlCollection which can have wpf controls added. You can see a sample of doing that in the drawing tool tiles indicator that comes with NinjaTrader.

    Comment


      #3
      Not sure if it matters, but it looks like when you are assigning the rows and columns, the variables do not match. For example, you are trying to assign textBlockGustavito1​, but under rows you named it textBlockGusta vito1​ and for columns textBlockGu stavito1​. As for textBlockGusti2​, for rows it looks like it's textBlockGusti 2​ and textBlockGu sti2​ for columns. If there are spaces in the names that would explain why the code wouldn't be working. The only other thing that I can think of is, after adding all the buttons on my code, I have UserControlCollection.Add(myGrid); You would just replace myGrid with the name of your grid...

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X