First of 7 Barnumber bars is missing  [SOLVED]

Questions about MultiCharts and user contributed studies.
tusa
Posts: 4
Joined: 14 Nov 2012

First of 7 Barnumber bars is missing

Postby tusa » 14 Nov 2012

Hello,

I am using the below code to ma Heiken Ashi chart, but whatever I use it for any symbol, it sill cannot show the first of 7 BarNumber.
But if I using the MC bulit-in Heiken Ashi or Hollow Candlestick, it can be shown back.

Do I miss someting? Or it is right if it is through code to make any chart? :(

Fm: Tusa

Code: Select all

inputs:
UpColor(green),
DnColor(red);

vars:
haClose(0),
haOpen(0),
haHigh(0),
haLow(0),
color(0);

if BarNumber = 1 then
begin
haOpen = open;
haClose = (O+H+L+C)/4;
haHigh = MaxList( high, haOpen, haClose);
haLow = MinList( low, haOpen,haClose);
end;

if BarNumber > 1 then
begin
haClose = (O+H+L+C)/4; ////average bar price
haOpen = (haOpen [1] + haClose [1])/2 ; ////avg open/close 1 bar ago
haHigh = MaxList(High, haOpen, haClose) ; ////highest of high,open,close
haLow = MinList(Low, haOpen, haClose) ; //// lowest of low, open, close

if haClose > haOpen then color = UpColor
else color = DnColor;

plotPB(haOpen,haClose,"heikin-ashi",color);
SetPlotWidth(1,4);
SetPlotColor(1,color);
end;
Attachments
002.jpg
(149.07 KiB) Downloaded 428 times
001.jpg
(137.54 KiB) Downloaded 417 times

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

Re: First of 7 Barnumber bars is missing

Postby TJ » 14 Nov 2012

Hello,

I am using the below code to ma Heiken Ashi chart, but whatever I use it for any symbol, it sill cannot show the first of 7 BarNumber.
But if I using the MC bulit-in Heiken Ashi or Hollow Candlestick, it can be shown back.

Do I miss someting? Or it is right if it is through code to make any chart? :(
Look up SetMaxBarsBack.

tusa
Posts: 4
Joined: 14 Nov 2012

Re: First of 7 Barnumber bars is missing

Postby tusa » 14 Nov 2012

Much thanks, TJ!!

I just added SetMaxBarsBack(1) above the "if BarNumber = 1 then"...
The case is improved, but it still only can shows fm BarNumber = 3.
Base on the code, it should define if BarNumber = 1 then... & > 1 then...
But why still lost the first 2 BarNumber bars? Please advise. :D
Attachments
003.jpg
(119.04 KiB) Downloaded 426 times

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

Re: First of 7 Barnumber bars is missing

Postby TJ » 14 Nov 2012

Much thanks, TJ!!

I just added SetMaxBarsBack(1) above the "if BarNumber = 1 then"...
The case is improved, but it still only can shows fm BarNumber = 3.
Base on the code, it should define if BarNumber = 1 then... & > 1 then...
But why still lost the first 2 BarNumber bars? Please advise. :D
Based on your code, how many bars of calculation does it take to draw the first Heiken Ashi?

tusa
Posts: 4
Joined: 14 Nov 2012

Re: First of 7 Barnumber bars is missing

Postby tusa » 14 Nov 2012

Hi, TJ

Sorry about I am newbie. For my concept, the "if BarNumber=1...", it only calculate itself's O,H,L,C to calculate and draw bar. And "if BarNumber>1...", it will take itself and previous one's data to make it. So it suppose can draw the first bar and second bar, not start to draw from the third bar. What I miss? Thanks! :(

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

Re: First of 7 Barnumber bars is missing

Postby TJ » 14 Nov 2012

Multicharts starts calculating at the first bar after SetMaxBarsBack.

tusa
Posts: 4
Joined: 14 Nov 2012

Re: First of 7 Barnumber bars is missing

Postby tusa » 15 Nov 2012

Hi, TJ

Thanks for your answer again. After your advise, now only missing the first bar only on chart, better than missed first 7 bars before. The SetMaxBarsBack() is only minimize set to SetMaxBarsBack(1), and you said that the first bar would be calculated after SetMaxBarsBack. So, the "if BarNumber = 1..." code should be no shows? And does the maximize showing chart is from the BarNumber = 2 like as the attached chart?
Attachments
004.jpg
(121.35 KiB) Downloaded 423 times

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

Re: First of 7 Barnumber bars is missing

Postby TJ » 15 Nov 2012

Hi, TJ

Thanks for your answer again. After your advise, now only missing the first bar only on chart, better than missed first 7 bars before. The SetMaxBarsBack() is only minimize set to SetMaxBarsBack(1), and you said that the first bar would be calculated after SetMaxBarsBack. So, the "if BarNumber = 1..." code should be no shows? And does the maximize showing chart is from the BarNumber = 2 like as the attached chart?
BarNumber starts counting at the first bar after SetMaxBarsBack.


For further study, look up:

BarNumber
Currentbar
MaxBarsBack

EasyLanguage Functions and Reserved Words Reference
https://www.multicharts.com/multicharts ... mentation/

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

Re: First of 7 Barnumber bars is missing  [SOLVED]

Postby TJ » 15 Nov 2012

Hi, TJ

Thanks for your answer again. After your advise, now only missing the first bar only on chart, better than missed first 7 bars before. The SetMaxBarsBack() is only minimize set to SetMaxBarsBack(1), and you said that the first bar would be calculated after SetMaxBarsBack. So, the "if BarNumber = 1..." code should be no shows? And does the maximize showing chart is from the BarNumber = 2 like as the attached chart?
The "BarNumber" you see in the Tracking Window is not the same BarNumber you see in your code.

The "BarNumber" you see in the Tracking Window is the actual bar count.
This is equivalent to the keyword Symbol_Currentbar.
This is a new keyword, you will find this keyword in the wiki only.

The BarNumber you see in your code is a function. It is a calculated number, thus it starts after the SetMaxBarsBack.
You will find this function in the wiki as well as in the ebook in previous post.


If you add the following to your code, you will see the differences of the numbers in the Tracking Window.

Code: Select all

plot100(barnumber, "--Bar number--");
plot101(symbol_currentbar, "--Symbol Currentbar--");


Return to “MultiCharts”