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

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

# ChartFibonacciFan.CalculateY

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

## CalculateY(int barIndex, FibonacciLevel 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, FibonacciLevel level)
```

Python:

```python
chartFibonacciFan.CalculateY(barIndex: int, level: FibonacciLevel) -> float
```

### Parameters

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

### Returns

`double` — Y-axis value

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
var fan = Chart.DrawFibonacciFan("fan", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(10), Bars.HighPrices.Last(10), Color.Red);
foreach (var level in fan.FibonacciLevels)
    Print("Level {0}% value at the last bar: {1}", level.Percent, fan.CalculateY(Bars.Count - 1, level));
```

Python:

```python
fan = api.Chart.DrawFibonacciFan("fan", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(10), api.Bars.HighPrices.Last(10), Color.Red)
for level in fan.FibonacciLevels:
    api.Print(f"Level {level.Percent}% value at the last bar: {fan.CalculateY(api.Bars.Count - 1, level)}")
```

## CalculateY(DateTime time, FibonacciLevel 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, FibonacciLevel level)
```

Python:

```python
chartFibonacciFan.CalculateY(time: DateTime, level: FibonacciLevel) -> float
```

### Parameters

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

### Returns

`double` — Y-axis value

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
var fan = Chart.DrawFibonacciFan("fan", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(10), Bars.HighPrices.Last(10), Color.Red);
var level = fan.FibonacciLevels[0];
Print("Level {0}% value at {1}: {2}", level.Percent, Bars.OpenTimes.LastValue, fan.CalculateY(Bars.OpenTimes.LastValue, level));
```

Python:

```python
fan = api.Chart.DrawFibonacciFan("fan", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(10), api.Bars.HighPrices.Last(10), Color.Red)
level = fan.FibonacciLevels[0]
api.Print(f"Level {level.Percent}% value at {api.Bars.OpenTimes.LastValue}: {fan.CalculateY(api.Bars.OpenTimes.LastValue, level)}")
```

