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

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

# ChartAndrewsPitchfork.CalculateY

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

## CalculateY(int barIndex)

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)
```

Python:

```python
chartAndrewsPitchfork.CalculateY(barIndex: int) -> float
```

### Parameters

- `barIndex` (`int`, Python `int`): Index of the bar.

### Returns

`double` — Y-axis value

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
var pitchfork = Chart.DrawAndrewsPitchfork("pitchfork", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(20), Bars.HighPrices.Last(20), Bars.OpenTimes.Last(10), Bars.LowPrices.Last(10), Color.Red);
var medianValue = pitchfork.CalculateY(Bars.Count - 1);
Print("Median line value at the last bar: {0}", medianValue);
```

Python:

```python
pitchfork = api.Chart.DrawAndrewsPitchfork("pitchfork", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(20), api.Bars.HighPrices.Last(20), api.Bars.OpenTimes.Last(10), api.Bars.LowPrices.Last(10), Color.Red)
medianValue = pitchfork.CalculateY(api.Bars.Count - 1)
api.Print(f"Median line value at the last bar: {medianValue}")
```

## CalculateY(DateTime time)

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)
```

Python:

```python
chartAndrewsPitchfork.CalculateY(time: DateTime) -> float
```

### Parameters

- `time` (`DateTime`, Python `DateTime`): The time.

### Returns

`double` — Y-axis value

Available since cAlgo.API 5.8.

### Examples

C#:

```csharp
var pitchfork = Chart.DrawAndrewsPitchfork("pitchfork", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(20), Bars.HighPrices.Last(20), Bars.OpenTimes.Last(10), Bars.LowPrices.Last(10), Color.Red);
var medianValue = pitchfork.CalculateY(Bars.OpenTimes.LastValue);
Print("Median line value at {0}: {1}", Bars.OpenTimes.LastValue, medianValue);
```

Python:

```python
pitchfork = api.Chart.DrawAndrewsPitchfork("pitchfork", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(20), api.Bars.HighPrices.Last(20), api.Bars.OpenTimes.Last(10), api.Bars.LowPrices.Last(10), Color.Red)
medianValue = pitchfork.CalculateY(api.Bars.OpenTimes.LastValue)
api.Print(f"Median line value at {api.Bars.OpenTimes.LastValue}: {medianValue}")
```

