---
id: "M:cAlgo.API.ChartGannSquare.CalculateY(System.Int32,cAlgo.API.GannLevel)"
kind: "method"
type: "T:cAlgo.API.ChartGannSquare"
url: "https://help.ctrader.com/ctrader-algo/references/Chart/Drawings/Gann/ChartGannSquare/CalculateY/"
---

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

# ChartGannSquare.CalculateY

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

## CalculateY(int barIndex, GannLevel level)

Calculates Y-axis value corresponding the specified bar index.

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

- CLI: Created and kept with all its properties, but never drawn: the CLI displays no chart.
- Cloud: Created and kept with all its properties, but never drawn: the cloud displays no chart.

C#:

```csharp
double CalculateY(int barIndex, GannLevel level)
```

Python:

```python
chartGannSquare.CalculateY(barIndex: int, level: GannLevel) -> float
```

### Parameters

- `barIndex` (`int`, Python `int`): Index of the bar.
- `level` (`GannLevel`, Python `GannLevel`): Level to get Y-axis value for.

### Returns

`double` — Y-axis value

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
var gannSquare = Chart.DrawGannSquare("gannSquare", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(10), Bars.HighPrices.Last(10), Color.Blue);
foreach (var level in gannSquare.GannLevels)
    Print("Gann {0} ray value at the last bar: {1}", level.Ratio, gannSquare.CalculateY(Bars.Count - 1, level));
```

Python:

```python
gannSquare = api.Chart.DrawGannSquare("gannSquare", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(10), api.Bars.HighPrices.Last(10), Color.Blue)
for level in gannSquare.GannLevels:
    api.Print(f"Gann {level.Ratio} ray value at the last bar: {gannSquare.CalculateY(api.Bars.Count - 1, level)}")
```

## CalculateY(DateTime time, GannLevel level)

Calculates Y-axis value corresponding the specified time value.

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

- CLI: Created and kept with all its properties, but never drawn: the CLI displays no chart.
- Cloud: Created and kept with all its properties, but never drawn: the cloud displays no chart.

C#:

```csharp
double CalculateY(DateTime time, GannLevel level)
```

Python:

```python
chartGannSquare.CalculateY(time: DateTime, level: GannLevel) -> float
```

### Parameters

- `time` (`DateTime`, Python `DateTime`): The time.
- `level` (`GannLevel`, Python `GannLevel`): Level to get Y-axis value for.

### Returns

`double` — Y-axis value

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
var gannSquare = Chart.DrawGannSquare("gannSquare", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(10), Bars.HighPrices.Last(10), Color.Blue);
var level = gannSquare.GannLevels[0];
Print("Gann {0} ray value at {1}: {2}", level.Ratio, Bars.OpenTimes.LastValue, gannSquare.CalculateY(Bars.OpenTimes.LastValue, level));
```

Python:

```python
gannSquare = api.Chart.DrawGannSquare("gannSquare", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(10), api.Bars.HighPrices.Last(10), Color.Blue)
level = gannSquare.GannLevels[0]
api.Print(f"Gann {level.Ratio} ray value at {api.Bars.OpenTimes.LastValue}: {gannSquare.CalculateY(api.Bars.OpenTimes.LastValue, level)}")
```

