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

[amibroker] Re: AFL question



PureBytes Links

Trading Reference Links

Graham,

Finally fixed it by adding a command to the "buy" and "sell", and 
then by using timenum rather than cross for "short" and "cover." Not 
sure exactly why it didn't work before, but it's working now. Here 
is the correct code FYI. Thanks again for your help!

Buy = (DayOfWeek()==1 AND Cross(TimeNum(),080000)) AND (ValueWhen
(DayOfWeek()==1 AND Cross(TimeNum(),080000), C) >= ValueWhen
(DayOfWeek()==1 AND Cross(TimeNum(),020000), C));

Sell = DayOfWeek()==5 AND TimeNum()==203000;

Short = DayOfWeek()==1 AND Cross(TimeNum(),080000) AND (ValueWhen
(DayOfWeek()==1 AND Cross(TimeNum(),080000), C)<=ValueWhen
(DayOfWeek()==1 AND Cross(TimeNum(),020000), C));

Cover = DayOfWeek()==5 AND TimeNum()==203000;

PositionSize=100000;

ApplyStop(0,2,0.01,True,False);

ApplyStop(1,2,0.01,True,False);






--- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> wrote:
> Not certain, maybe TJ could shed some light
> 
> But you could try breaking the conditions down into separate lines 
and do an
> exploration of these signals to see what is effecting your 
buys/sells
> 
> Eg
> Cond1 = DayOfWeek()==1 ;
> Cond2 = Cross(TimeNum(),080000) ;
> Price1 = Valuewhen (Cond1 and Cond2, C );
> Etc
> 
> The filter=buy or sell ;
> Addcolumn(buy,"B",1);
> Addcolumn(Cond1,"1",1);
> Addcolumn(Cond2,"2",1);
> etc
> 
> 
> 
> Cheers,
> Graham
> http://groups.msn.com/ASXShareTrading
> http://groups.msn.com/FMSAustralia 
> 
> -----Original Message-----
> From: the_real_redleg [mailto:james.hall3@x...] 
> Sent: Friday, 31 October 2003 5:58 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: AFL question
> 
> 
> Graham,
> 
> Thanks! I did mean 2 AM for the second time. I'm not getting any 
> errors now, but backtesting gives me a bunch of orders that are 
not 
> part of the system I'm trying to test. There should only be 1 
order 
> each week, opened at 8 AM on Monday (either buy or sell based on 
> relative position to the 2 AM price). Those orders are correctly 
> executed in the back test, but there are many other orders opened 
on 
> multiple days of the week and at multiple times. Any idea what is 
> going on with that? Here is where I am on the AFL code right now:
> 
> James
> 
> 
> Buy = ValueWhen(DayOfWeek()==1 AND Cross(TimeNum(),080000), C) >= 
> ValueWhen (DayOfWeek()==1 AND Cross(TimeNum(),020000), C);
> 
> Sell = DayOfWeek()==5 AND Cross(TimeNum(),203000);
> 
> Short = ValueWhen(DayOfWeek()==1 AND Cross(TimeNum(),080000), C) 
<=ValueWhen
> (DayOfWeek()==1 AND Cross(TimeNum(),020000), C);
> 
> Cover = DayOfWeek()==5 AND Cross(TimeNum(),203000);
> 
> PositionSize=100000;
> 
> ApplyStop(0,2,0.01,True,False);
> 
> ApplyStop(1,2,0.01,True,False);
> 
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> wrote:
> > You just needed the array to be checked C, also if you do not 
have
> a price
> > at exactly the time nothing can be found, so I use the Cross for
> that. Plus
> > your second time was for 2am, thought you might mean 2pm
> > 
> > Hope this works better
> > 
> > Buy = ValueWhen(DayOfWeek()==1 AND Cross(TimeNum(),080000), C) >=
> ValueWhen
> > (DayOfWeek()==1 AND Cross(TimeNum(),140000), C);
> > 
> > Sell = DayOfWeek()==5 AND Cross(TimeNum(),203000);
> > 
> > Short = ValueWhen(DayOfWeek()==1 AND Cross(TimeNum(),080000), C)
> <=ValueWhen
> > (DayOfWeek()==1 AND Cross(TimeNum(),140000), C);
> > 
> > Cover = (DayOfWeek()==5 AND Cross(TimeNum(),203000);
> > 
> > PositionSize=100000;
> > 
> > Short=Sell;
> > 
> > ApplyStop(0,2,0.01,False,True);
> > 
> > ApplyStop(1,2,0.01,False,True);
> > 
> > Cheers,
> > Graham
> > http://groups.msn.com/ASXShareTrading
> > http://groups.msn.com/FMSAustralia
> > 
> > -----Original Message-----
> > From: the_real_redleg [mailto:james.hall3@x...]
> > Sent: Thursday, 30 October 2003 10:00 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] AFL question
> > 
> > 
> > I'm trying to backtest a system where you make one trade every
> week. 
> > The rules are that you check the price at 0200 on Monday against
> the 
> > price at 0800 on Monday. If the later price is higher, buy. If 
the
> > later price is lower, sell. Take profit and stop loss levels of 
> 100 
> > pips. If the trade has not closed by the end of the week, then
> close 
> > it.
> > 
> > Here is my attempt at AFL code (not working). Greatly appreciate
> any 
> > help in coding this for backtesting. You guys are great!
> > 
> > James
> > 
> > Buy = (ValueWhen(DayOfWeek()==1 AND TimeNum()==080000)
>=ValueWhen 
> > (DayOfWeek()==1 AND TimeNum()==020000));
> > 
> > Sell = (DayOfWeek()==5 AND TimeNum()==203000);
> > 
> > Short = ValueWhen(DayOfWeek()==1 AND TimeNum()==080000)
<=ValueWhen 
> > (DayOfWeek()==1 AND TimeNum()==020000);
> > 
> > Cover = (DayOfWeek()==5 AND TimeNum()==203000);
> > 
> > PositionSize=100000;
> > 
> > Short=Sell;
> > 
> > ApplyStop(0,2,0.01,False,True);
> > 
> > ApplyStop(1,2,0.01,False,True);
> > 
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > 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/
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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/



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/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/