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)
|
alberto,
You are setting yourself a dangerous precedence if you use Ref(x,+y). Please forget that the forward looking function even exists! We can only look into the past, so you have correctly identified that you need to rephrase your search criteria:
MAXr2:= CLOSE > Mov(C,55,E)
AND HIGH > Ref(HIGH,-1)
AND HIGH > Ref(HIGH,-2)
AND HIGH > Ref(HIGH, 1)
AND HIGH > Ref(HIGH, 2)
equates to:
MAXr2:= Ref(CLOSE,-2) > Ref(Mov(C,55,E),-2)
AND Ref(HIGH,-2) > Ref(HIGH,-3)
AND Ref(HIGH,-2) > Ref(HIGH,-4)
AND Ref(HIGH,-2) > Ref(HIGH,-1)
AND Ref(HIGH,-2) > HIGH;
this means the peak of highs was formed two bars ago and on that bar the close was above the MA, but only uses hindsight.
You can modify the theory to find peaks over longer periods:
x:=HIGH > Ref(HIGH,-1);
y:=Input("Periods",1,10,2);
Ref(Sum(x,LastValue(y)),-LastValue(y))=y AND Sum(x,y)=0;
This says the peak is formed when there are 'y' consecutive higher high bars follwed by 'y' consecutive lower/equal high bars. You can progammatically add some latitude too, if you want to be strict that every bar in each part of the series must be higher etc.
Hope this helps.
wabbit :D
|