---
id: "M:cAlgo.API.ChartArea.DrawGannSquare(System.String,System.DateTime,System.Double,System.DateTime,System.Double,cAlgo.API.Color)"
kind: "method"
type: "T:cAlgo.API.ChartArea"
url: "https://help.ctrader.com/ctrader-algo/references/Chart/ChartArea/DrawGannSquare/"
---

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

# ChartArea.DrawGannSquare

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

## DrawGannSquare(string name, DateTime time1, double y1, DateTime time2, double y2, Color color)

Draws a Gann square.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartGannSquare DrawGannSquare(string name, DateTime time1, double y1, DateTime time2, double y2, Color color)
```

Python:

```python
chartArea.DrawGannSquare(name: str, time1: DateTime, y1: float, time2: DateTime, y2: float, color: Color) -> ChartGannSquare
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `time1` (`DateTime`, Python `DateTime`): The time value of the Gann square start point location on the X-axis.
- `y1` (`double`, Python `float`): The Y-axis value of the Gann square start point location.
- `time2` (`DateTime`, Python `DateTime`): The time value of the Gann square end point location on the X-axis.
- `y2` (`double`, Python `float`): The Y-axis value of the Gann square end point location.
- `color` (`Color`, Python `Color`): The Gann square lines color.

### Returns

`ChartGannSquare` — ChartGannSquare.

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
var gannSquare = Chart.DrawGannSquare("gannSquare", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.LastValue, Bars.HighPrices.LastValue, Color.Blue);
Print("Gann square levels: {0}", gannSquare.GannLevels.Count);
```

Python:

```python
gannSquare = api.Chart.DrawGannSquare("gannSquare", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.LastValue, api.Bars.HighPrices.LastValue, Color.Blue)
api.Print(f"Gann square levels: {gannSquare.GannLevels.Count}")
```

## DrawGannSquare(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness)

Draws a Gann square.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartGannSquare DrawGannSquare(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness)
```

Python:

```python
chartArea.DrawGannSquare(name: str, time1: DateTime, y1: float, time2: DateTime, y2: float, color: Color, thickness: int) -> ChartGannSquare
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `time1` (`DateTime`, Python `DateTime`): The time value of the Gann square start point location on the X-axis.
- `y1` (`double`, Python `float`): The Y-axis value of the Gann square start point location.
- `time2` (`DateTime`, Python `DateTime`): The time value of the Gann square end point location on the X-axis.
- `y2` (`double`, Python `float`): The Y-axis value of the Gann square end point location.
- `color` (`Color`, Python `Color`): The Gann square lines color.
- `thickness` (`int`, Python `int`): The Gann square lines thickness.

### Returns

`ChartGannSquare` — ChartGannSquare.

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
var gannSquare = Chart.DrawGannSquare("gannSquare", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.LastValue, Bars.HighPrices.LastValue, Color.Blue, 2);
Print("Gann square thickness: {0}", gannSquare.Thickness);
```

Python:

```python
gannSquare = api.Chart.DrawGannSquare("gannSquare", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.LastValue, api.Bars.HighPrices.LastValue, Color.Blue, 2)
api.Print(f"Gann square thickness: {gannSquare.Thickness}")
```

## DrawGannSquare(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness, LineStyle lineStyle)

Draws a Gann square.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartGannSquare DrawGannSquare(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness, LineStyle lineStyle)
```

Python:

```python
chartArea.DrawGannSquare(name: str, time1: DateTime, y1: float, time2: DateTime, y2: float, color: Color, thickness: int, lineStyle: LineStyle) -> ChartGannSquare
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `time1` (`DateTime`, Python `DateTime`): The time value of the Gann square start point location on the X-axis.
- `y1` (`double`, Python `float`): The Y-axis value of the Gann square start point location.
- `time2` (`DateTime`, Python `DateTime`): The time value of the Gann square end point location on the X-axis.
- `y2` (`double`, Python `float`): The Y-axis value of the Gann square end point location.
- `color` (`Color`, Python `Color`): The Gann square lines color.
- `thickness` (`int`, Python `int`): The Gann square lines thickness.
- `lineStyle` (`LineStyle`, Python `LineStyle`): The Gann square lines style.

### Returns

`ChartGannSquare` — ChartGannSquare.

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
var gannSquare = Chart.DrawGannSquare("gannSquare", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.LastValue, Bars.HighPrices.LastValue, Color.Blue, 2, LineStyle.Dots);
Print("Gann square style: {0}", gannSquare.LineStyle);
```

Python:

```python
gannSquare = api.Chart.DrawGannSquare("gannSquare", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.LastValue, api.Bars.HighPrices.LastValue, Color.Blue, 2, LineStyle.Dots)
api.Print(f"Gann square style: {gannSquare.LineStyle}")
```

## DrawGannSquare(string name, int barIndex1, double y1, int barIndex2, double y2, Color color)

Draws a Gann square.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartGannSquare DrawGannSquare(string name, int barIndex1, double y1, int barIndex2, double y2, Color color)
```

Python:

```python
chartArea.DrawGannSquare(name: str, barIndex1: int, y1: float, barIndex2: int, y2: float, color: Color) -> ChartGannSquare
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `barIndex1` (`int`, Python `int`): The bar index of the Gann square start point location on the X-axis.
- `y1` (`double`, Python `float`): The Y-axis value of the Gann square start point location.
- `barIndex2` (`int`, Python `int`): The bar index of the Gann square end point location on the X-axis.
- `y2` (`double`, Python `float`): The Y-axis value of the Gann square end point location.
- `color` (`Color`, Python `Color`): The Gann square lines color.

### Returns

`ChartGannSquare` — ChartGannSquare.

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
var index = Bars.Count - 1;
var gannSquare = Chart.DrawGannSquare("gannSquare", index - 30, Bars.LowPrices[index - 30], index, Bars.HighPrices[index], Color.Blue);
Print("Gann square levels: {0}", gannSquare.GannLevels.Count);
```

Python:

```python
index = api.Bars.Count - 1
gannSquare = api.Chart.DrawGannSquare("gannSquare", index - 30, api.Bars.LowPrices[index - 30], index, api.Bars.HighPrices[index], Color.Blue)
api.Print(f"Gann square levels: {gannSquare.GannLevels.Count}")
```

## DrawGannSquare(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness)

Draws a Gann square.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartGannSquare DrawGannSquare(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness)
```

Python:

```python
chartArea.DrawGannSquare(name: str, barIndex1: int, y1: float, barIndex2: int, y2: float, color: Color, thickness: int) -> ChartGannSquare
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `barIndex1` (`int`, Python `int`): The bar index of the Gann square start point location on the X-axis.
- `y1` (`double`, Python `float`): The Y-axis value of the Gann square start point location.
- `barIndex2` (`int`, Python `int`): The bar index of the Gann square end point location on the X-axis.
- `y2` (`double`, Python `float`): The Y-axis value of the Gann square end point location.
- `color` (`Color`, Python `Color`): The Gann square lines color.
- `thickness` (`int`, Python `int`): The Gann square lines thickness.

### Returns

`ChartGannSquare` — ChartGannSquare.

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
var index = Bars.Count - 1;
var gannSquare = Chart.DrawGannSquare("gannSquare", index - 30, Bars.LowPrices[index - 30], index, Bars.HighPrices[index], Color.Blue, 2);
Print("Gann square thickness: {0}", gannSquare.Thickness);
```

Python:

```python
index = api.Bars.Count - 1
gannSquare = api.Chart.DrawGannSquare("gannSquare", index - 30, api.Bars.LowPrices[index - 30], index, api.Bars.HighPrices[index], Color.Blue, 2)
api.Print(f"Gann square thickness: {gannSquare.Thickness}")
```

## DrawGannSquare(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness, LineStyle lineStyle)

Draws a Gann square.

Environments: Desktop supported · CLI works differently · Cloud works differently.

- CLI: The object is created and returned, but never drawn: the CLI displays no chart.
- Cloud: The object is created and returned, but never drawn: the cloud displays no chart.

C#:

```csharp
ChartGannSquare DrawGannSquare(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness, LineStyle lineStyle)
```

Python:

```python
chartArea.DrawGannSquare(name: str, barIndex1: int, y1: float, barIndex2: int, y2: float, color: Color, thickness: int, lineStyle: LineStyle) -> ChartGannSquare
```

### Parameters

- `name` (`string`, Python `str`): The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name.
- `barIndex1` (`int`, Python `int`): The bar index of the Gann square start point location on the X-axis.
- `y1` (`double`, Python `float`): The Y-axis value of the Gann square start point location.
- `barIndex2` (`int`, Python `int`): The bar index of the Gann square end point location on the X-axis.
- `y2` (`double`, Python `float`): The Y-axis value of the Gann square end point location.
- `color` (`Color`, Python `Color`): The Gann square lines color.
- `thickness` (`int`, Python `int`): The Gann square lines thickness.
- `lineStyle` (`LineStyle`, Python `LineStyle`): The Gann square lines style.

### Returns

`ChartGannSquare` — ChartGannSquare.

Available since cAlgo.API 5.7.

### Examples

C#:

```csharp
var index = Bars.Count - 1;
var gannSquare = Chart.DrawGannSquare("gannSquare", index - 30, Bars.LowPrices[index - 30], index, Bars.HighPrices[index], Color.Blue, 2, LineStyle.Dots);
Print("Gann square style: {0}", gannSquare.LineStyle);
```

Python:

```python
index = api.Bars.Count - 1
gannSquare = api.Chart.DrawGannSquare("gannSquare", index - 30, api.Bars.LowPrices[index - 30], index, api.Bars.HighPrices[index], Color.Blue, 2, LineStyle.Dots)
api.Print(f"Gann square style: {gannSquare.LineStyle}")
```

