Incorrect BarNumber and CurrentBar?

Questions about MultiCharts and user contributed studies.
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Incorrect BarNumber and CurrentBar?

Postby 2haerim » 22 May 2008

I plotted 1 min / 100 bars back chart and see the BarNumber from the Hint window correctly, however in PowerLanguage Editor's print statement prints wrong value.

For example, the last BarNumber from Hint was 107, but the following print shows 57 and 225 for CurrentBar and BarNumber, respectively.


57 225
57 225
57 225
57 225
58 226
58 226
58 226

Anything am I missing here?

Posts: 218
Joined: 31 Jul 2005

Postby drwar » 23 May 2008

I believe its offset by the maxbarsback setting. If its set to automatic. Set it to a fixed number and you should be able to calculate the correct barnumber.


User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 23 May 2008

Hi HaeRim,

J's explanation is perfectly correct.

However, the real problem here is why you have two values that are so different (57 vs 225): currentbar and barnumber should return the same value and it is not quite clear why in your case they don't. We couldn't reproduce the problem on our end.

Please contact us directly to show the issue (if you can reproduce it)


Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Postby 2haerim » 04 Jun 2008

In new 3.1.1304.201 release,

I tested the following indicator on 1min/100 bars back chart and MBB is set to 40.


The BarNumber value from the chart's Hint window and from the output bar of PLEditor is different.

Chart => 100
Output => 60

It seems that Chart's BarNumber is an ABSOULTE number reflecting all the number of bars in the current chart, and PLEditor Output's BarNumber is RELATIVE and offset from the MBB which is set to 40.

Why not use the same BarNumber(either Absolute or Relative, but preferrably Relative) in both cases? If they were the same values, I wouldn't have to post this article.

Is this correct? Just want to know more exactly and clearly how those two BarNumber values are different.

As an idea, I propose to display both values in the Hint window like:


where first one is ABSOULTE and second one is RELATIVE barnumber. This way one can easily find the MBB applied to the chart.

Or display BarNumber along with MBB like:

, where 60 is the Relative number and simply adding MBB would result in the Absolute barnumber 100.

Also, it might be useful adding another keyword BarNumber_A and CurrentBar_A to return ABSOLUTE bar number.

Return to “MultiCharts”