---
id: "M:cAlgo.API.Button.#ctor"
kind: "constructor"
type: "T:cAlgo.API.Button"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Button/Constructor/"
---

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

# Button constructor

Member of [Button](https://help.ctrader.com/ctrader-algo/references/Controls/Button/index.md).

## Button()

Initializes a new instance of the Button class.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Accepted without error but never displayed, so control events such as Click are never raised.
- Cloud: Accepted without error but never displayed, so control events such as Click are never raised.

C#:

```csharp
public Button()
```

Python:

```python
Button()
```

### Examples

C#:

```csharp
var button = new Button { Text = "Buy", Margin = 5 };
button.Click += args => Print("Clicked");
Chart.AddControl(button);
```

Python:

```python
button = Button()
button.Text = "Buy"
button.Margin = Thickness(5)
button.Click += lambda args: api.Print("Clicked")
api.Chart.AddControl(button)
```

