Discussions
»
Product and Service Development
»
Formula Assistance
»
Returning price bar H or L based on HHV in some other parameter - ValueWhen()?
Rank: Newbie
Groups: Registered, Registered Users, Unverified Users Joined: 7/11/2011(UTC) Posts: 8
|
Normal
0
MicrosoftInternetExplorer4
Hi
I am trying to analyse blocks of price bars for degree of overlap and
whether the way bars overlap can signal entries. I am trying to do this by
identifying the widest ranging bar (High minus Low) within 20 periods and then
check how much the other bars overlap against this widest ranging bar.
Using HHV(H-L,20) it is easy enough to identify widest ranging bar and it
is easy enough to return the periods elapsed since the wide ranging bar using HHVbars.
But I cannot figure out how to return the High and Low of that bar. It seems ValueWhen() should be used but I cannot see how to do it.
ValueWhen(1,(H-L)= HHV(H-L,20),H {or L}) is not sufficient because the
data point may not be the HHV when it occurs, it may only become the HHV when a
higher value data point passes out of the older end of the array. I would use
ref(H,-HHVbars(H-L)) if you could use expressions within the ref() function.
Any pointers as to my next step greatly appreciated.
Thanks perth RAT
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
|
|
|
|
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)
|
I'm not quite sure what you're trying to achieve, but I reckon the forum.dll (see files section) variable ref function will help.
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
I agree with Wabbit -- you will have to do a better job of explaining and/or showing what you want to accomplish, perhaps through posting whatever code you've managed so far, and perhaps a chart, marked up to show what exactly it is that you want.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Unverified Users Joined: 7/11/2011(UTC) Posts: 8
|
Thanks for replies Wabbit and jjstein. Been sitting here trying to post a chart for last ages and no success. Will leave for now.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
Upload to IMGUR, use the BBCODE option.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Unverified Users Joined: 7/11/2011(UTC) Posts: 8
|
(I have attached file via IMGUR as suggested.Preview of this post does not let me see the chart. So if it is not there please ignore this post.)
Lets say I want to compare bar ranges and overlap against the widest ranging bar of the past 20 bars. My HHV20 HL range indicator identifies that during periods in "B" , price bar "D" had the 20 period widest range (H minus L). I would like to return the H value and L value of price bar "D" in any periods in the "B" timeframe.
Thanks Wabbit for pointing out the DLL files, I'll try them. But I was also wondering if I could use ValueWhen().
Hope this explanation is clearer.
perth RAT
|
|
|
|
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)
|
Check your email.
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
wabbit wrote:Check your email. Oh, sure...now that I'm interested, keep it a secret!
I'm telling you-know-who to put a lump of coal in your stocking...
|
|
|
|
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)
|
If the solution works, I'll post it....
Until then.... hurry up and wait [:D]
wabbit [:D]
|
|
|
|
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)
|
This is what I submitted to the OP: Code:
{== requires forum.dll ==}
prd:=20;
range:=H-L;
highestRangeinPeriod:=HHV(range,prd);
lookForward:=Min(BarsSince(range=highestRangeinPeriod),Min(LastValue(Cum(1))-Cum(1),prd-1));
futureHighestRange:=ExtFml("forum.Ref",highestRangeinPeriod,-lookForward);
{polarity is reversed in forum.ref}
test:=range=highestRangeinPeriod OR range=futureHighestRange;
highRangeBarHigh:=ValueWhen(1,test,H);
highRangeBarLow:=ValueWhen(1,test,L);
{plot in chart window}
highRangeBarHigh;
highRangeBarLow;
The key to this lies in looking into the future
a specific period to see if the current bar will eventually be a highest
range bar, and return the high and low values for this bar; to do this
requires us to look when the previous highest range bar occurred, the
periods expire or we reach the right hand side of the chart and take the
minimum of these three values, then use the forum.dll variable-period
Ref() function.
I see an issue with this code on the first instances of the new higher
range values on the left hand side of the chart, but to solve these will
require the use of internal loops (which MS cannot do) so will require
an external function. As I am unsure of how the user will employ this, I am unsure whether my solution meets his needs? If you want to put the indicator back into the "right place" with respect to time, then simply change the last two lines to read: Code:
{plot in chart window}
ExtFml("forum.ref",highRangeBarHigh,lf);
ExtFml("forum.ref",highRangeBarLow,lf);
We'll have to see until we hear from RAT again to see if this is in fact the solution.... but it was a good thinking exercise! wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
My take on perth Rat's request also requires the forum.dll but does not use the ValueWhen function.
Code:Prd:=20;
Hx:=
ExtFml("Forum.Ref",H,HHVBars(H-L,Prd));
Lx:=
ExtFml("Forum.Ref",L,HHVBars(H-L,Prd));
Hx;Lx
oztrader
|
|
|
|
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)
|
That's basically where I started too and then noticed regions where the returned values didn't meet the criteria (or what I think the criteria was supposed to be? Or was it just the way I was looking at the charts??) Most of the code I ended up with is error handling or working around the limitations of the scripting language. I'm still not sure of the usefulness of this, or even if I've got the concept right... that's up to RAT I suppose? Nice code though.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Unverified Users Joined: 7/11/2011(UTC) Posts: 8
|
Hey guys. Thanks for the thorough response and discussion. No coal for you guys... [;)]
I haven't had a chance to spend much time on play with this. Also have problem. Cannot find the DLL's in Metastock. Have looked at other post on this subject and all seems in order. Have/will attach screenshots of file location/path and indicator builder window with greyed out "functions" button.
Do I need to import these using the indicator builder organizer. The manual and posts did not say anything about this ?option?.
How I plan to use this - once the widest ranging bar is ID'd I can score all the other bars in the period against it for how much each of the other bars is within the bounds of the wide ranging bar (0 -100%) and also how much of the widest ranging bar they "cover" (0-100%) . I can weight these two attributes and come up with a total score (add up all the other bars scores) which will maybe give me a scannable, rankable quality of consolidation. I can maybe use less periods to ID flags - and more periods to ID longer basing/consolidation patterns. Make sense?
By the way I know if you respond before christmas , you don't have enough going on.
Merry Christmas.
RAT
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Unverified Users Joined: 7/11/2011(UTC) Posts: 8
|
|
|
|
|
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)
|
The functions button is not available when the cursor is in the indicator title text box, but will be activated when the cursor is in the formula text box.
wabbit[:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Unverified Users Joined: 7/11/2011(UTC) Posts: 8
|
{smacks forehead - but still thinks merely clicking with mouse should be sufficient}
thanks
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Returning price bar H or L based on HHV in some other parameter - ValueWhen()?
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.