PureBytes Links
Trading Reference Links
|
Sorry, here is what I added, but I am getting a syntax error:
Buy = (f AND NOT Ref(f, -1) AND trendMom > Ref(trendMom, -1);
Sell = (f AND NOT Ref(f, -1) AND trendMom < Ref(trendMom, -1);
--- In amibroker@xxxxxxxxxxxxxxx, "jism1992" <gdihia@xxxx> wrote:
>
> How can I add a buy and sell clauses to the following AFL file so I
> can scan for positive and negative divergences? Thanks for the help.
>
> // ********************************************
> // INDICATOR :DIVERGENCE
> // DATE :07-30-04
> // PROGRAMMER :M.Lauronen
> // COPYRIGHTS :Public Domain
> // ********************************************
>
> // --------------------------------------------
> // Recommended AmiBroker indicator settings:
> // Level 0
> // Percent
> // Middle
> // Scaling: Custom 0 - 100
> // --------------------------------------------
>
> // Adjust the following parameters to suit your needs
> period = 14;
> numChg = 0.001;
>
> // --------------------------------------------
> // Divergence for LONG
> // --------------------------------------------
>
> trendMom = RSI(14);
> trendZig = Zig(L, numChg);
>
> f = trendZig > Ref(trendZig, -1) AND Ref(trendZig, -1) < Ref(trendZig,
> -2);
>
> p1 = ValueWhen(f, Ref(trendZig, -1), 1);
> p2 = ValueWhen(f, Ref(trendZig, -1), 2);
> r1 = ValueWhen(f, Ref(trendMom,-1), 1);
> r2 = ValueWhen(f, Ref(trendMom,-1), 2);
>
> f = r1 > r2 AND p1 < p2;
>
> sig = f AND NOT Ref(f, -1) AND trendMom > Ref(trendMom, -1);
>
> _N(str = "(" + period + ")");
> Plot(trendMom, "RSI" + str, colorWhite);
> Plot(sig * 100, "Sig", colorGreen, styleHistogram + styleThick +
> styleNoLabel);
>
> // --------------------------------------------
> // Divergence for SHORT
> // --------------------------------------------
>
> trendZig2 = Zig(H, numChg);
>
> f = trendZig2 < Ref(trendZig2, -1) AND Ref(trendZig2, -1) >
Ref(trendZig2,
> -2);
>
> p1 = ValueWhen(f, Ref(trendZig2, -1), 1);
> p2 = ValueWhen(f, Ref(trendZig2, -1), 2);
> r1 = ValueWhen(f, Ref(trendMom,-1), 1);
> r2 = ValueWhen(f, Ref(trendMom,-1), 2);
>
> f = r1 < r2 AND p1 > p2;
>
> sig = f AND NOT Ref(f, -1) AND trendMom < Ref(trendMom, -1);
>
> _N(str = "(" + period + ")");
> Plot(sig * 100, "Sig", colorRed, styleHistogram + styleThick +
> styleNoLabel);
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|