How to use Nplot to draw a stock chart of futures in C #?

Source: Internet
Author: User

Introduction

As a professional programmatic trader, programming is a programmer's basic skills, this article is the author in a Futures CTP project related to the Candlestick drawing part, the trial class MT4 in the chart design and write, in the drafting, consult the relevant data, feel or use Nplot this chart control is better, features are: Free, can be used for WinForm programs, and faster, you can dynamically display the chart data in real time, the following to enter the theme.

Content

One, Nplot control related knowledge Introduction:

Chart controls are always hard to find, especially for free and powerful. Nplot is a very rare chart control under the. NET platform, can do a variety of graphs, histograms, pie charts, scatter charts, stock charts and so on, and it is free and open source, it is also very consistent with the programmer's habits. The only drawback is that documents are especially hard to read. By reading its documentation and analyzing the source code of the sample program, the basic concepts of Nplot are now organized as follows:

The Nplot namespace includes Nplot,nplot.bitmap,nplot.web,nplot.web.design, Nplot.windows and so on, of which the most core, the management of various types of charts belong to the Nplot namespace, Nplot.bitmap for the management of bitmaps, Nplot.web, NPlot.Web.Design and Nplot.windows can be thought of as nplot charts on Web form and container (plotsurface2d) on Windows Form. These containers can be dragged onto a form or in other containers.

To apply the Nplot control in your application, you first add the downloaded NPlot.dll to the. NET project. and add it to the Toolbox tray. Add this by right-clicking on the Toolbox, selecting Select Items, and the Select Toolbox Items dialog box, in the. Net Frameworks Components Property page, select Browse, locate NPlot.dll to add to the toolbox item. The Nplot control appears in the Toolbox. When you design the application interface, you can drag it into the application interface, and the system automatically creates a Plotsurface2d object in your code.

The Plotsurface2d object is a container for the Nplot chart, and all kinds of information such as chart graphics, coordinates, headings (both inherited idrawable interfaces ) can be added to the plotsurface2d. Plotsurface2d has a very important method: Add. Various chart graphs, coordinates, headings can be added to the Plotsurface2d object via Add.

1/////////Various drawings//////////2PrivatevoidPlot ()3{4This. Myplot.clear ();7//////Grid//////////8 Grid Mygrid =NewGrid ();9 Mygrid. Horizontalgridtype =Grid.GridType.Fine;Ten Mygrid. Verticalgridtype =Grid.GridType.Fine;11This. Myplot.add (Mygrid);1213///////Horizontal Line//////////HorizontalLine line =New HorizontalLine (10);Line. Lengthscale =2.89f;16//Line. Ordinatevalue = 2;17THIS.MYPLOT.ADD (Line,10);18///////Vertical Line///////////Verticalline line2 =New Verticalline (10);Line2. Lengthscale =0.89f;21stThis. Myplot.add (Line2);222324///////Candle Chart///////////25Int[] Opens = {1,2,1,2,1,3};26Double[] Closes = {2,2,2,1,2,1};27Float[] lows = {1,1,1,1,1,1};System.int64[] Highs = {3,2,3,3,3,4};29Int[] times = {0,1,2,3,4,5}; 30 candleplot cp = new31 CP. Closedata = Closes; CP. OpenData = Opens; CP. Lowdata = Lows; CP. Highdata = Highs; CP. Abscissadata = Times; this.myplot.add (CP);  PNS this.myplot.refresh ();                  

How do I use Nplot to draw a Futures stock candlestick chart under C #?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.