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

# ConvertFromHorizontalPixels

## Definition

Converts an x-axis pixel coordinate from device pixels to application 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

A double representing an x-coordinate value in terms of application pixels.

## Syntax

`ChartingExtensions.ConvertFromHorizontalPixels(this int x, PresentationSource target)`

`int.ConvertFromHorizontalPixels(PresentationSource target)`

## Parameters

| Parameter  | Description                                                                                                                                                                                                                                                                                                               |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **x**      | The horizontal int coordinates in device pixels to convert.                                                                                                                                                                                                                                                               |
| **target** | The [PresentationSource](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 applicationPixelX;

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