How to get the BN of the leftmost bar on current chart ?  [SOLVED]

Questions about MultiCharts and user contributed studies.
maxmax68
Posts: 163
Joined: 20 Nov 2012
Has thanked: 55 times
Been thanked: 48 times

How to get the BN of the leftmost bar on current chart ?  [SOLVED]

Postby maxmax68 » 10 Jul 2016

Hello,

how can I find the barnumber of the leftmost bar displayed in the current chart ?


Best regards.
Massimo

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

Re: How to get the BN of the leftmost bar on current chart ?

Postby TJ » 10 Jul 2016

Hello,

how can I find the barnumber of the leftmost bar displayed in the current chart ?


Best regards.
Massimo

Look up the following keywords:


GetBarNumber
GetAppInfo
aileftdispdatetime

maxmax68
Posts: 163
Joined: 20 Nov 2012
Has thanked: 55 times
Been thanked: 48 times

Re: How to get the BN of the leftmost bar on current chart ?

Postby maxmax68 » 10 Jul 2016

Look up the following keywords:


GetBarNumber
GetAppInfo
aileftdispdatetime
Thanks TJ,
but I need to find the bar number of the leftmost bar currently in the chart, not the datetime!
I do not see how to achieve that with those keywords.

Best regards.
Massimo

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How to get the BN of the leftmost bar on current chart ?

Postby JoshM » 11 Jul 2016

but I need to find the bar number of the leftmost bar currently in the chart, not the datetime!
I do not see how to achieve that with those keywords.
If you know the DateTime value of the leftmost bar, you can compare that with the `DateTime` value of the recent price bars to see whether that bar is the leftmost bar or not. You probably need to create a loop for that, and then check if each recent price bar has the time of the leftmost bar.

You can also place a drawing on that leftmost bar and then use `Arw_GetBarNumber()` or `Text_GetBarNumber()` as TJ suggested. Then if you know that bar number you can compare it to the current bar number (probably `CurrentBar`).

maxmax68
Posts: 163
Joined: 20 Nov 2012
Has thanked: 55 times
Been thanked: 48 times

Re: How to get the BN of the leftmost bar on current chart ?

Postby maxmax68 » 11 Jul 2016

You can also place a drawing on that leftmost bar and then use `Arw_GetBarNumber()` or `Text_GetBarNumber()` as TJ suggested.
Thanks TJ and JoshM,
now I got it.

Code: Select all

value1=getappinfo(aileftdispdatetime);
value2=getappinfo(aiLowestDispValue);
text_delete(value5);
value3=text_new_dt(value1,value2+5,"");
value4=text_getbarnumber(value3);
text_delete(value3);
value5=text_new_bn(value4+10,value2+1,numtostr(value4,0));
Best regards.
Massimo


Return to “MultiCharts”