Discussions
»
Product and Service Development
»
Formula Assistance
»
Market Structure Short/Inter/Long Term Highs/Lows - Larry Williams
Rank: Newbie
Groups: Registered, Registered Users Joined: 11/23/2012(UTC) Posts: 5
|
Hello,
Hoping someone can help.
I've tried to search for ways (within the threads) for a means of labelling Swing Highs and Lows but to no avail.
Basically I'm trying to find a way of labelling my charts using the Larry Williams method. Short term highs = lower highs either side. Intermediate term highs = lower short term highs either side....
I can label short term highs using the following:
STH:= H > Ref(H,-1) AND H > Ref(H,+1);
STH;
but when it comes to labelling Intermediate Term Highs I failed to get the following to work...
ITH:= H > Ref(STH,-1) AND H > Ref(STH, +1);
ITH;
Is there an easy way of being able to do this or does anyone possibly have a similar formula they would be willing to share.
Any feedback welcomed.
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)
|
In your first section of code, you are asking MS a question, to which it will respond either TRUE or FALSE (1 or 0) if there is a short term high as you have defined it. If you want to the price when that question was TRUE, use ValueWhen().
In the second bit of code as you have written it, the answer will always be TRUE if the HIGH price is greater than 1, and if the HIGH price is less than or equal to 1, the answer will depend on the STH question; you are comparing a price to a Boolean value (1 or 0).
As for looking into the future to know the value of the HIGH on the next STH, this cannot be achieved in basic MS formula code. From is distant memory, I think someone (Roy??) did once achieve a lookahead to next event code in MSFL involving a complex mix of PREVs, ValueWhen() and LastValue() functions, but I cannot seem to find it, if it existed at all?? But, it is easily achieved in external functions written in more powerful
programming languages which have access to each individual bar of data,
in the past and into the future.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 11/23/2012(UTC) Posts: 5
|
Appreciate your comments wabbit as that has helped me pinpoint the error of my ways and guided me in the right direction.
As you can probably tell, my MS programming is still in the early/noob stages as after a bit of experimenting that 'ITH' bit of code looks a bit pseudo for what I really wanted MS to achieve ;) I'll go away and experiment with the ValueWhen() so thank you for the 'heads-up' on that one. Just as a starter I'm assuming I need something like:
For Swing Highs
STH:= ValueWhen(1,(H > Ref(H,-1) AND H > Ref(H,+1)),H);
This STH then implying the following ITH code.....
ITH:= (H > Ref(H,-1) AND H > Ref(H,+1)) AND H > ValueWhen(1, Ref(STH,-1),H) AND H > ValueWhen(1,Ref(STH,+1),H) // or something along these lines
breaking down the above ITH we first need to see if it is a swing high AND then see if we have Short term Highs either side..
To expand on this, it would be good to use two bars either side of the highs/lows to confirm that point even further as well as using Long Term Highs/Lows with Intermediate H/L's either side but all of those extras should follow quite easily once the basic structure in place.
It didn't have to be a crystal ball type indicator as I'd just wanted something like this in an 'Expert' so that the Highs and Lows could be labelled and painted as price unfolded. The reason being that if price came up to break an Intermediate Swing high rather than a Short term High then that would look more significant.
Thanks for your time wabbit.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 11/23/2012(UTC) Posts: 5
|
I see what you're saying about the 'looking into the future' part wabbit as it seems ValueWhen() won't take negative numbers and so consider points after a specific bar.
I tried the following (below) and although I do get the correct value, unfortunately it only appears after the entire Intermediate Swing High has formed... i.e. there doesn't appear to be a way of printing the value above the middle high rather than over the right high (lower) point.
Might need to look at this ext.fml stuff.
###########################
RightSTH:= ValueWhen(1,(H > Ref(H,-1) AND
H > Ref(H,-2) AND
H > Ref(H,+1) AND
H > Ref(H,+2)),H);
MiddleSTH:= ValueWhen(2,(H > Ref(H,-1) AND
H > Ref(H,-2) AND
H > Ref(H,+1) AND
H > Ref(H,+2)),H);
LeftSTH:= ValueWhen(3,(H > Ref(H,-1) AND
H > Ref(H,-2) AND
H > Ref(H,+1) AND
H > Ref(H,+2)),H);
boolITH:=If(RSTH<MSTH AND MSTH>LSTH,MSTH,0);
boolITH;
##########################
|
|
|
|
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)
|
Use variables, it makes the code easier to read, quicker to edit and execute: Use the proper code tags to post code in the forum (with less likelihood of the code getting borked by the forum) Code:
STH:= H > Ref(H,-1) AND
H > Ref(H,-2) AND
H > Ref(H,+1) AND
H > Ref(H,+2);
RightSTH:= ValueWhen(1,STH,H);
MiddleSTH:=ValueWhen(2,STH,H);
LeftSTH:= ValueWhen(3,STH,H);
ITH:= STH AND (MiddleSTH>LeftSTH AND MiddleSTH>RightSTH);
{plot}
ITH;
Notice you don't have to force the Boolean expression If(x,1,0) as MS does this for already. Bootle wrote:I tried the following (below) and although I do get the correct value,
unfortunately it only appears after the entire Intermediate Swing High
has formed... i.e. there doesn't appear to be a way of printing the
value above the middle high rather than over the right high (lower)
point. As I said, you need more advanced programming to be able look forward to the next event; this will allow you to place markers on historical bars, but then again, in a more advanced programming environment, you could program the entire thing! wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 11/23/2012(UTC) Posts: 5
|
There was always the chance I was going to be scoulded for my code repitition and lack of structure ;) but I just wanted to get out some working code I suppose. The message posting process seemed to mess up my boolITH statement for some reason but was almost identical to what you have wabbit.
The advanced programming bit might take a while (especially if my basics looks a bit dodgy!) but I'll perservere and see what I can come up with. There's bound to be a guide or two within the community that can point me in the right direction.
Again, thanks for your time wabbit, appreciated.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 11/23/2012(UTC) Posts: 5
|
Hmmmm.... looks like I need something called the MDK at extra cost so I think I'm going to pass on that one as I don't think this little feature will warrant the expense....a bit disappointing.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Market Structure Short/Inter/Long Term Highs/Lows - Larry Williams
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.