---
id: "T:cAlgo.API.LineStackingStrategy"
kind: "enum"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/LineStackingStrategy/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# LineStackingStrategy (enum)

Describes a mechanism by which a line box is determined for each line.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum LineStackingStrategy
```

## Examples

C#:

```csharp
using cAlgo.API;
using System.Text;

namespace cAlgo
{
    // This sample indicator shows how to use different Line Stacking Strategies on a TextBlock
    public partial class LineStackingStrategySample : Indicator
    {
        protected override void Initialize()
        {
            var stackPanel = new StackPanel
            {
                Orientation = Orientation.Vertical,
                BackgroundColor = Color.Gold,
                Opacity = 0.6,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("First line of text");
            stringBuilder.AppendLine("Second line of text");
            stringBuilder.AppendLine("Third line of text");
            stringBuilder.AppendLine("Fourth line of text");
            stringBuilder.AppendLine("Fifth line of text");

            stackPanel.AddChild(new TextBlock
            {
                Margin = 5,
                Text = "LineStackingStrategy = BlockLineHeight:\n" + stringBuilder.ToString(),
                LineStackingStrategy = LineStackingStrategy.BlockLineHeight,
                FontWeight = FontWeight.Bold,
                ForegroundColor = Color.Black
            });

            stackPanel.AddChild(new TextBlock
            {
                Margin = 5,
                Text = "LineStackingStrategy = MaxHeight:\n" + stringBuilder.ToString(),
                LineStackingStrategy = LineStackingStrategy.MaxHeight,
                FontWeight = FontWeight.Bold,
                ForegroundColor = Color.Black
            });

            Chart.AddControl(stackPanel);
        }

        public override void Calculate(int index)
        {
        }
    }
}
```

Python:

```python
import clr
clr.AddReference("cAlgo.API")

from cAlgo.API import *

class Test():
    def get_text_block(self, text, lineStackingStrategy):
        textBlock = TextBlock()
        textBlock.Text = text
        textBlock.FontWeight = FontWeight.Bold
        textBlock.ForegroundColor = Color.Black
        textBlock.Margin = Thickness(5)
        textBlock.LineStackingStrategy = lineStackingStrategy
        return textBlock

    def initialize(self):
        stackPanel = StackPanel()
        stackPanel.Orientation = Orientation.Vertical
        stackPanel.BackgroundColor = Color.Gold
        stackPanel.Opacity = 0.6
        stackPanel.HorizontalAlignment = HorizontalAlignment.Center
        stackPanel.VerticalAlignment = VerticalAlignment.Center

        lines = """
        First line of text
        Second line of text
        Third line of text
        Fourth line of text
        Fifth line of text"""

        stackPanel.AddChild(self.get_text_block(f"LineStackingStrategy = BlockLineHeight:\n{lines}", LineStackingStrategy.BlockLineHeight))
        stackPanel.AddChild(self.get_text_block(f"LineStackingStrategy = MaxHeight:\n{lines}", LineStackingStrategy.MaxHeight))

        api.Chart.AddControl(stackPanel)
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}
```

## Values

- `LineStackingStrategy.BlockLineHeight` — The stack height is determined by the block element line-height property value.
- `LineStackingStrategy.MaxHeight` — The stack height is the smallest value that containing all the inline elements on that line when those elements are properly aligned.

