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

[amibroker] Off Topic: PDF to Word converter



PureBytes Links

Trading Reference Links




Hey d,
 
thanks for all the work!
 
-john
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  dingo 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Cc: <A title=psytek@xxxxxxxx 
  href="">Herman 
  Sent: Tuesday, April 20, 2004 6:30 
  AM
  Subject: RE: [amibroker] RE: VBScript to 
  automate back test and export of tradelist.
  
  <FONT 
  color=#0000ff><SPAN 
  class=375421312-20042004>1.   You need to 
  look at the table below. That governs what you see in the tradelist and the 
  results.rlst file.  <FONT 
  face=Arial><FONT 
  size=2>I've added the following to the backtest script:
  <FONT 
  size=2> 
  <FONT face="Courier New" color=#0000ff 
  size=2>'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' Below are 
  3 "constants" that inidicate what type of' back test is to be run. Below 
  that is the line:' "BackTestType = cstPortFolioBackTest".'' TO RUN 
  DIFFERENT TYPE BACKTESTS:' change the "BackTestType = 
  cstPortFolioBackTest"' line to relect the type of backtest you want to 
  run:' BackTestType = cstPortFolioBackTest' BackTestType = 
  cstIndividualBackTest' BackTestType = cstOldBackTest'' The 
  following table shows what is produced by the' different backtests along 
  with the "Result List Shows"' setting the Report tab of the Settings 
  form:'================================================================='                 
  Result'                 
  List            
  Trade     ' 
  BackTest        
  Shows           
  List            
  Results.Rlst' 
  Type            
  Setting         
  Contains        Contains' 
  --------------------------------------------------------------' 
  Portfolio       "Trade List"    
  Trades By Date  1 Total line' 
  Portfolio       "Detailed Log"  Day By 
  Day      1 Total line' 
  Portfolio       
  "Summary"       1 Total Line    1 
  Total line' Individual      "Trade 
  List"    Trades By Tckr  Totals Per Tckr ' 
  Individual      "Detailed Log"  Day By 
  Day      Totals Per Tckr ' 
  Individual      
  "Summary"       Totals Per Tckr Totals Per 
  Tckr'================================================================='' 
  NOTE: The above table shows what's in the trade list and 
  '       the Results.Rlst file so that you'll 
  know where to '       look for your 
  data.''       Suggestion: Create as many 
  settings files with the'       desired 
  reporting options as you may need and use 
  '       them rather than try to alter the 
  settings manually.'      
  '       If you need both the individual 
  trades and the '       totals by ticker then 
  you'll need to extract the '       totals 
  from the Results.Rlst file.''       
  Since the Results.Rlst file can have many 
  entries'       in it from all of your other 
  backtesting I'd '       strongly suggest 
  that you use the '       "SetFormulaName("My 
  unique backtest Id Here");"'       command 
  in your AFL backtest formula. Each line 
  '       in your "Results.rlst" file will 
  have that name'       as the value of the 
  first column making it easy'       to locate 
  those lines from your 
  backtest.'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Const 
  cstPortFolioBackTest = 0Const cstIndividualBackTest = 1Const 
  cstOldBackTest = 2
   
  <FONT face="Courier New" color=#0000ff 
  size=2>BackTestType = cstPortFolioBackTest
  <FONT face="Courier New" color=#0000ff 
  size=2> 
  <FONT 
  face="Courier New" color=#0000ff size=2>2. AFAIK 
  command line arguments are not available in vbScript - please correct me if 
  I'm wrong.  What IS avail is the 
  <FONT 
  face="Courier New" color=#0000ff size=2> 
  <FONT 
  size=4>InputBox Function
  
  
  <DIV class=saveHistory id=allHistory onsave="saveAll()" 
  >
  Displays a prompt in a dialog box, waits for the user to input 
  text or click a button, and returns the contents of the text 
  box.
  <FONT 
  face="Courier New" color=#0000ff size=2>and this could be used to input your 
  various options.
  <FONT 
  face="Courier New" color=#0000ff size=2> 
  <FONT 
  face="Courier New" color=#0000ff size=2>3. Future date 
  will only process up to the last actual bar in your database EXCEPT when you 
  have the option set for "Add artificial...." option set on in the portfolio 
  tab in the settings formula. 
  <FONT 
  face="Courier New" color=#0000ff size=2> 
  <FONT 
  face="Courier New" color=#0000ff size=2> 
  <FONT 
  face="Courier New" color=#0000ff size=2>Here is the entire modified 
  script
  <SPAN 
  class=140223711-20042004>
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004>----------------8<------------------------------
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004> 
  <SPAN 
  class=140223711-20042004><FONT 
  size=1>'**************************************'Purpose: Run A Procedure in 
  Amibroker'         that will load 
  a database, '         load a 
  settings file, Load a'         
  formula, Set the Apply To 
  and'         Range settings, run a 
  backtest '         and export the 
  tradelist to'         a csv 
  file''Operation: Name this file whatever 
  you'         wish but give it an 
  extension'         of .vbs. Place 
  it in your'         Amibroker 
  folder and run it'         by 
  double clicking on the 
  file'         name.'  
  '         Make sure that you 
  change those'         lines under 
  the !!!!!!! lines'         to 
  match your system.''         
  Make sure that you have the 
  '         correct format file in 
  the '         format 
  folder.''The Code: Is written in VB Script and 
  '         runs within "Windows 
  Scripting'         Host (WSH)". I 
  have included'         many 
  commented out MsgBox 
  lines'         that you can 
  uncomment if you're'         
  having problems. That way 
  you'         have a way to monitor 
  the progress'         of the 
  script as it executes.''vbScript Help: The following links 
  will'         provide information 
  on VBScript:'         (Be careful 
  of folded lines)'' <A 
  href=""><FONT 
  size=1>http://msdn.microsoft.com/library/default.asp?url="";><FONT 
  size=1>'' <A 
  href=""><FONT 
  size=1>http://msdn.microsoft.com/library/default.asp?url="";><FONT 
  size=1>'' <A 
  href=""><FONT 
  size=1>http://www.microsoft.com/technet/community/scriptcenter/default.mspx<FONT 
  size=1>'' <A 
  href=""><FONT 
  size=1>http://groups.msn.com/windowsscript/_homepage.msnw?pgmarket=en-us<FONT 
  size=1>''Created By: 
  dingo'**************************************
   
  <SPAN 
  class=140223711-20042004>Dim oABDim 
  oAADim result_Ok  
   
  <SPAN 
  class=140223711-20042004>Dim 
  Data_Base_FolderDim BackTest_Frmla_PathDim Xport_CSV_FlePathDim 
  Settngs_FilePathDim iErrorDim BackTestType
   
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004>'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' 
  Below are 3 "constants" that inidicate what type of' back test is to be 
  run. Below that is the line:' "BackTestType = 
  cstPortFolioBackTest".'' TO RUN DIFFERENT TYPE BACKTESTS:' change 
  the "BackTestType = cstPortFolioBackTest"' line to relect the type of 
  backtest you want to run:' BackTestType = cstPortFolioBackTest' 
  BackTestType = cstIndividualBackTest' BackTestType = 
  cstOldBackTest'' The following table shows what is produced by 
  the' different backtests along with the "Result List Shows"' setting 
  the Report tab of the Settings 
  form:'================================================================='                 
  Result'                 
  List            
  Trade     ' 
  BackTest        
  Shows           
  List            
  Results.Rlst' 
  Type            
  Setting         
  Contains        Contains' 
  --------------------------------------------------------------' 
  Portfolio       "Trade List"    
  Trades By Date  1 Total line' 
  Portfolio       "Detailed Log"  Day By 
  Day      1 Total line' 
  Portfolio       
  "Summary"       1 Total Line    1 
  Total line' Individual      "Trade 
  List"    Trades By Tckr  Totals Per Tckr ' 
  Individual      "Detailed Log"  Day By 
  Day      Totals Per Tckr ' 
  Individual      
  "Summary"       Totals Per Tckr Totals Per 
  Tckr'================================================================='' 
  NOTE: The above table shows what's in the trade list and 
  '       the Results.Rlst file so that you'll 
  know where to '       look for your 
  data.''       Suggestion: Create as many 
  settings files with the'       desired 
  reporting options as you may need and use 
  '       them rather than try to alter the 
  settings manually.'      
  '       If you need both the individual 
  trades and the '       totals by ticker then 
  you'll need to extract the '       totals 
  from the Results.Rlst file.''       
  Since the Results.Rlst file can have many 
  entries'       in it from all of your other 
  backtesting I'd '       strongly suggest 
  that you use the '       "SetFormulaName("My 
  unique backtest Id Here");"'       command 
  in your AFL backtest formula. Each line 
  '       in your "Results.rlst" file will 
  have that name'       as the value of the 
  first column making it easy'       to locate 
  those lines from your 
  backtest.'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Const 
  cstPortFolioBackTest = 0Const cstIndividualBackTest = 1Const 
  cstOldBackTest = 2
   
  <SPAN 
  class=140223711-20042004>BackTestType = 
  cstPortFolioBackTest
   
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004>'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' 
  change the following paths to suit your 
  configuration'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Data_Base_Folder 
  = "C:\Program Files\Amibroker\Your Database Dir"BackTest_Frmla_Path = 
  "C:\Program Files\Amibroker\Afl\Your Formula Here.Afl"Xport_CSV_FlePath = 
  "C:\Program Files\Amibroker\Output\TradeList.CSV"Settngs_FilePath = 
  "C:\Program Files\Amibroker\Settings Files\Your Settings 
  File.ABS"
   
  <SPAN 
  class=140223711-20042004>' declare object for 
  Amibroker and the file system objectset oAB = 
  CreateObject("Broker.Application")Set oAA = 
  oAB.Analysis
   
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004>'------------------------------------------' Load 
  the Settings File, Set from and to ' dates, and the 
  watchlist'------------------------------------------with 
  oAA    
  '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    
  ' change the following settings to suit your 
  configuration    
  '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    
  If Not .LoadSettings(cstr(Settngs_FilePath)) 
  Then        MsgBox "Can't Load Settings 
  File"        iError = 
  true    Else    
          .RangeMode = 
  3        .RangeFromDate = 
  "01/01/2001"        .RangeToDate = 
  "12/31/2002"        
  .ClearFilters        .ApplyTo = 
  2        .Filter(0, "watchlist") = 
  29    End IfEnd With
   
  <SPAN 
  class=140223711-20042004>If Not iError then 
      
  '------------------------------------------    ' The 
  following is the "main" code for the    ' exporting and 
  importing of the data    
  '------------------------------------------    ' Load EOD 
  Data Base    
  '------------------------------------------    
  'wscript.echo "Loading EOD Database: " + 
  Data_Base_Folder    If 
  oAB.LoadDatabase(cstr(Data_Base_Folder)) 
  Then        
  '------------------------------------------        
  ' Load the AFL for Building the CSV 
  File        
  '------------------------------------------        
  'wscript.echo "Loading AFL: " + 
  BackTest_Frmla_Path        If 
  oAA.LoadFormula(cstr(BackTest_Frmla_Path)) 
  Then            
  '------------------------------------------            
  ' Run The 
  Scan            
  '------------------------------------------            
  'wscript.echo "Running 
  Backtest"            
  oAA.Backtest(BackTestType) 
              
  '------------------------------------------            
  ' now export the 
  tradelist            
  '------------------------------------------            
  result_Ok = 
  oAA.Export(Xport_CSV_FlePath)            
  If Not result_Ok 
  Then                
  'wscript.echo "result_Ok: " + 
  cstr(result_Ok)                
  MsgBox "Error Exporting 
  Tradelist"            
  else                
  MsgBox 
  "Finished"            
  End If        
  Else            
  MsgBox "Can't Load Backtest 
  Formula"        End 
  If        
  Else        MsgBox "Cant Load 
  Database"    End IfEnd If
   
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004>'------------------------------------------' 
  destroy all objects'------------------------------------------Set oAA 
  = Nothingset oAB = Nothing
  <SPAN 
  class=140223711-20042004>
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004>----------------8<------------------------------
  <SPAN 
  class=140223711-20042004><SPAN 
  class=375421312-20042004> <FONT 
  face="Courier New" color=#0000ff size=2><SPAN 
  class=375421312-20042004>
  
    
    
    From: Herman van den Bergen 
    [mailto:psytek@xxxxxxxx] Sent: Tuesday, April 20, 2004 7:48 
    AMTo: AmiBroker YahooGroupsSubject: [amibroker] RE: 
    VBScript to automate back test and export of tradelist.
    
    <SPAN 
    class=734061511-20042004>Very nice d, thanks for creating this code, it 
    works like a charm!
    <SPAN 
    class=734061511-20042004> 
    A 
    few questions, 
    1) 
    Is the portfolio BT mode available in Automation and if so, can your code be 
    adapted to do Port BTs?
    <SPAN 
    class=734061511-20042004>2) I would I add a few command line arguments to 
    your code so that, for example, I can change the systems code, dates, 
    etc. without editing, 
    possible?
    3) 
    What happens if I specify a future date for the "To:" data... would AB 
    default to the last available data bar? 
    <SPAN 
    class=734061511-20042004> 
    <SPAN 
    class=734061511-20042004>For those who haven't followed this topic, the 
    purpose of this export is to be able to use BT stats (CAR, RAR, 
    K-Ratio, etc.) in 2-nd pass BTs. The csv file can be read using file 
    operations code documented in the Help. Once the first export has been 
    completed you can then extract any stat you like with StrExtract() for 
    use in subsequent BTs.
    <SPAN 
    class=734061511-20042004> 
    <SPAN 
    class=734061511-20042004>herman.
    <FONT face=Arial 
      color=#0000ff 
  size=2>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 
  


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 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.