Financial Bars (C Code)
Open, High, Low, Close Chart
#include <stdio.h> #include "dislin.h" #define NMAX 100 int get_data (float *x, float *yopen, float *yhigh, float *ylow, float *yclose, float *yvol, int nmax); main () { int n; float x[NMAX], yopen[NMAX], yhigh[NMAX], ylow[NMAX], yclose[NMAX], yvol[NMAX]; float xa, xe, xor, xstp; basdat (1,1,2000); n = get_data (x, yopen, yhigh, ylow, yclose, yvol, NMAX); xa = incdat (1, 1, 2010); xe = incdat (15, 3, 2010); xor = incdat (1, 1, 2010); xstp = 7.f; scrmod ("revers"); winsiz (600, (int) (2100. / 2900 * 600)); metafl ("cons"); disini (); pagera (); hwfont (); barwth (-20.f); labels ("Date", "x"); labmod ("form", "mdy", "x"); labmod ("month", "short", "x"); labmod ("year", "short", "x"); labmod ("separator", "/", "x"); ticks (7, "x"); name ("Price", "y"); name ("Date", "x"); labdig (-1, "y"); height (30); bartyp ("ticks"); titlin ("Open, High, Low, Close Chart", 3); axspos (300, 1300); axslen (2400, 900); setgrf ("ticks", "name", "ticks", "ticks"); graf (xa, xe, xor, xstp, 27.f, 32.f, 27.f, 1.f); htitle (45); title (); dot (); grid (1, 1); solid (); fbars (x, yopen, yhigh, ylow, yclose, n); endgrf (); name ("Volume * 10000", "y"); axspos (300, 1800); axslen (2400, 501); setgrf ("name", "name", "ticks", "ticks"); graf (xa, xe, xor, xstp, 0.f, 23000.f, 0.f, 5000.f); dot (); grid (1, 1); solid (); polcrv ("fbars"); color ("blue"); curve (x, yvol, n); rpng ("fchart_1.png"); disfin (); } int get_data (float *x, float *yopen, float *yhigh, float *ylow, float *yclose, float *yvol, int nmax) { struct data { int im; int id; int iy; float open; float high; float low; float close; int volume; } v[47] = { 1, 4, 2010, 30.62, 31.10, 30.59, 30.95, 38409100, 1, 5, 2010, 30.85, 31.10, 30.64, 30.96, 49749600, 1, 6, 2010, 30.88, 31.08, 30.52, 30.77, 58182400, 1, 7, 2010, 30.63, 30.70, 30.19, 30.45, 50559700, 1, 8, 2010, 30.28, 30.88, 30.24, 30.66, 51197400, 1, 11, 2010, 30.71, 30.76, 30.12, 30.27, 68754700, 1, 12, 2010, 30.15, 30.40, 29.91, 30.07, 65912100, 1, 13, 2010, 30.26, 30.52, 30.01, 30.35, 51863500, 1, 14, 2010, 30.31, 31.10, 30.26, 30.96, 63228100, 1, 15, 2010, 31.08, 31.24, 30.71, 30.86, 79913200, 1, 19, 2010, 30.75, 31.24, 30.68, 31.10, 46575700, 1, 20, 2010, 30.81, 30.94, 30.31, 30.59, 54849500, 1, 21, 2010, 30.61, 30.72, 30.00, 30.01, 73086700, 1, 22, 2010, 30.00, 30.20, 28.84, 28.96, 102004600, 1, 25, 2010, 29.24, 29.66, 29.10, 29.32, 63373000, 1, 26, 2010, 29.20, 29.85, 29.09, 29.50, 66639900, 1, 27, 2010, 29.35, 29.82, 29.02, 29.67, 63949500, 1, 28, 2010, 29.84, 29.87, 28.89, 29.16, 117513700, 1, 29, 2010, 29.90, 29.92, 27.66, 28.18, 193888500, 2, 1, 2010, 28.39, 28.48, 27.92, 28.41, 85931100, 2, 2, 2010, 28.37, 28.50, 28.14, 28.46, 54413700, 2, 3, 2010, 28.26, 28.79, 28.12, 28.63, 61397900, 2, 4, 2010, 28.38, 28.50, 27.81, 27.84, 77850000, 2, 5, 2010, 28.00, 28.28, 27.57, 28.02, 80960100, 2, 8, 2010, 28.01, 28.08, 27.57, 27.72, 52820600, 2, 9, 2010, 27.97, 28.34, 27.75, 28.01, 59195800, 2, 10, 2010, 28.03, 28.24, 27.84, 27.99, 48591300, 2, 11, 2010, 27.93, 28.40, 27.70, 28.12, 65993700, 2, 12, 2010, 27.81, 28.06, 27.58, 27.93, 81117200, 2, 16, 2010, 28.13, 28.37, 28.02, 28.35, 51935600, 2, 17, 2010, 28.53, 28.65, 28.36, 28.59, 45882900, 2, 18, 2010, 28.59, 29.03, 28.51, 28.97, 42856500, 2, 19, 2010, 28.79, 28.92, 28.69, 28.77, 44451800, 2, 22, 2010, 28.84, 28.94, 28.65, 28.73, 36707100, 2, 23, 2010, 28.68, 28.83, 28.09, 28.33, 52266200, 2, 24, 2010, 28.52, 28.79, 28.38, 28.63, 43165900, 2, 25, 2010, 28.27, 28.65, 28.02, 28.60, 48694000, 2, 26, 2010, 28.65, 28.85, 28.51, 28.67, 40370600, 3, 1, 2010, 28.77, 29.05, 28.53, 29.02, 43773800, 3, 2, 2010, 29.08, 29.30, 28.24, 28.46, 93123900, 3, 3, 2010, 28.51, 28.61, 28.35, 28.46, 48421200, 3, 4, 2010, 28.46, 28.65, 28.27, 28.63, 42890600, 3, 5, 2010, 28.66, 28.68, 28.42, 28.59, 56001800, 3, 8, 2010, 28.52, 28.93, 28.50, 28.63, 39414500, 3, 9, 2010, 28.56, 29.11, 28.55, 28.80, 50271600, 3, 10, 2010, 28.86, 29.11, 28.80, 28.97, 44891400, 3, 11, 2010, 28.89, 29.19, 28.85, 29.18, 35349700 }; int i, n = 0; for (i = 0; i < 47; i++) { if (i < nmax) { x[i] = incdat (v[i].id, v[i].im, v[i].iy); yopen[i] = v[i].open; yhigh[i] = v[i].high; ylow[i] = v[i].low; yclose[i] = v[i].close; yvol[i] = v[i].volume/ 10000.f; n++; } } return n; }
Candlestick Chart
#include <stdio.h> #include "dislin.h" #define NMAX 100 int get_data (float *x, float *yopen, float *yhigh, float *ylow, float *yclose, float *yvol, int nmax); main () { int n; float x[NMAX], yopen[NMAX], yhigh[NMAX], ylow[NMAX], yclose[NMAX], yvol[NMAX]; float xa, xe, xor, xstp; basdat (1,1,2000); n = get_data (x, yopen, yhigh, ylow, yclose, yvol, NMAX); xa = incdat (1, 1, 2010); xe = incdat (15, 3, 2010); xor = incdat (1, 1, 2010); xstp = 7.f; scrmod ("revers"); winsiz (600, (int) (2100. / 2900 * 600)); metafl ("cons"); disini (); pagera (); hwfont (); barwth (-20.f); labels ("Date", "x"); labmod ("form", "mdy", "x"); labmod ("month", "short", "x"); labmod ("year", "short", "x"); labmod ("separator", "/", "x"); ticks (7, "x"); name ("Price", "y"); name ("Date", "x"); labdig (-1, "y"); height (30); titlin ("Candlestick Chart", 3); axspos (300, 1300); axslen (2400, 900); setgrf ("ticks", "name", "ticks", "ticks"); graf (xa, xe, xor, xstp, 27.f, 32.f, 27.f, 1.f); htitle (45); title (); dot (); grid (1, 1); solid (); color ("red"); fbars (x, yopen, yhigh, ylow, yclose, n); color ("fore"); endgrf (); name ("Volume * 10000", "y"); axspos (300, 1800); axslen (2400, 501); setgrf ("name", "name", "ticks", "ticks"); graf (xa, xe, xor, xstp, 0.f, 23000.f, 0.f, 5000.f); dot (); grid (1, 1); solid (); polcrv ("fbars"); color ("blue"); curve (x, yvol, n); rpng ("fchart_2.png"); disfin (); } int get_data (float *x, float *yopen, float *yhigh, float *ylow, float *yclose, float *yvol, int nmax) { struct data { int im; int id; int iy; float open; float high; float low; float close; int volume; } v[47] = { 1, 4, 2010, 30.62, 31.10, 30.59, 30.95, 38409100, 1, 5, 2010, 30.85, 31.10, 30.64, 30.96, 49749600, 1, 6, 2010, 30.88, 31.08, 30.52, 30.77, 58182400, 1, 7, 2010, 30.63, 30.70, 30.19, 30.45, 50559700, 1, 8, 2010, 30.28, 30.88, 30.24, 30.66, 51197400, 1, 11, 2010, 30.71, 30.76, 30.12, 30.27, 68754700, 1, 12, 2010, 30.15, 30.40, 29.91, 30.07, 65912100, 1, 13, 2010, 30.26, 30.52, 30.01, 30.35, 51863500, 1, 14, 2010, 30.31, 31.10, 30.26, 30.96, 63228100, 1, 15, 2010, 31.08, 31.24, 30.71, 30.86, 79913200, 1, 19, 2010, 30.75, 31.24, 30.68, 31.10, 46575700, 1, 20, 2010, 30.81, 30.94, 30.31, 30.59, 54849500, 1, 21, 2010, 30.61, 30.72, 30.00, 30.01, 73086700, 1, 22, 2010, 30.00, 30.20, 28.84, 28.96, 102004600, 1, 25, 2010, 29.24, 29.66, 29.10, 29.32, 63373000, 1, 26, 2010, 29.20, 29.85, 29.09, 29.50, 66639900, 1, 27, 2010, 29.35, 29.82, 29.02, 29.67, 63949500, 1, 28, 2010, 29.84, 29.87, 28.89, 29.16, 117513700, 1, 29, 2010, 29.90, 29.92, 27.66, 28.18, 193888500, 2, 1, 2010, 28.39, 28.48, 27.92, 28.41, 85931100, 2, 2, 2010, 28.37, 28.50, 28.14, 28.46, 54413700, 2, 3, 2010, 28.26, 28.79, 28.12, 28.63, 61397900, 2, 4, 2010, 28.38, 28.50, 27.81, 27.84, 77850000, 2, 5, 2010, 28.00, 28.28, 27.57, 28.02, 80960100, 2, 8, 2010, 28.01, 28.08, 27.57, 27.72, 52820600, 2, 9, 2010, 27.97, 28.34, 27.75, 28.01, 59195800, 2, 10, 2010, 28.03, 28.24, 27.84, 27.99, 48591300, 2, 11, 2010, 27.93, 28.40, 27.70, 28.12, 65993700, 2, 12, 2010, 27.81, 28.06, 27.58, 27.93, 81117200, 2, 16, 2010, 28.13, 28.37, 28.02, 28.35, 51935600, 2, 17, 2010, 28.53, 28.65, 28.36, 28.59, 45882900, 2, 18, 2010, 28.59, 29.03, 28.51, 28.97, 42856500, 2, 19, 2010, 28.79, 28.92, 28.69, 28.77, 44451800, 2, 22, 2010, 28.84, 28.94, 28.65, 28.73, 36707100, 2, 23, 2010, 28.68, 28.83, 28.09, 28.33, 52266200, 2, 24, 2010, 28.52, 28.79, 28.38, 28.63, 43165900, 2, 25, 2010, 28.27, 28.65, 28.02, 28.60, 48694000, 2, 26, 2010, 28.65, 28.85, 28.51, 28.67, 40370600, 3, 1, 2010, 28.77, 29.05, 28.53, 29.02, 43773800, 3, 2, 2010, 29.08, 29.30, 28.24, 28.46, 93123900, 3, 3, 2010, 28.51, 28.61, 28.35, 28.46, 48421200, 3, 4, 2010, 28.46, 28.65, 28.27, 28.63, 42890600, 3, 5, 2010, 28.66, 28.68, 28.42, 28.59, 56001800, 3, 8, 2010, 28.52, 28.93, 28.50, 28.63, 39414500, 3, 9, 2010, 28.56, 29.11, 28.55, 28.80, 50271600, 3, 10, 2010, 28.86, 29.11, 28.80, 28.97, 44891400, 3, 11, 2010, 28.89, 29.19, 28.85, 29.18, 35349700 }; int i, n = 0; for (i = 0; i < 47; i++) { if (i < nmax) { x[i] = incdat (v[i].id, v[i].im, v[i].iy); yopen[i] = v[i].open; yhigh[i] = v[i].high; ylow[i] = v[i].low; yclose[i] = v[i].close; yvol[i] = v[i].volume/ 10000.f; n++; } } return n; }
Candlestick Chart
#include <stdio.h> #include "dislin.h" #define NMAX 100 int get_data (float *x, float *yopen, float *yhigh, float *ylow, float *yclose, float *yvol, int nmax); main () { int n, ic1, ic2; float x[NMAX], yopen[NMAX], yhigh[NMAX], ylow[NMAX], yclose[NMAX], yvol[NMAX]; float xa, xe, xor, xstp; basdat (1,1,2000); n = get_data (x, yopen, yhigh, ylow, yclose, yvol, NMAX); xa = incdat (1, 1, 2010); xe = incdat (15, 3, 2010); xor = incdat (1, 1, 2010); xstp = 7.f; scrmod ("revers"); winsiz (600, (int) (2100. / 2900 * 600)); metafl ("cons"); disini (); pagera (); hwfont (); barwth (-20.f); labels ("Date", "x"); labmod ("form", "mdy", "x"); labmod ("month", "short", "x"); labmod ("year", "short", "x"); labmod ("separator", "/", "x"); ticks (7, "x"); name ("Price", "y"); name ("Date", "x"); labdig (-1, "y"); height (30); titlin ("Candlestick Chart", 3); axspos (300, 1300); axslen (2400, 900); setgrf ("ticks", "name", "ticks", "ticks"); graf (xa, xe, xor, xstp, 27.f, 32.f, 27.f, 1.f); htitle (45); title (); dot (); grid (1, 1); solid (); ic1 = intrgb (0.f, 1.f, 0.f); ic2 = intrgb (1.f, 0.f, 0.f); barclr (-1, ic1, ic2); fbars (x, yopen, yhigh, ylow, yclose, n); color ("fore"); endgrf (); name ("Volume * 10000", "y"); axspos (300, 1800); axslen (2400, 501); setgrf ("name", "name", "ticks", "ticks"); graf (xa, xe, xor, xstp, 0.f, 23000.f, 0.f, 5000.f); dot (); grid (1, 1); solid (); polcrv ("fbars"); color ("blue"); curve (x, yvol, n); rpng ("fchart_3.png"); disfin (); } int get_data (float *x, float *yopen, float *yhigh, float *ylow, float *yclose, float *yvol, int nmax) { struct data { int im; int id; int iy; float open; float high; float low; float close; int volume; } v[47] = { 1, 4, 2010, 30.62, 31.10, 30.59, 30.95, 38409100, 1, 5, 2010, 30.85, 31.10, 30.64, 30.96, 49749600, 1, 6, 2010, 30.88, 31.08, 30.52, 30.77, 58182400, 1, 7, 2010, 30.63, 30.70, 30.19, 30.45, 50559700, 1, 8, 2010, 30.28, 30.88, 30.24, 30.66, 51197400, 1, 11, 2010, 30.71, 30.76, 30.12, 30.27, 68754700, 1, 12, 2010, 30.15, 30.40, 29.91, 30.07, 65912100, 1, 13, 2010, 30.26, 30.52, 30.01, 30.35, 51863500, 1, 14, 2010, 30.31, 31.10, 30.26, 30.96, 63228100, 1, 15, 2010, 31.08, 31.24, 30.71, 30.86, 79913200, 1, 19, 2010, 30.75, 31.24, 30.68, 31.10, 46575700, 1, 20, 2010, 30.81, 30.94, 30.31, 30.59, 54849500, 1, 21, 2010, 30.61, 30.72, 30.00, 30.01, 73086700, 1, 22, 2010, 30.00, 30.20, 28.84, 28.96, 102004600, 1, 25, 2010, 29.24, 29.66, 29.10, 29.32, 63373000, 1, 26, 2010, 29.20, 29.85, 29.09, 29.50, 66639900, 1, 27, 2010, 29.35, 29.82, 29.02, 29.67, 63949500, 1, 28, 2010, 29.84, 29.87, 28.89, 29.16, 117513700, 1, 29, 2010, 29.90, 29.92, 27.66, 28.18, 193888500, 2, 1, 2010, 28.39, 28.48, 27.92, 28.41, 85931100, 2, 2, 2010, 28.37, 28.50, 28.14, 28.46, 54413700, 2, 3, 2010, 28.26, 28.79, 28.12, 28.63, 61397900, 2, 4, 2010, 28.38, 28.50, 27.81, 27.84, 77850000, 2, 5, 2010, 28.00, 28.28, 27.57, 28.02, 80960100, 2, 8, 2010, 28.01, 28.08, 27.57, 27.72, 52820600, 2, 9, 2010, 27.97, 28.34, 27.75, 28.01, 59195800, 2, 10, 2010, 28.03, 28.24, 27.84, 27.99, 48591300, 2, 11, 2010, 27.93, 28.40, 27.70, 28.12, 65993700, 2, 12, 2010, 27.81, 28.06, 27.58, 27.93, 81117200, 2, 16, 2010, 28.13, 28.37, 28.02, 28.35, 51935600, 2, 17, 2010, 28.53, 28.65, 28.36, 28.59, 45882900, 2, 18, 2010, 28.59, 29.03, 28.51, 28.97, 42856500, 2, 19, 2010, 28.79, 28.92, 28.69, 28.77, 44451800, 2, 22, 2010, 28.84, 28.94, 28.65, 28.73, 36707100, 2, 23, 2010, 28.68, 28.83, 28.09, 28.33, 52266200, 2, 24, 2010, 28.52, 28.79, 28.38, 28.63, 43165900, 2, 25, 2010, 28.27, 28.65, 28.02, 28.60, 48694000, 2, 26, 2010, 28.65, 28.85, 28.51, 28.67, 40370600, 3, 1, 2010, 28.77, 29.05, 28.53, 29.02, 43773800, 3, 2, 2010, 29.08, 29.30, 28.24, 28.46, 93123900, 3, 3, 2010, 28.51, 28.61, 28.35, 28.46, 48421200, 3, 4, 2010, 28.46, 28.65, 28.27, 28.63, 42890600, 3, 5, 2010, 28.66, 28.68, 28.42, 28.59, 56001800, 3, 8, 2010, 28.52, 28.93, 28.50, 28.63, 39414500, 3, 9, 2010, 28.56, 29.11, 28.55, 28.80, 50271600, 3, 10, 2010, 28.86, 29.11, 28.80, 28.97, 44891400, 3, 11, 2010, 28.89, 29.19, 28.85, 29.18, 35349700 }; int i, n = 0; for (i = 0; i < 47; i++) { if (i < nmax) { x[i] = incdat (v[i].id, v[i].im, v[i].iy); yopen[i] = v[i].open; yhigh[i] = v[i].high; ylow[i] = v[i].low; yclose[i] = v[i].close; yvol[i] = v[i].volume/ 10000.f; n++; } } return n; }
News
Update 11.5.2
8. April 2024
Support für Python 3.11 und Windows
28. Juli 2023
Bugfix für die X11-Distributionen
22. Juli 2023
Update 11.5.1
25. April 2023
Support für Linux 64-bit auf IBM z Rechnern
30. Oktober 2022
Support für MingW 64-bit mit UCRT Runtime-Umgebung
28. September 2022
Release 11.5
15. März 2022
Release 11.4
15. März 2021
Support für Free Pascal 64-bit unter Windows
22. Juli 2020
Upgrade 11.3.3
28. Juni 2020
DISLIN-Buch Version 11 ist erhältlich
8. März 2017
8. April 2024
Support für Python 3.11 und Windows
28. Juli 2023
Bugfix für die X11-Distributionen
22. Juli 2023
Update 11.5.1
25. April 2023
Support für Linux 64-bit auf IBM z Rechnern
30. Oktober 2022
Support für MingW 64-bit mit UCRT Runtime-Umgebung
28. September 2022
Release 11.5
15. März 2022
Release 11.4
15. März 2021
Support für Free Pascal 64-bit unter Windows
22. Juli 2020
Upgrade 11.3.3
28. Juni 2020
DISLIN-Buch Version 11 ist erhältlich
8. März 2017