PureBytes Links
Trading Reference Links
|
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>
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=Tahoma
size=2>-----Original Message-----From: dingo
[mailto:dingo@xxxxxxxxxxxx]Sent: Monday, April 19, 2004 11:28
PMTo: _amibroker_yahooCc: HermanSubject:
VBScript to automate back test and export of tradelist.Importance:
High
Herman asked me to write a script that would do what the
subject line states.Here it is for those interested:<FONT
face="Courier New" 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
face="Courier New"
size=1>http://msdn.microsoft.com/library/default.asp?url=""><FONT
face="Courier New" size=1>'' <A
href=""><FONT
face="Courier New"
size=1>http://msdn.microsoft.com/library/default.asp?url=""><FONT
face="Courier New" size=1>'' <A
href=""><FONT
face="Courier New"
size=1>http://www.microsoft.com/technet/community/scriptcenter/default.mspx<FONT
face="Courier New" size=1>'' <A
href=""><FONT
face="Courier New"
size=1>http://groups.msn.com/windowsscript/_homepage.msnw?pgmarket=en-us<FONT
face="Courier New" size=1>''Created By:
dingo'**************************************Dim oABDim
oAADim result_Ok dim Data_Base_Folderdim
BackTest_Frmla_Pathdim Xport_CSV_FlePathdim Settngs_FilePathdim
iError'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
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"'
declare object for Amibroker and the file system objectset oAB =
CreateObject("Broker.Application")Set oAA =
oAB.Analysis'------------------------------------------' 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 WithIf 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
'------------------------------------------
' 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'------------------------------------------' destroy all
objects'------------------------------------------Set oAA =
Nothingset oAB = Nothing
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.
|