|
RealTest supports an optional Windows command line mode. To use this mode, simply invoke RealTest from any Windows command shell window or batch script, with arguments specifying your desired action.
Supported command line tasks:
❖realtest -import script.rts
•runs script.rts in Import mode
•saves data to RTD file if import definition includes a SaveAs path
❖realtest -scan script.rts
•runs script.rts in Scan mode
•saves scan output to CSV if ScanSettings include a SaveScanAs path
❖realtest -test script.rts
•runs script.rts in Test mode
•saves results data to RTR if the Settings include a ResultsFile path
•saves results window contents to CSV if test settings include a SaveTestListAs path
•saves stats to CSV if test settings include a SaveStatsAs path
•saves final position list to CSV if test settings include a SavePositionsAs path
•saves trade list to CSV if test settings include a SaveTradesAs path
❖realtest -optimize script.rts
•runs script.rts in Optimize mode
•use special {X} comments in Parameters to specify which ones should be optimized
•use OptimizeSettings in your script to specify other optimization options
❖realtest -orders script.rts
•runs script.rts in Orders mode
•generates and saves Order List file(s) as specified in the script
•also saves results and other output as is done for Test mode
❖realtest -parse script.rts
•checks the script.rts for syntax errors and does nothing else
Multiple run modes can precede a script name, e.g. realtest -import -test script.rts will run that script first for import and then for backtest.
Multiple scripts can follow a run mode, e.g. realtest -orders orders1.rts orders2.rts orders3.rts will generate orders from three different scripts.
If all scripts ran successfully, the program return code will be 0.
If there were errors, the return code will be one of the following:
|
Code
|
Meaning
|
|
1
|
unknown command line task
|
|
2
|
license error
|
|
3
|
file open/read/write error
|
|
4
|
memory error
|
|
5
|
script error (syntax etc.)
|
|
6
|
import error
|
|
7
|
can't load data file
|
|
8
|
other / unspecified
|
|
9
|
a requested output file (SaveTradesAs, OrdersFile, etc.) could not be written
|
Note that in the event of an error, the usual popup message that would be displayed when not running in command line mode is instead appended to a file called "errorlog.txt" in the folder where RealTest was installed. The error message is also written to the stderr command line output stream.
In addition, a file called batchlog.txt is created in the RealTest folder for each batch-mode run. Unlike errorlog.txt (which keeps growing), batchlog.txt is recreated each time, making it easier for AI agents and other automated tools to process. If the script parsed and ran without errors, batchlog.txt will contain an "OK" success message. A run that completes but fails to write an output file the script asked for (a Save...As CSV, or the OrdersFile of an orders run) is not a success: it exits with code 9 and writes no "OK" line.
Syntax errors reported in batch mode use script line and column numbers rather than raw byte offsets, which is more useful when working with AI agents such as Claude Code.
When using a standard Windows .CMD batch script, you can check the return code using %errorlevel%, as in the following example:
@echo off
cd c:\RealTest
start /wait RealTest -import -scan my_scan.rts
if errorlevel 1 goto error
start /wait RealTest -import -orders my_orders.rts
if errorlevel 1 goto error
echo Script completed
goto done
:error
echo Error code was %errorlevel%
:done
pause
exit
Note also that in batch mode, RealTest runs with its main window minimized, but you can restore it manually if desired, to see what it's doing.
The command -noexit can optionally be added to the command line. If found, RealTest will remain open after processing the other commands.
If errors are encountered in a -noexit run, RealTest will close, return an error code, and log the error to errorlog.txt, as if -noexit had not been specified.
The command -define xxx can be used to define a symbol on the command line. This enables #ifdef / #endif blocks in a script to be controlled from outside the script. Multiple -define arguments can be specified. This is especially useful when doing AI-driven research, e.g. with Claude Code. Note that -define by itself does not engage command line (batch) mode, so it can also be used when opening a normal interactive session; batch mode engages only when a run-mode argument such as -test is present.
The commands -api and -port N enable the Automation API for this launch (the second also chooses its port). Neither implies batch mode: RealTest opens normally and can then be driven over HTTP by scripts and AI tools, which is the better choice when the same instance will run several tests or when a task needs the interactive windows.
The command -hide starts RealTest minimized without activating its window, so launching it never takes keyboard focus away from the application you are working in. Like -api it does not imply batch mode; it is intended for automation programs that launch their own RealTest instance, and the two are typically used together.
The command -batchlog file writes the batchlog.txt output to the given file instead of the batchlog.txt in the RealTest folder. A relative path is relative to the current folder of the command shell that launched RealTest. Use it when several batch runs (for example parallel AI sessions) may run at the same time: they otherwise all write to the same batchlog.txt, and each new run starts by deleting it, so a run could read another run's "OK" line as its own. Like -api it does not imply batch mode.
The command -expandto path only parses each script and saves its expanded text to path: every Include file inlined (the Include line itself kept as a // comment), the same text Show Original Test Script shows for a test. Nothing is imported, loaded or run. A * in path stands for the script's file name without its extension, and a folder (one that exists, or a path ending in \) gets the script's own file name, so -expandto D:\Expanded\ saves each script under its own name in that folder and -expandto C:\Scripts\*_expanded.rts saves MyScript.rts as MyScript_expanded.rts. A relative path is relative to the current folder of the command shell that launched RealTest. The run mode chooses which mode-specific includes are expanded: -parse (the default when no mode is given) expands only Include, -test also TestInclude, -scan ScanInclude and -orders OrdersInclude. For each script batchlog.txt gets an "Expanded:" line naming the file written. Saving over the script itself is refused (exit code 9). Example: realtest.exe -expandto D:\Expanded\ C:\Scripts\a.rts C:\Scripts\b.rts
|