Discussions
»
Product and Service Development
»
Formula Assistance
»
Obtaining the highest high for the past 250 periods
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 5/7/2007(UTC) Posts: 9
|
Obtaining the highest high for the past 250 periods
ok there's no proble with this. its a simple indicator If(HIGH>Ref(HHV(HIGH,250),-1),1,0);
but the problem is that it causes error pop up when the chart is only has past half year data. so i would want to make the error not show up and still carry out it's task this is what i tried:
If( IsDefined( Ref(C, -250) ),If(HIGH>Ref(HHV(HIGH,250),-1),1,0) , 0);
unforturnately it doesnt work yet =( . can anyone please help?
-wahkao
|
|
|
|
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)
|
wahkao, This is another one of those occassions when the Forum.dll comes in handy! Try this: Code:
prds:=Min(250, Cum(1));
hi:=ExtFml("forum.HHV",H, prds);
{plot/return}
hi;
Hope this helps. wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
The above code will return the highest High of the last 250 bars (not days), which will result in breakout signal errors on securities that have halted trading for any period of time in the YTD.
Furthermore, a yearly breakout based on bars lookback does not work on any periodicity other than daily.
Lastly, there are a number of good reasons for avoiding the use of MetaStock DLLs where MSFL will do the job.
Wahkao, try this code for accurate year-breakout signals:
---8<-----------------------------------------
{ Replacement solution for H>Ref(HHV(H,252),-1) on all securities. http://www.metastocktools.com }
{ Signal a year back from last trading day } start:=Year()>LastValue(Year())-1 OR (Year()=LastValue(Year())-1 AND (Month()>LastValue(Month()) OR Month()=LastValue(Month()) AND DayOfMonth()>=LastValue(DayOfMonth()))); yearAgo:=start AND Alert(start=0,2);
{ Add signal if insufficient data } yearAgo:=If(LastValue(Cum(yearAgo))>0,yearAgo, Cum(1)=1);
{ Price breakout } Hi:=HighestSince(1,yearAgo,H); breakout:=H>Ref(Hi,-1);
{ Signal output } {yearAgo;} breakout
---8<-----------------------------------------
jose '-)
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Obtaining the highest high for the past 250 periods
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.