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

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

# ChartArea.SetYRange

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

## SetYRange(double bottomY, double topY)

Sets the Y-axis lowest and highest values range. Allows scrolling the chart by the Y-axis. If only one of the values is set, then the chart will be expanded regarding the lowest or highest value respectively. A range whose lowest value is not lower than its highest value is ignored, and so is any range on the main chart area while the price scale mode is Percent or IndexedTo100.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
void SetYRange(double bottomY, double topY)
```

Python:

```python
chartArea.SetYRange(bottomY: float, topY: float) -> None
```

### Parameters

- `bottomY` (`double`, Python `float`): The lowest visible Y-axis value.
- `topY` (`double`, Python `float`): The highest visible Y-axis value.

### Examples

C#:

```csharp
var margin = 50 * Symbol.PipSize;
Chart.SetYRange(Bars.LowPrices.LastValue - margin, Bars.HighPrices.LastValue + margin);
Print("Visible Y range: {0} - {1}", Chart.BottomY, Chart.TopY);
```

Python:

```python
margin = 50 * api.Symbol.PipSize
api.Chart.SetYRange(api.Bars.LowPrices.LastValue - margin, api.Bars.HighPrices.LastValue + margin)
api.Print(f"Visible Y range: {api.Chart.BottomY} - {api.Chart.TopY}")
```

