PureBytes Links
Trading Reference Links
|
Hi all,
I have a script I'd like to use to run an exploration automatically.
I'm pasting the script and the exploration below. What's strange is
that when I run the exploration manually, it is fine. When I run it
automatically, the results file is exported instantly with nothing in
it. Please let me know if you've experienced similar problems or if
you see something missing. Thanks,
Gordon
*****
VB Code:
*****
Call main
WScript.Echo("Done")
Sub main
On Error Resume next
Dim process
Dim winmgm
Dim aa
Dim ab
Dim bAbIsOpen
Dim bEsIsOpen
Dim wsh
bAbIsOpen = false
bEsIsOpen = False
Err.Clear
Set winmgm = GetObject("winmgmts://localhost")
Set wsh = WScript.CreateObject("WScript.Shell")
If Err <> 0 Then
WScript.Echo Err.Description
Exit Sub
End if
' -- Close all existing instances
For Each Process in winmgm.ExecQuery ("select * from
Win32_Process where name='Broker.exe'")
bAbIsOpen = true
Next
If Not bAbIsOpen Then
WScript.Echo("AB not open")
Exit sub
End If
For Each Process in winmgm.ExecQuery ("select * from
Win32_Process")
If UCase(process.name) = "WINROS.EXE" then
bEsIsOpen = True
End if
Next
If Not bEsIsOpen Then
WScript.Echo("Es not open")
Err.Clear
Wsh.Run "C:\Program Files\eSignal\winros.exe"
If Err <> 0 Then
WScript.Echo "Err starting winros: " &
Err.Description
End if
WScript.Sleep(10000)
For Each Process in winmgm.ExecQuery ("select * from
Win32_Process")
If UCase(process.name) = "WINROS.EXE" then
bEsIsOpen = True
End If
If Not bEsIsOpen Then Exit Sub
Next
Exit sub
End If
Err.Clear
Set ab = CreateObject("broker.application")
If Err <> 0 Then
WScript.Echo Err.Description
Exit Sub
End If
Err.Clear
If ucase(ab.DatabasePath) <> UCase("c:\Amibroker RT 5M\") Then
WScript.Echo "Wrong database"
Exit Sub
End if
Set aa = ab.analysis
If Err <> 0 Then _
WScript.Echo Err.Description
' load formula from external file */
AA.LoadFormula("C:\getRTdata.afl")
'/* optional: load settings */
'/* setup filters */
'/* backtest over symbols present in market 0 only (zero-
based number) */
'AA.ClearFilters();
'AA.Filter( 0, "market" ) = 0;
' - long ApplyTo - defines apply to mode: 0 - all stocks, 1 -
current stock, 2 - use Filter
' - long RangeMode - defines range mode: 0 - all quotes, 1 -
n last quotes, 2 - n last days, 3 - from-to Date
' - long RangeN - defines N (number of bars/days to backtest)
aa.ClearFilters()
aa.ApplyTo = 0
aa.RangeMode = 1
' -- The scan may start and it may not. Hmmm.
aa.explore()
' -- This file is created instantly
aa.export("C:\results.csv")
'/* run backtest and display report */
aa.close()
On Error goto 0
End Sub
*****
Exploration -- runs fine manually
*****
Filter=1;
AddColumn(GetRTData("Bid"), "LastBid");
AddColumn(GetRTData("Ask"), "LastAsk");
------------------------ 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
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/
|