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

[amibroker] Need help translating Xavier Raj's strategy from EasyLang to AFL



PureBytes Links

Trading Reference Links



The following strategy - in EasyLanguage - is from Xavier Raj's 
article in the Apr 2005 edition of Active Trader.  The strategy is 
simple and looks promising.  Being an ABSOLUTE newbie to AFL, I'm 
having trouble translating the EasyLanguage to AFL.  I would 
appreciate if somebody would help.  I'll list the EasyLanguage code 
first followed by my pathetic attempt

Xavier Raj's system
VAR:X(0),Y(0),R(0); R=RANGE;

IF C>H-((R/10)) AND O<L+((R/10)) THEN X=1 ELSE X=0;
IF C<L+((R/10)) AND O>H-((R/10)) THEN Y=1 ELSE Y=0;
IF X=1 THEN Buy Next Bar AT H+.05 STOP;
IF Y=1 THEN Sell Short Next Bar AT L-.05 STOP;
Sell this Bar AT C;
Buy to Cover This Bar AT C;
Sell Next Bar AT MEDIANPRICE-.05 STOP;
Buy to Cover Next Bar AT MEDIANPRICE+.05 STOP;
Sell AT ("P1") Next Bar H+10 LIMIT;
Buy to Cover AT ("P2") Next Bar L-10 LIMIT;

Having just finished understanding pg 246 of the Users Guide, my 
limited AFL language skills couldn't grasp the finesse of 
writing 'buy next bar' and 'medianprice'.  Anyway, here's my simple 
attempt (too many 'results' and 'conditions').  Please HELP!!

R=(H-L)/10;

Condition1 = Close>High-((R/10)) AND Open<Low+((R/10));
Condition2 = Close<Low+((R/10)) AND Open>High-((R/10));

result1 = IIf(Condition1,1,0);
result2 = IIf(Condition2,1,0);

Buy = H+0.05;
Sell = Close;
Short = L-0.05;  
Cover = Close;

Condition3 = result1 = 1;
Condition4 = result2 = 1;

IIf (Condition3,Buy,0);
IIf (Condition4,Short,0);










------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.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/