Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 1/22/2011(UTC) Posts: 34
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Hope everyone is well,
Just have a really quick question if you have time,
Ref(C,-1) refers to the closing price yesterday, is it possible to reference the last 30 days without having to type
Ref(C,-1) AND Ref(C,-2) AND Ref(C,-3) Etc…
Thanks guys
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Specifically, what do you want to do with the data? Compare it something? Add it up? Count something?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 1/22/2011(UTC) Posts: 34
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Hi Wabbit,
As an example i have a custom indicator that im working on and i would like the CLOSE price to be greater than that indicator value for the last 20 Bars.
Typing out -1, -2, -3, -4 etc all the way to 20 looks sloppy, im sure there is an easy way to code it without having to do that.
Ref(CLOSE>(Fml("TEST)),-1) AND Ref(CLOSE>(Fml("TEST)),-2) AND Ref(CLOSE>(Fml("TEST)),-3) AND etc, etc, etc
Thanks
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Try: Code:
ind:=Fml("TEST");
{plot}
C>Ref(HHV(ind,20),-1);
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 1/22/2011(UTC) Posts: 34
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Thanks Wabbit, but unfortunately that did not work.
The HHV function only returns the highest value of the selected `data array'
From the looks of it when using, ref( DATA ARRAY, PERIODS )
"PERIODS" in the function must only be a constant, not variable.
MetaStock limitation...
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 1/22/2011(UTC) Posts: 34
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Never mind, managed to work it out by doing away entirely with the Ref function and instead using the BarsSince function.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
You might also find HighestSince() helpful? If you want to employ dynamic look back lengths, you could use the functionality of the Forum.dll
BTW: you never mentioned anything about the look back period being dynamic, you only said 20 bars. When asking for assistance, the more information you provide, the better the answer will be. Also, posting the first response worked and then later editing the post to say the code didn't work won't win you many friends and is best avoided.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 1/22/2011(UTC) Posts: 34
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Please accept my sincere apology Wabbit, I mean no disrespect by editing my post. I’m very appreciative of the help you have provided me.
The truth is it was late at night and I did some pretty basic testing of the new indicator and I thought it was working correctly. I did some more thorough testing the next morning and found a few errors in how I was trying to construct the formula.
Cheers
|
|
|
|
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.