Algos and Scripts Version 1.0 Algos and Scripts www.fxdd.com 1. Script Script is a program written using FXDD API which performs actions once, on execute method call. It can be stopped by user or it will stop after code, for execution, completed. Basic language for scripts is Java. The following template of the script appears after new script creation: import com.fxdd.fip.algos.Script; public class NewScript extends Script { @Override public void execute() { // TODO Auto-generated method stub } @Override public void onDispose() { // TODO Auto-generated method stub } @Override public void onInit() { } } Algos and Scripts www.fxdd.com 2. Algo Algo is a program written using FXDD API which performs actions on every new tick. It can be stopped only by user or due to some errors. Basic language for algos is Java The following template of the algo appears after new algo creation: import com.fxdd.fip.algos.TradeAlgo; import com.fxdd.fip.algos.Quote; public class NewAlgo extends TradeAlgo { @Override public void onTick(Quote quote) { // TODO Auto-generated method stub } @Override public void onDispose() { // TODO Auto-generated method stub } @Override public void onInit() { } } Directory where algos are saved is set in the Tools->Options->Algo Whiz parameter. Its value is equal to <user_home>\.fxdd\Algo by default Algos and Scripts www.fxdd.com 3. Life cycle of Algo/Script Create Open Delete Save Edit Compile Start Stop All errors and warnings during algo/script creation and execution are written in the log file. The log directory is set in the Tools->Options->Logging parameter. It is equal to <user_home>\.fxdd\logs‖ by default but it can be reconfigured. All manipulations with algo or script are executed using Explorer tab (see Error! Reference source not found.). If user selects some algo or script in the explorer then right-click popup menu contains: Edit (it opens user script in the editor) Start (it executes script) Note: this menu item differs for scripts and for algos (it is absent for algo). You can use “drag and drop” mechanism to start either algo or script. Stop (it detaches algo or breaks script execution) Note: item appears only for attached algos or executing scripts. Compile (it runs process to compile) Delete (it deletes script) Algos and Scripts www.fxdd.com Each script is shown in Explorer as a single item under corresponding high level nodes (without .java extension) with icon. Icon indicates one of the following states: (Not ready) – user script is not compiled; (Ready) – user script is compiled; (Running) – user script is running now. Several instances of this user script can be running in the same time. New As a result of this action the new user script (script or algo) with appropriate type and name is created. The script or algo can be created in the following way: ―Create‖ item in the popup menu of Explorer tab ―New‖ menu item in the toolbar of Script Editor ―File‖->‖New‖ item in the main menu of Script Editor ―Ctrl‖+‖N‖ hotkeys in Script Editor Open As a result of this action the selected script or algo is opened. The script or algo can be opened in the following way: ―Edit‖ or ―Open‖ item in the popup menu of Explorer tab ―Open‖ menu item in the toolbar of Script Editor ―File‖->‖Open‖ item in the main menu of Script Editor ―Ctrl‖+‖O‖ hotkeys in Script Editor Save As a result of this action user script from active tab is saved. Also you can save all opened user scripts (‗Save All‘) or choose new script name or create new script with the copies of content from active script (‗Save As…‘). Note: While copying content it changes java class and contructor name to new one. The script or algo can be saved in the following way: ―Save‖ or ―Save All‖ or ―Save As…‖ menu item in the toolbar of Script Editor ―File‖->‖Save‖ or ―File‖->‖Save All‖ or ―File‖->‖Save As…‖ item in the main menu of Script Editor ―Ctrl‖+‖S‖ hotkeys in Script Editor to ―Save‖ ―Ctrl‖+‖Shift‖+‖S‖ hotkeys in Script Editor to ―Save All‖ Algos and Scripts www.fxdd.com Edit The script or algo can be modified during creation or after its opening. Compile The result of this action is compiled user script (algo or script). If JDK is not installed or not defined path to installed JDK then the message with link to JDK settings is shown during compilation. The script or algo can be compiled in the following way: ―Compile‖ item in the popup menu of Explorer tab ―Compile‖ menu item in the toolbar of Script Editor ―Task‖->‖Compile‖ item in the main menu of Script Editor ―F5‖ hotkeys in Script Editor In some cases the compilation cannot be executed: Compilation should fail if parent class is not correct for user script type: TradeAlgo class for Algo, Script class for Script. Already running user script cannot be compiled. Start ―Start‖ operation attaches algo or executes script for selected CP and time interval. Start item enabled only if user script already compiled without errors. The script or algo can be started in the following way: Drag and drop algo or script from ―Explorer‖ tab to selected chart ―Start‖ item in the popup menu of ―Explorer‖ tab only for script ―Start‖ menu item in the toolbar of Script Editor ―Task‖->―Start‖ item in the main menu of Script Editor ―F7‖ hotkeys in Script Editor to ―Start‖ Algos and Scripts www.fxdd.com ―Drag and drop‖ start has some specific characters: CP and time interval are taken from selected (base) chart Only one algo can be attached to one chart. If you try to drop algo (algo2) on the chart where another algo (algo1) is already attached then the confirmation dialog appears and in continuation case algo1 can be stopped automatically. If equal charts are opened in different tabs then the different algos can be attached to them. If you try to close chart with attached algo then the confirmation dialog appears and algo can be stopped in continuation case. When you choose ―Start‖ action (except ―drag and drop‖ start) then the ―Start on‖ dialog appears. ―Start on‖ dialog allows user to select CP and period to attach algo or to execute script. All attached algos and executed scripts are shown in the ―Attached advisers‖ tab Running user scripts (especially algos) are shown in the table view with following information: ‗Name‘ – should contains ―[User script name <user script id>]‖; ‗CP‘ – currency pair symbol; ‗Period‘ – period. Before using you can also test your strategy (algo or script) in Back Tester tool (see chapter ‗Script Editor‘) on the real historical data. Stop ―Stop‖ operation detaches algo or breaks script execution. If several instances of user script are running then ―Stop‖ action provides form to choose instance to stop. The script or algo can be stopped in the following way: Press ―x‖ icon near the algo name in the chart if algo is started on this chart using ―drag and drop‖. Algos and Scripts www.fxdd.com ―Stop‖ item in the popup menu of ―Explorer‖ tab ‖Stop‖ menu item in the toolbar of Script Editor ―Task‖->―‖Stop‖ item in the main menu of Script Editor ―Shift‖+‖F7‖ hotkeys in Script Editor to ―Stop‖ ―Stop‖ item in the popup menu of ―Attached Algos‖ tab Every attached algo disappears from the ―Attached advisers‖ tab after its stopping. Delete Every script or algo can be removed from Explorer tab and physically from the storage folder. If you try to delete running script suggestion to stop running instances and delete user script is shown. Algos and Scripts www.fxdd.com 3. Group Script and Group Algo Group script and group algo are used instead of simple algo and script in case of MAM user. 4. Binary Script and Binary Algo Binary script and binary algo are delivered by 3th party developer in special form to plug in Swordfish. Now links on such developers are not provided by Swordfish Trader Interface but later this information can appear there. Their differences from the normal script/algo are the following: They are already compiled (in binary form) and don‘t include its sources. Binary Algos Package is a .Jar archive. In the main Explorer binary algos and scripts contain only Start/Stop options (no Edit, Compile or Delete operations) Install Uninstall Start Stop Interface remembers info about installed packages between restarts. It is allow to providing many Algos and Scripts in one package. Algos and Scripts www.fxdd.com To manage binary algos and scripts the Binary algos package manager is used. It can be opened using following way: by View -> Binary Algos Packages menu item by selection of ―Install‖ menu item in the ―Binary Scripts‖ or ―Binary Algos‖ nodes of Explorer tab. There are 3 main controls in the manager: Explorer. It contains list of installed packages as a tree-like structure: - First level nodes are packages that been installed - Each package node has two sub-nodes: Binary Algos and Binary Scripts - All algos and scripts that found in the package placed under these sub-nodes depend on its type. Properties frame. It contains info about selected entity in the explorer: For algos and scripts entities - Class (main class file) - Descriptions - Author - Version For package entity: - Name - Install path - Install date Install New Package button. By its pressing the following actions have happen: - Standard file open dialog appears. You are able to select .JAR algo binary package archive. - By pressing ―Install‖ button in the file open dialog the installation process begin. - During installation the package archive unpacked to <user_home>/.fxdd/Algo/Binary/<package_name>/ folder. - After successful install the installed package showed in the explorer. Note: Package with given name can be installed only once!
Description: