Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 30
|
Hello
How do I get the closing price of the first displayed bar on a chart?
I am trying to create an indicator similar to the Performance indicator, but I am not interested in the first loaded bar. In other words, I want my indicator's values change as I display more or less data in my chart.
Thanks
bikhod
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
You can replace "CLOSE" with any other data or indicator in the formula below:
[code:1:85234d79bd]
DataArray:=CLOSE;
Bar1:=Cum(IsDefined(DataArray))=1;
FirstValue:=ValueWhen(1,Bar1,DataArray);
FirstValue
[/code:1:85234d79bd]
jose '-)
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 30
|
Thanks, but this is still returning the closing price of the first loaded period, so even if I am displaying the last six months of a 10 year chart, it seems to go back to the close of 10 years ago.
If I have 10 years of data loaded, and I am viewing on my screen just the last year of it, then I would like to know what the closing price was at the beginning of portion being viewed i.e. closing price at the beginning of the tenth year.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
First find out how many bars MetaStock is loading for chart display:
MetaStock -> File -> Open -> Options -> Load Options
Then assuming that the chart display Nr of periods is (for example) 190 bars:
[code:1:491555a9d3]
pds:=190;
DataArray:=CLOSE;
FirstChartVal:=LastValue(Ref(DataArray,-pds+1));
FirstChartVal
[/code:1:491555a9d3]
In MetaStock, there is no automatic way to detect the displayed Nr of bars in a chart, that I know of.
jose '-)
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 30
|
Thanks Jose, you are a star!
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.