logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
dmyy2k  
#1 Posted : Wednesday, March 30, 2005 7:13:27 AM(UTC)
dmyy2k

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 3/30/2005(UTC)
Posts: 1

someone recommended ( in amibroker language) http://www.amibroker.com/library/detail.php?id=306 I try to convert it to metastock language but hit some command error. Could you help on this metastock language problem or workaround solution if any. Thank you and appreciate very much ./dmyy2k ========================================= MinPrice:=0.20; { 2} MinVolume:=200000; {100K} LH:=HHV(Close,25); BLH:=HHVBars(Close,25); BH:=LLV(Close,BLH); BBH:=LLVBars(Close,BLH); NBLH:=BLH-BBH; BC:=LLV(Close,BLH+25); BBC:=LLVBars(Close,BLH+25); LC:=Ref(HHV(Close,120),BBC*-1); BLC:=Ref(HHVBars(Close,120),BBC*-1); KC:=Ref(HHV(Close,30),BLC*-1); BKC:=Ref(HHVBars(Close,120),BLC*-1); Delta:= LC/KC; URPV=DRPV=0; i=barssince(BLH); j=barssince(BBC); countback:=j-i UPRV:= sum( if(Ref(C,i*-1) >Ref(i+1)*-1), Ref(V,i*-1) * ( Ref(C,(i*-1)) - Ref(C,(i+1)*-1) ), UPRV) , countback) ; DRPV:= sum( if(Ref(C,i*-1) <Ref(i+1)*-1), Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ), DRPV) , countback); Alpha := URPV/DRPV; { // Should be>1} DRPV:=0; i:=barssince(BBH); j:=barssince(BLH); countback2=j-i DRPV:= sum( if(Ref(C,i*-1) <Ref(i+1)*-1), Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ), DRPV) , countback); Beta := URPV/DRPV; Gamma := log(Alpha) + log(Beta) + delta; {NBHL ?} NBLH >2 AND C>BH AND BC<LC and LH<=LC AND ( BC<LH AND BH<LH) AND (BH (0.8*LH + 0.2*BC)) AND KC < LC AND C>MinPrice AND MOV(V,30)>MinVolume { AddColumn(LH,"Left Handle"); AddColumn(BH,"Bottom Handle"); AddColumn(BC,"Bottom Cup"); AddColumn(LC,"Left Cup"); AddColumn(ALPHA,"Alpha"); AddColumn(DELTA,"Delta"); AddColumn(BETA,"BETA"); AddColumn(GAMMA,"Gamma"); } { // Filter Criteria as follows: } { // 1. Right side of handle must be at least 2 bars. NBHL>2 } { // 2. Bottom of the cup must be lower than the left top of the cup. } { // 3. Left handle must be lower than or equal to the lect cup formation. } { // 4. Bottom of the cup must be less than the left handle. } { // 5. Bottom of the handle must be 80% of the left handle + 20% of the bottom cup. } { // 6. Start of cup/handle formation must be greater than precedding chart value. LC>LC } { // 7. Minimum price and volume you can set any way you like. } {Filter= NBLH>2 AND Close>BH AND BC<LC AND LH<=LC AND BC<LH AND BH<LH AND BH>.8*LH+.2*BC AND KC<LC AND Close>MinPrice AND MA(Volume,30)>MinVolume;}
Patrick  
#2 Posted : Wednesday, March 30, 2005 6:09:38 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
I tried to correct your attempt but ran into a complexity problem ( in other words I ended up using too many previous functions :D ). I will take a look at the amibroker code and try to convert it myself. But for now you could look at this cup & handle formula : vari:=10; bowl:=100; spk:=HHVBars(H,11)=5; lvl:=LastValue(ValueWhen(1,spk,HHV(H,11))); mrk:=HHV(H,11)<=((1+(vari/100))*lvl) AND HHV(H,11)>=((1-(vari/100))*lvl); cup:=Ref(HighestSince(1,spk AND mrk, If(spk,HHV(H,11),0)),-1); spk AND Ref(BarsSince(spk AND mrk),-1)>=bowl AND Ref(cup,-6) < lvl
Biff Malibu  
#3 Posted : Tuesday, April 26, 2005 3:51:27 AM(UTC)
Biff Malibu

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/21/2005(UTC)
Posts: 33

has anyone been able to find a good cup with handle explorer formula? i'm working on it myself, I've tried Patrick's previous formula but have not gotten any results in a few tests and am wondering if the criteria may be too stringent. I'm working on this also of course and will post anything I come up with.
skeetabomb  
#4 Posted : Thursday, April 28, 2005 6:28:22 PM(UTC)
skeetabomb

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/28/2005(UTC)
Posts: 41
Location: London

Interesting Formula! Well done at attempting to convert it. I see a couple of issues with what you've posted: [color=darkblue:74f51a2c41][size=18:74f51a2c41]1. There are too many variables declared.[/size:74f51a2c41][/color] E.G. "NBLH:=BLH-BBH;" Unfortunately, Metastock currently only supports 20 variables per formula (or more precisely, per indicator). That means you should only see ":=" 20 times or less. One important thing to be aware of is if you have called (referenced) a variable within the definition of another variable, the variable being called (or 'looked up') must appear above the one that is calling it. E.G. This is wrong: MyMA:=Mov(C,per,E); per:=Input("Periods",1,300,13); MyMA; This is right: per:=Input("Periods",1,300,13); MyMA:=Mov(C,per,E); MyMA; WHY? Because Metastock evaluates formulae from top down, just as you read it. In the first example, 'MyMA' is looking for the value of 'per', but Metastock does not know it yet because it is further down the list of things to calculate. Whereas in the second example, 'per' has already been calculated and stored, so when Metastock tries to evaluate 'MyMA', it already has all the input values necessary to calculate the result. [color=darkblue:74f51a2c41][size=18:74f51a2c41]2. A few plots (individual formulae) look syntactically incorrect.[/size:74f51a2c41][/color] E.G. i=barssince(BLH); j=barssince(BBC); Unlike Excel, Metastock cannot take letters as input for formulae UNLESS you are doing it in an external DLL or an ODBC linked spreadsheet. I can see that 'i' and 'j' are declared further down, which relates to issue 1 above. But regarding the following piece: countback2=j-i DRPV:= sum( if(Ref(C,i*-1) <Ref(i+1)*-1), Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ), DRPV) , countback); you should know that Metastock removes all line breaks when calculating a formula. What this means is this: countback2=j-i {line break} DRPV:= sum( {line break} if(Ref(C,i*-1) <Ref(i+1)*-1), {line break} Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ), {line break} DRPV) , countback); - BECOMES - "countback2=j-i DRPV:= sum( if(Ref(C,i*...etc...;" - i.e. Metastock sees it as all on one line, and you can clearly see that 'countback2=j-i DRPV:=' is incorrect in Metastock's view. One more example: "URPV=DRPV=0;" I am not sure exactly how Metastock would evaluate this one, but my guess is that if it did not return a syntax error of some sort, it would evaluate it like this: " If URPV equals DRPV and DRPV equals 0 {meaning both variables equal zero at the current bar}, then return TRUE, else return FALSE" - i.e. return the value '1' if true or 0 if false. When Metastock is faced with a logical or 'Boolean' formula that evaluates to a TRUE or FALSE condition, it returns '1' for TRUE and '0' for FALSE as stated above. But I would expect this one to fail due to incorrect syntax. I hope this helps you. When you have a successfully working Cup and Handle formula, please let me know! Kind Regards, Steve/skeetabomb.
theghost  
#5 Posted : Wednesday, May 4, 2005 12:16:42 PM(UTC)
theghost

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/4/2005(UTC)
Posts: 63
Location: Poole Dorset England

Hello all, This is my very first time onthe forum, so bear with me as I'm new to this sort of thing. I'd just like to comment on the cup and handle formula posted by Patrick (Hello Patrick 8) I use Metasock EOD v9, I copied the formula into the exploration and it works fine, didn't generate many results but thats a good thing as I want good classic styled cup and handle patterns. My question is this; Is there anyway you can alter the formula so it doesn't return the results as 1 or 0. I only would like to see the positive results, ie the 1 or 2 or 5 etc that were generated, rather than scroll through a few thousand that didnt generate a pattern. Hope this makes sense. Many thanks Theghost (I'll attach a picture of my default template, purely because this is my first post, and I want to see if it appears online. Changed the volume(Colour coded) & Histogram MACD plotted on the same signal line, also CCI (5 period) & RSI, rounded off with Colour coded candlestick expert. There's alot of info on the screen, but it's very clear for me to instantly take a judgement. Hope you like) :lol:
Patrick  
#6 Posted : Wednesday, May 4, 2005 1:11:33 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Welcome :D, The answer to your question is to place the formula in the filter column of your exploration. It will then only return securities that just formed a pattern and you won't have to look at the list. Patrick
theghost  
#7 Posted : Wednesday, May 4, 2005 4:30:32 PM(UTC)
theghost

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/4/2005(UTC)
Posts: 63
Location: Poole Dorset England

thanks for that Patrick. Simple question it seems :? I told you I was new to this. Cheers All the best.
Patrick  
#8 Posted : Wednesday, May 4, 2005 5:13:55 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
No problem that is what the forum is for :wink: Patrick
royttm  
#9 Posted : Monday, October 9, 2006 2:17:31 AM(UTC)
royttm

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 3/27/2006(UTC)
Posts: 41
Location: Singapore

You can find a "program" for Cup & Handle identification with Metastock at http://forum.equis.com/forums/thread/14502.aspx.

The "program" was offer free at http://www.daedalussoft.com/.

uasish  
#10 Posted : Tuesday, October 10, 2006 7:32:42 PM(UTC)
uasish

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/13/2005(UTC)
Posts: 170

Thanks: 7 times

Patrick,

Daedalussoft's code & your code does'nt identify the same stocks,hence now more intense study of the codes required .You have just spoiled my coming week end.Thanks for your neat code.

Asish

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.