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

[amibroker] Using Param() to analyze system price-sensitivity



PureBytes Links

Trading Reference Links




<FONT face=Arial 
color=#0000ff size=2>This might help those of you who are working on this but 
don't want to have to pre-calc datenums.
<FONT face=Arial 
color=#0000ff size=2> 
<FONT face=Arial 
color=#0000ff size=2>Its an AFL routine to calc the date num given a string in 
MM/DD/YYYY format.  I can be easily modified for those of you using other 
formats.
<FONT face=Arial 
color=#0000ff size=2> 
function 
DateToDateNum(sMMDDYYYY) // date in format mm/dd/yyyy{
 
<FONT face=Arial color=#0000ff 
size=2>/*-------------------------------------------------------------  
This function will accept a string in the MM/DD/YYY format  and convert 
it into Amibroker's datenum.
 
  nDateNum = 
10000 * (year - 1900) + 100 * month + day
 
  It assumes 
that mm dd and yyyy are reasonable. It does check  for the presence of 
2 "/" characters and if not there  will return a 
0.-------------------------------------------------------------*/
 
    
nDateNum = 0;    sWrk = sMMDDYYYY;    
nPosn = StrFind(sWrk, "/");    if (nPosn > 0) 
{        nMth = StrToNum(StrLeft(sWrk, 
nPosn-1));        sWrk = StrRight(sWrk, 
StrLen(sWrk) - nPosn);        nPosn = 
StrFind(sWrk, "/");        if (nPosn > 
0) {            nDay 
= StrToNum(StrLeft(sWrk, 
nPosn-1));            
sWrk = StrRight(sWrk, StrLen(sWrk) - 
nPosn);            
nYr = 
StrToNum(sWrk);            
nDateNum = 10000 * (nYr - 1900) + (100 * nMth) + 
nDay;        }    
}    return nDateNum;}
 
Filter = 
1;
 
sDate = 
"12/31/2001";  //1011231nDate = DateToDateNum(sDate);
 
<FONT face=Arial color=#0000ff 
size=2>AddTextColumn(sDate, "String Date");AddTextColumn(NumToStr(nDate, 1, 
False), "AB Date");
 
sDate = 
"12/31/1995";  //951231nDate = DateToDateNum(sDate);
 
<FONT face=Arial color=#0000ff 
size=2>AddTextColumn(sDate, "String Date");AddTextColumn(NumToStr(nDate, 1, 
False), "AB Date");
 
<FONT face=Arial 
color=#0000ff size=2>d


From: Nigel Rowe [mailto:rho@xxxxxxxxxxxxxxx] 
Sent: Friday, January 23, 2004 9:26 PMTo: 
amibroker@xxxxxxxxxxxxxxxSubject: Re: [amibroker] Enhancement Request 
- "Playback" Function
-----BEGIN PGP SIGNED MESSAGE-----Hash: SHA1Greetings 
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 
PriceBuy = 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.      NigelOn 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+998JuzXYJIITljQCg721nn1qdRu7Alu4RXOzsbeY2Vqo==GaYd-----END 
PGP SIGNATURE-----Send BUG REPORTS to 
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
suggest@xxxxxxxxxxxxx-----------------------------------------Post 
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
group FAQ at: <A 
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


Yahoo! Groups Links
  To visit your group on the web, go to:<A 
  href="">http://groups.yahoo.com/group/amibroker/  

  To unsubscribe from this group, send an email to:<A 
  href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 
  


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


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.