Using SharpDX for Custom Chart Rendering

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Educational Resources >

Using SharpDX for Custom Chart Rendering

Previous page Return to chapter overview Next page

Show/Hide Hidden Text

Understanding the SharpDX .NET Library

NinjaTrader Chart objects (such as Indicators, Strategies, DrawingTools, ChartStyles) implement an OnRender() method aimed to render custom lines, shapes, and text to the chart.  To achieve the level of performance required to keep up with market data events, NinjaTrader uses a 3rd-party open-source .NET library named SharpDX.  This 3rd party library provides a C# wrapper for the powerful Microsoft DirectX API used for graphics processing and known for its hardware-accelerated performance, including 2D vector and text layout graphics used for NinjaTrader Chart Rendering.  The SharpDX/DirectX library is extensive, although NinjaTrader only uses a handful of namespaces and classes, which are documented as a guide in this reference.  In addition to this educational resource, we have also compiled a more focused collection of SharpDX SDK Reference resources to help you learn the SharpDX concepts used in NinjaTrader Chart Rendering.

 

Tips:  

1.There are several pre-installed examples of OnRender() and SharpDX objects used in the NinjaTrader.Custom project.  For starters, please look at the SampleCustomRender indicator file

2.Although not entirely identical, the SharpDX wrapper is designed to resemble System.Drawing namespace; experienced GDI developers will be familiar with concepts discussed in this section.

3.Microsoft provides various DirectX Programming Guides aimed to educate users with the underlying C++ DirectX API.  While SharpDX (C#) syntax is different, you may find these guides helpful for understanding SharpDX concepts not offered by this guide.

 

There are three main SharpDX namespaces you need to be familiar with:

 

SharpDX

Contains basic objects used by SharpDX.

SharpDX.Direct2D1

Contains objects used for rendering for 2D geometry, bitmaps, and text.

SharpDX.DirectWrite

Contains objects used for text rendering

 

The rest of this page will help you navigate the fundamental concepts needed to achieve custom rendering to your charts.

tog_minus        SharpDX Vectors and Charting Coordinates

tog_minus        SharpDX Brush Resources

tog_minus        SharpDX RenderTarget

tog_minus        SharpDX Lines and Shapes

tog_minus        SharpDX Text Rendering

tog_minus        SharpDX Stroke Style

tog_minus         Best Practices for SharpDX Resources