Plot the HighPrices, LowPrices, ClosePrices and OpenPrices of a security as a candlestick chart.
See also: datenum, datestr, datevec, highlow, bolling, dateaxis, movavg, pointfig.
The following code
 1
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices );
 title("default plot.");
Produces the following output
ans = 1
and the following figure
| Figure 1 | 
|---|
![]()  | 
The following code
 2
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices, 'brk' );
 title("default plot with user selected black background");
Produces the following output
ans = 2
and the following figure
| Figure 1 | 
|---|
![]()  | 
The following code
 3
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices, 'brkg' );
 title("default color candlestick bodies and user selected background and wick colors");
Produces the following output
ans = 3
and the following figure
| Figure 1 | 
|---|
![]()  | 
The following code
 4
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices, 'gmby' );
 title("all four colors being user selected");
Produces the following output
ans = 4
and the following figure
| Figure 1 | 
|---|
![]()  | 
The following code
 5
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 datenum_vec = [ 7.3702e+05; 7.3702e+05 ;7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05; ...
 7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05 ];
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices, 'brwk', datenum_vec, "yyyy-mm-dd" );
 title("default plot with datenum dates and character dateform arguments");
Produces the following output
ans = 5
and the following figure
| Figure 1 | 
|---|
![]()  | 
The following code
 6
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 datenum_vec = [ 7.3702e+05; 7.3702e+05 ;7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05; ...
 7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05 ];
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices, 'brk', datenum_vec, 29 );
 title("default plot with user selected black background with datenum dates and integer dateform arguments");
Produces the following output
ans = 6
and the following figure
| Figure 1 | 
|---|
![]()  | 
The following code
 7
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 datenum_vec = [ 7.3702e+05; 7.3702e+05 ;7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05; ...
 7.3702e+05; 7.3702e+05; 7.3702e+05; 7.3702e+05 ];
 datevec_vec = datevec( datenum_vec );
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices, 'brwk', datevec_vec, 23 );
 title("default plot with datevec dates and integer dateform arguments");
Produces the following output
ans = 7
and the following figure
| Figure 1 | 
|---|
![]()  | 
The following code
 8
 close();
 OpenPrices = [ 1292.4; 1291.7; 1291.8; 1292.2; 1291.5; 1291.0; 1291.0; 1291.5; 1291.7; 1291.5; 1290.7 ];
 HighPrices = [ 1292.6; 1292.1; 1292.5; 1292.3; 1292.2; 1292.2; 1292.7; 1292.4; 1292.3; 1292.1; 1292.9 ];
 LowPrices = [ 1291.3; 1291.3; 1291.7; 1291.1; 1290.7; 1290.2; 1290.3; 1291.1; 1291.2; 1290.5; 1290.4 ];
 ClosePrices = [ 1291.8; 1291.7; 1292.2; 1291.5; 1291.0; 1291.1; 1291.5; 1291.7; 1291.6; 1290.8; 1292.8 ];
 character_dates = char ( [] );
 for i = 1 : 11
 character_dates = [ character_dates ; "a date" ] ;
 endfor
 candle( HighPrices, LowPrices, ClosePrices, OpenPrices, 'brk', character_dates );
 title("default plot with user selected black background with character dates argument");
Produces the following output
ans = 8
and the following figure
| Figure 1 | 
|---|
![]()  | 
Package: financial