paint inside bars

Questions about MultiCharts and user contributed studies.
User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

paint inside bars

Postby arnie » 16 May 2011

I don't know if this is a bug or not, since is not something that happens all the time, bit it happens.

I applied a simple study, to paint inside bars.

Code: Select all

if high <= high[1] and low >= low[1] then
PlotPaintBar(h, l, o, c, "", blue);
Notice that from the start of the overnight session, until the start of the european session, there's no problem with the painting, but afterwords we see bars being half painted, which is a very strange reaction.

Even stranger is when I compile the study again, leaving it exactly as it is, and the bars start to be painted correctly.

Why is this happening?

Regards,
Fernando
Attachments
inside bar.png
(54.87 KiB) Downloaded 699 times

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Re: MC 7 Beta 3 - Questions/Issues

Postby piranhaxp » 16 May 2011

It offen occur if the study is running in "tick-by-tick" mode .... After re-compiling it again, the history will be updated ;o). So check the "Update on every tick" is not checked in the property windows of the indicator.

Mike

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: MC 7 Beta 3 - Questions/Issues

Postby arnie » 16 May 2011

It offen occur if the study is running in "tick-by-tick" mode .... After re-compiling it again, the history will be updated ;o). So check the "Update on every tick" is not checked in the property windows of the indicator.

Mike
Thanks Mike.

The weird thing is that I have a couple of indicators where some bars are painted and this never happened. At least I never noticed.
Truth be told, none paint inside bars.

Regards

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Re: MC 7 Beta 3 - Questions/Issues

Postby piranhaxp » 16 May 2011

Arnie .... I never experienced a problem like you have. But with conditions like your's I'm always working different. First be cautious with 'and' commends in EL. I always put each part of the condition in braces. I know it sounds trivial. But had so many problems with it. And may I'm wrong, but from my standpoint bars with h=h[1] and/or l=l[1] are no inside-bars.

May try this one :

Code: Select all

input : color(yellow);

var : ib(false);

ib = (h<h[1]) and (l>l[1]);

if ib then
begin
plotpaintbar(h,l,o,c,"",color);
end;
Give it a try ....

Regards.

Mike

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: MC 7 Beta 3 - Questions/Issues

Postby arnie » 16 May 2011

Arnie .... I never experienced a problem like you have. But with conditions like your's I'm always working different. First be cautious with 'and' commends in EL. I always put each part of the condition in braces. I know it sounds trivial. But had so many problems with it. And may I'm wrong, but from my standpoint bars with h=h[1] and/or l=l[1] are no inside-bars.

May try this one :

Code: Select all

input : color(yellow);

var : ib(false);

ib = (h<h[1]) and (l>l[1]);

if ib then
begin
plotpaintbar(h,l,o,c,"",color);
end;
Give it a try ....

Regards.

Mike

Regarding inside bars, if the high and low are inside the previous high and low, we have an inside bar, even if that high and low are equal. If it's not above or below, it's inside.

When I'm trying basic stuff, I tend not worry much about the code, and it's natural that from time to time, that lack of worry result in errors such as this one.

But the problem with it is definitely the tick by tick update.
If we say something like:

Code: Select all

if high > high[1] then
PlotPaintBar(h, l, o, c, "", green)
else
if low < low[1] then
PlotPaintBar(h, l, o, c, "", red);
the tick by tick update allow the bars to be painted correctly.

So it seems that the inside bar is the only one that generates that type of error while painting the bars.

Couldn't this be an indication that something might not be OK with the paint bar reserved word when we select the tick by tick update?


Regards

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: MC 7 Beta 3 - Questions/Issues

Postby TJ » 16 May 2011

I don't know if this is a bug or not, since is not something that happens all the time, bit it happens.

I applied a simple study, to paint inside bars.

Code: Select all

if high <= high[1] and low >= low[1] then
PlotPaintBar(h, l, o, c, "", blue);
Notice that from the start of the overnight session, until the start of the european session, there's no problem with the painting, but afterwords we see bars being half painted, which is a very strange reaction.

Even stranger is when I compile the study again, leaving it exactly as it is, and the bars start to be painted correctly.

Why is this happening?

Regards,
Fernando
ask yourself this real time question...

what happens if the bar started out as an inside bar ...
but expanded to be a higher high bar by the end of the bar?

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Re: MC 7 Beta 3 - Questions/Issues

Postby piranhaxp » 16 May 2011

TJ .....

you were faster then me ... agreed. That's why I said :
It offen occur if the study is running in "tick-by-tick" mode .... After re-compiling it again, the history will be updated ;o). So check the "Update on every tick" is not checked in the property windows of the indicator.

Mike
Regards.

Mike

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: MC 7 Beta 3 - Questions/Issues

Postby arnie » 16 May 2011

ask yourself this real time question...

what happens if the bar started out as an inside bar ...
but expanded to be a higher high bar by the end of the bar?
Maybe 95% of all bars start as inside bars and then they expand up or down.
So those 95% would always start as... blue, and then as soon as the previous high or low is broken, the blue would be replaced by green or red.

When the previous high or low is broken you cannot change the fact that it has been broken.
The close of the bar has nothing to do with the reading.

As soon as this ticks crosses the previous tick upwards, that is a done deal, that is the signal to change colours. I don't care if the next tick is lower or if the last tick of the bar is even lower.

That is my "real time" reading, my human thinking.
I know that computers think differently, and that has been my Achilles' heel when dealing with coding.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: MC 7 Beta 3 - Questions/Issues

Postby TJ » 16 May 2011

ask yourself this real time question...

what happens if the bar started out as an inside bar ...
but expanded to be a higher high bar by the end of the bar?
Maybe 95% of all bars start as inside bars and then they expand up or down.
So those 95% would always start as... blue, and then as soon as the previous high or low is broken, the blue would be replaced by green or red.

When the previous high or low is broken you cannot change the fact that it has been broken.
The close of the bar has nothing to do with the reading.

As soon as this ticks crosses the previous tick upwards, that is a done deal, that is the signal to change colours. I don't care if the next tick is lower or if the last tick of the bar is even lower.

That is my "real time" reading, my human thinking.
I know that computers think differently, and that has been my Achilles' heel when dealing with coding.
you are on the right track...
you just have to tell the computer what to do
your wish is the computer's command:

you can modify your code with this addition:

Code: Select all

if high <= high[1] and low >= low[1] then
PlotPaintBar(h, l, o, c, "", blue)
ELSE
{-- what would you like MC to do when the bar has broken out of inside bar ? --}

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: MC 7 Beta 3 - Questions/Issues

Postby arnie » 16 May 2011

you are on the right track...
you just have to tell the computer what to do
your wish is the computer's command:

you can modify your code with this addition:

Code: Select all

if high <= high[1] and low >= low[1] then
PlotPaintBar(h, l, o, c, "", blue)
ELSE
{-- what would you like MC to do when the bar has broken out of inside bar ? --}

... and let it be light ...

Yes, the computer knew what to do if prices stayed inside the previous bar's range, but had no clue what to do when that range was broken.

One again, thanks TJ.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: MC 7 Beta 3 - Questions/Issues

Postby TJ » 16 May 2011

you are on the right track...
you just have to tell the computer what to do
your wish is the computer's command:

you can modify your code with this addition:

Code: Select all

if high <= high[1] and low >= low[1] then
PlotPaintBar(h, l, o, c, "", blue)
ELSE
{-- what would you like MC to do when the bar has broken out of inside bar ? --}

... and let it be light ...

Yes, the computer knew what to do if prices stayed inside the previous bar's range, but had no clue what to do when that range was broken.

One again, thanks TJ.
You are welcome.
Glad you saw the light.


Return to “MultiCharts”