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

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

# ChartGannFan.CalculateY

Member of [ChartGannFan](https://help.ctrader.com/ctrader-algo/references/Chart/Drawings/Gann/ChartGannFan/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
chartGannFan.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 gannFan = Chart.DrawGannFan("gannFan", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(10), Bars.HighPrices.Last(10), Color.Blue);
foreach (var level in gannFan.GannLevels)
    Print("Gann {0} ray value at the last bar: {1}", level.Ratio, gannFan.CalculateY(Bars.Count - 1, level));
```

Python:

```python
gannFan = api.Chart.DrawGannFan("gannFan", 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 gannFan.GannLevels:
    api.Print(f"Gann {level.Ratio} ray value at the last bar: {gannFan.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
chartGannFan.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 gannFan = Chart.DrawGannFan("gannFan", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(10), Bars.HighPrices.Last(10), Color.Blue);
var level = gannFan.GannLevels[0];
Print("Gann {0} ray value at {1}: {2}", level.Ratio, Bars.OpenTimes.LastValue, gannFan.CalculateY(Bars.OpenTimes.LastValue, level));
```

Python:

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

