Page 1 of 1

Coding help: how to plot a bar gradually?

Posted: 22 Jun 2009
by 2haerim
I am trying to paint a bar in a tick-count chart. For example, 10 tick chart.

I would like to paint the bar(possibly candle) in 10 levels for each tick received. For the 1st tick, I would paint 1/10th of the bar, for 2nd tick, 2/10th of the bar, and so on. For the last 10th tick, the bar would be painted fully. Once the current bar becomes an old one, the painting for that bar should be removed.

I am thinking to use this as an alternative for the Tick counter.

Is this possible? If so, please kindly write a code for this.

Thanks.

HR

Posted: 22 Jun 2009
by 2haerim
I got it myself as below. It's the simple and basic, and someone might refine more.

Code: Select all

Var: Level(0);
Level = (h-l)*Ticks/BarInterval;
PlotPaintBar(L+Level ,Low,l,L+Level ,"",Yellow, BarInterval);
NoPlot(1)[1];
NoPlot(2)[1];
NoPlot(3)[1];
NoPlot(4)[1];

Posted: 22 Jun 2009
by TJ
PlotPaintBar(h, l, o, c, "p", blue, default, ticks);

Posted: 22 Jun 2009
by TJ
I just realized, LineWidth can go beyond 14 !

PlotPaintBar (BarHigh, BarLow, BarOpen, BarClose <,"PlotName"<,PlotColor <,Default <,LineWidth >>>>)


LineWidth
- an optional parameter; specifies the plot line width, ranging from 1 to 14

Posted: 22 Jun 2009
by 2haerim
TJ,

thanks for the tips.

But your code does not clearly show when the tick bar will be completed, meanwhile, mine works like level gauge. When the last tick is to received, 9/10th of the bar gets colored yellow, and finally the last tick completely fills the bar with yellow. So, it is easier to know then end of a bar is approaching, I think.

HR

Posted: 22 Jun 2009
by TJ
TJ,

thanks for the tips.

But your code does not clearly show when the tick bar will be completed, meanwhile, mine works like level gauge. When the last tick is to received, 9/10th of the bar gets colored yellow, and finally the last tick completely fills the bar with yellow. So, it is easier to know then end of a bar is approaching, I think.

HR

I posted my simple suggestion before I saw your post.

Posted: 22 Jun 2009
by 2haerim
A little more refinement.
It now changes color depending on the direction.

Code: Select all

Var: GaugeLevel(0);
GaugeLevel = (h-l)*Ticks/BarInterval;
PlotPaintBar(Low+GaugeLevel,Low,Low,Low+GaugeLevel,"",iff(O>C,Blue,iff(O<C,Red,Yellow)), BarInterval);
NoPlot(1)[1];
NoPlot(2)[1];
NoPlot(3)[1];
NoPlot(4)[1];