Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 3/7/2014(UTC) Posts: 17
Thanks: 6 times
|
Hi,
I am trying to code for bar highlight for pivot on the basis of the close. following are the conditions
a) Low pivot (LP)
1) LP must close lower than previous 2 bars close ie close of bar -1 and close of bar -2. the two closes do not have to be in consecutive order.
I have coded- C>REF(C,-1) AND C>REF(C,-2)
2) bar +1 close must be equal or > LP close
I have coded- C>=REF(C,1)
3) LP is confirmed as LP bar(s) next to +1 bar closes equal to of > +1 bar close. it may be +2 bar or +3 bar or any bar as long as there is no close below LP bar close as its void the sequence.
Here I am not able to do the code- please help me.
for High Pivot (HP) reverse the conditions.
Regards,
K
|
|
|
|
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)
|
It's late, I'm tired, your code doesn't match your words, so here goes....
Code:
lpBarPlus1:=
Ref(C,-1) < Ref(C,-2) AND
Ref(C,-1) < Ref(C,-3) AND
Ref(C,-1) <=C;
lpBarPlus1Close:=ValueWhen(1,lpBarPlus1,C);
count:=Cum(C>lpBarPlus1Close);
counter:=count-ValueWhen(1,lpBarPlus1,count);
confirmation:=counter=1 AND Alert(counter<>1,2);
{plot}
confirmation;
Edited by user Thursday, April 20, 2017 8:47:45 AM(UTC)
| Reason: Fixed code tags
|
1 user thanked wabbit for this useful post.
|
|
|
Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 3/7/2014(UTC) Posts: 17
Thanks: 6 times
|
|
|
|
|
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)
|
Because you could have multiple instances where the LP condition is true whilst awaiting confirmation, the only real solution is leave the limited metastock formula language behind and use an external function written in a far more powerful language.
|
1 user thanked wabbit for this useful post.
|
|
|
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.