> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# GetYByValue()

## Definition

Returns the chart's y-pixel coordinate on the chart determined by a series value represented on the chart scale.

## Method Return Value

An **int** value representing a y pixel coordinate on the chart scale.

## Syntax

`\<chartscale\>.GetYByValue(double val)`

## Method Parameters

| Parameter | Description                                                            |
| --------- | ---------------------------------------------------------------------- |
| **val**   | A **double** value which usually represents a price or indicator value |

## Examples

```csharp
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
   // gets the pixel coordinate of the price value passed to the method
   int     yByValue = chartScale.GetYByValue(Bars.GetClose(Bars.Count - 1));

   Print("yByValue: " + yByValue); // 207
}
```

In the image below, we pass the last bar close as the value (example logic avoids using a bars ago index, see also [OnRender()](/developer/desktop-sdk/references/common/charts/rendering/onrender) note #5), which in return tells us the last price displayed on the chart is at a y location of 207 pixels.

![getybyvalue](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/ninjatrader-public.docs.buildwithfern.com/85af5ac56b771e136007149e040a327e8514dd49c16f9c344425e49d2124f7ad/docs/assets/developer/desktop-sdk/references/getybyvalue-getybyvalue.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260730%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260730T090112Z&X-Amz-Expires=604800&X-Amz-Signature=f454083086134241efeb3d8e2f8fa772e26623fb02d4ce8836d78287d0b8bc9e&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)