> 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.

# ConvertToHorizontalPixels

## Definition

Converts an x-axis pixel coordinate from application pixels to device pixels.

For more information concerning the differences between application pixels and device pixels, please see the [Working with Pixel Coordinates](/developer/desktop-sdk/guides/educational-resources/working-with-pixel-coordinates).

## Method Return Value

An int representing an x-coordinate value in terms of device pixels.

## Syntax

`ChartingExtensions.ConvertToHorizontalPixels(this double x, PresentationSource target)`

`\<double\>.ConvertToHorizontalPixels(PresentationSource target)`

## Parameters

| Parameter  | Description                                                                                                                                                                    |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **x**      | The horizontal double coordinates in application pixels to convert                                                                                                             |
| **target** | The [PresenationSource](https://msdn.microsoft.com/en-us/library/system.windows.presentationsource\(v=vs.110\).aspx) representing the display surface used for the conversion. |

Note: For Charts, see [ChartControl.PresentationSource](/developer/desktop-sdk/references/common/charts/chartcontrol/presentationsource).

## Examples

```csharp
int devicePixelX;

protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
    // Obtain the device-pixel coordinate corresponding to an application pixel X-value of 500
    devicePixelX = ChartingExtensions.ConvertToHorizontalPixels(500, ChartControl.PresentationSource);
}
```