Barnumber of the first bar displayed on the chart. Possible?

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1263
Joined: 23 Nov 2010
Has thanked: 717 times
Been thanked: 221 times

Barnumber of the first bar displayed on the chart. Possible?

Postby arjfca » 21 May 2012

Hello

Is it possible to get the value of the date and time of the first bar, displayed, on the left side on the chart?

Purpose, adding text to a created trendline via code. The position of the text would then be adjusted for each new first bar on the left

Martin
Attachments
First Bar.gif
First Bar.gif (26.39 KiB) Viewed 88 times

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: Barnumber of the first bar displayed on the chart. Possi

Postby TJ » 21 May 2012

arjfca wrote:Hello

Is it possible to get the value of the date and time of the first bar, displayed, on the left side on the chart?

Purpose, adding text to a created trendline via code. The position of the text would then be adjusted for each new first bar on the left

Martin


look up

getappinfo
These users thanked the author TJ for the post:
arjfca

arjfca
Posts: 1263
Joined: 23 Nov 2010
Has thanked: 717 times
Been thanked: 221 times

Re: Barnumber of the first bar displayed on the chart. Possi

Postby arjfca » 21 May 2012

TJ wrote:
arjfca wrote:Hello

Is it possible to get the value of the date and time of the first bar, displayed, on the left side on the chart?

Purpose, adding text to a created trendline via code. The position of the text would then be adjusted for each new first bar on the left

Martin


look up

getappinfo


Yes it work
Many thanks

Code: Select all

Var:DateTimeFirstBar (0);

DateTimeFirstBar = getappinfo(aiLeftDispDateTime);
If barstatus[1] = 2 then print (formatdate("dd-MM-yyyy",DateTimeFirstBar), " ", formattime("hh:mm:ss",DateTimeFirstBar));

I should be able to create an indicator to display a trendline with a string starting at the first bar on the left.

First time that I use the GetAppInfo. Interesting.

Martin :)
These users thanked the author arjfca for the post:
TJ

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: Barnumber of the first bar displayed on the chart. Possi

Postby TJ » 21 May 2012

arjfca wrote:
TJ wrote:
arjfca wrote:Hello

Is it possible to get the value of the date and time of the first bar, displayed, on the left side on the chart?

Purpose, adding text to a created trendline via code. The position of the text would then be adjusted for each new first bar on the left

Martin


look up

getappinfo


Yes it work
Many thanks

Code: Select all

Var:DateTimeFirstBar (0);

DateTimeFirstBar = getappinfo(aiLeftDispDateTime);
If barstatus[1] = 2 then print (formatdate("dd-MM-yyyy",DateTimeFirstBar), " ", formattime("hh:mm:ss",DateTimeFirstBar));

I should be able to create an indicator to display a trendline with a string starting at the first bar on the left.

First time that I use the GetAppInfo. Interesting.

Martin :)


Good work! Thanks for sharing the code.


ps. please check the bracket on "barstatus[1] = 2"


Return to “MultiCharts”