11.85 Sample ‘ohlc

Function ohlc draw Open-High-Low-Close diagram. This diagram show vertical line for between maximal(high) and minimal(low) values, as well as horizontal lines before/after vertical line for initial(open)/final(close) values of some process.

MGL code:

new o 10 '0.5*sin(pi*x)'
new c 10 '0.5*sin(pi*(x+2/9))'
new l 10 '0.3*rnd-0.8'
new h 10 '0.3*rnd+0.5'
subplot 1 1 0 '':title 'OHLC plot':box:ohlc o h l c

C++ code:

void smgl_ohlc(mglGraph *gr)	// flow threads and density plot
{
	mglData o(10), h(10), l(10), c(10);
	gr->Fill(o,"0.5*sin(pi*x)");	gr->Fill(c,"0.5*sin(pi*(x+2/9))");
	gr->Fill(l,"0.3*rnd-0.8");		gr->Fill(h,"0.3*rnd+0.5");
	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("OHLC plot");	}
	gr->Box();	gr->OHLC(o,h,l,c);
}

Sample ohlc