PureBytes Links
Trading Reference Links
|
Nigel,
That's a nice bit of code. Thank you very much.
I had my head on backasswards when I was trying to code the thing,
thinking I had to somehow read the file once, then process the
Watchlist. Your solution of simply opening/reading/closing the file
each time a member of the Watchlist is processed is straightforward,
and a technique I'll remember. And you even use the same coding
convention I do with respect to "{" :-).
Looks like I don't need to submit a formal enhancement request to
Tomasz after all.
Thanks again...
...Don Upton
--- In amibroker@xxxxxxxxxxxxxxx, Nigel Rowe <rho@xxxx> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Greetings Don,
> I was in the mood for a bit of a challenge, so....
>
> // Inspired by a request for a 'playback' feature from Don Upton
> //
> // Simplified example, long only and the file format is spec'd for
ease of
> // implimentation.
> //
> // Input file is comma seperated text.
> // Fields are:
> // 0. Symbol -- without quotes
> // 1. Entry date -- in datenum() format. ie xmas day
2003 is 1031225
> // 2. Entry price
> // 3. Exit date -- datenum() format, or blank for no
exit
> // 4. Exit Price
>
> Buy = False;
> Sell = False;
> BuyPrice = Close;
> SellPrice = Close;
>
> function DateToBar(dn)
> {
> return LastValue(ValueWhen(DateNum()==dn, BarIndex()));
> }
>
> f = fopen("playback.txt", "r");
> while( f && (! feof(f)) ) {
> Line = fgets(f);
> sym = StrExtract(Line, 0);
> if( sym == Name() ) {
> endt = StrExtract(Line,1);
> enpr = StrExtract(Line,2);
> exdt = StrExtract(Line,3);
> expr = StrExtract(Line,4);
> bar = DateToBar(StrToNum(endt));
> if( bar ) {
> Buy[bar] = True;
> BuyPrice[bar] = StrToNum(enpr);
> if( exdt != "" ) {
> bar = DateToBar(StrToNum(exdt));
> Sell[bar] = True;
> SellPrice[bar] = StrToNum(expr);
> }
> }
> }
> }
> if(f) fclose(f);
>
>
> I'll leave you to modify it to get exactly what you want.
>
> Nigel
>
>
> On Fri, 23 Jan 2004 22:51, Don Upton wrote:
> > I'd like to suggest an enhancement to Amibroker. Judging from
recent
> > messages, I believe others might be interested, too. If so,
maybe we can
> > get Tomasz in the discussion.
> >
> > I would like to see another function (like Scan and Backtest) in
AA. I'll
> > call it Playback for now. Playback would essentially be a
Backtest, but
> > instead of invoking an AFL script, it would prompt for the name
of a
> > comma-delimited file in which each record would represent a
trade. Each
> > record might have the following fields:
> >
> > 1) Ticker Symbol
> > 2) Type Trade (Long or Short)
> > 3) Entry Date
> > 4) Exit Date - null if trade still open
> > 5) Shares
> > 6) Position Entry Price (Buy or Short price, depending on type
trade) -
> > Optional
> > 7) Position Exit Price (Sell or Cover price, depending on type
trade; null
> > if trade still open) - Optional
> > 8) Commission on Entry - Optional
> > 9) Commission on Exit - Optional
> >
> > The optional fields above would default to the values in
AA/Settings if not
> > specified. The date range used for report statistics could be
calculated
> > based on the earliest trade open and last trade close (or current
date if
> > there are open trades). (Or should the date range be based on
the setting
> > in the AA window, as Backtest currently works ?)
> >
> > A Playback function would make it much easier to do "manual" -type
> > backtesting, as well as track actual trades...
> >
> > ...Don Upton
> >
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.2 (GNU/Linux)
>
> iD8DBQFAEdfYBbmcM2pfckkRAh1DAJ0SP/ONsODgnQ+998JuzXYJIITljQCg721n
> n1qdRu7Alu4RXOzsbeY2Vqo=
> =GaYd
> -----END PGP SIGNATURE-----
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
------------------------ 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
---------------------------------------------------------------------~->
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/
|