[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] need help plotting indicator written in MetaStock



PureBytes Links

Trading Reference Links

Calling all AFL Gurus,

I'm trying to put Spyros Raftopolous's "ZigZag Trend" indicator into
AFL (from MetaStock language) and need some coding help, since I'm an
AFL "dummy."

FYI, this is SR's solution(?) to the problem  of identifying trend
using MetaStock's zigzag indicator--something that's never been
accomplished before. I found it doing a Google search on "Zigzag
Trend" (or: "zig zag trend" -- I'm not sure which).

Anyway, the formula in MetaStock is:

perc:=Input("percent",.1,100,.5);

tr:=ValueWhen(1,Zig(C,perc,%)>Ref(Zig(C,perc,%),-1) AND
Ref(Zig(C,perc,%),-1)<Ref(Zig(C,perc,%),-2),Ref(Zig(C,perc,%),-1));
pk:=ValueWhen(1,Zig(C,perc,%)<Ref(Zig(C,perc,%),-1) AND
Ref(Zig(C,perc,%),-1)>Ref(Zig(C,perc,%),-2),Ref(Zig(C,perc,%),-1));
res:=If(C>=tr+tr*perc/100 AND Zig(C,perc,%)>Ref(Zig(C,perc,%),-1),1,
If(C<=pk-pk*perc/100 AND Zig(C,perc,%)<Ref(Zig(C,perc,%),-1),-1,0));
res:=If(res<>0,res,ValueWhen(1,res<>0,res));
res


I need help on three things:

1.  On the line reading: "perc:=(Input("percent",1,100,10),
I want to define "perc" in AFL, rather than just say "perc = 5" or
anohter number.   What is the correct AFL equivalent to MetaStock's
"Input" function?

2.  On the line reading: 
"Ref(Zig(C,perc,%),-1)<Ref(Zig(C,perc,%),-2),Ref(Zig(C,perc,%),-1));"
I don't understand the MetaStock meaning of the last clause,
  
     " ,Ref(Zig(C,perc,%),-1))".
That is, I don't understand the syntax where this clause is added to
what precedes it, after a comma.  Obviously, then, I don't kinow how
to put it into AFL.

3.  The MetaStock sysmbol "<>" means "not equal to."  What is the
equvalent in AFL?  AB help claims it can't look up this symbol.

4.  Finally, here's what I have so far, in AFL:

//calculate ZigZag Trend
perc=.5;
tr=ValueWhen(Zig(C,perc)>Ref(Zig(C,perc),-1),1) AND
Ref(Zig(C,perc),-1)<Ref(Zig(C,perc),-2), Ref(Zig(C,perc),-1));
pk=ValueWhen(1,Zig(C,perc)<Ref(Zig(C,perc),-1) AND
Ref(Zig(C,perc),-1)>Ref(Zig(C,perc),-2),Ref(Zig(C,perc),-1));
res=If(C>=tr+tr*perc/100 AND Zig(C,perc)>Ref(Zig(C,perc),-1),1,
If(C<=pk-pk*perc/100 AND Zig(C,perc)<Ref(Zig(C,perc),-1),-1,0));
res:=If(res<>0,res,ValueWhen(1,res<>0,res));
Plot(res,"ZigZag_Trend",colorBlue);

Any help will be greatly appreciated.  

Thanks in advance,

FredB


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/YoVfrB/XP.FAA/uetFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/