Algorithmic language QPILE for programming trading robots for QUIK.
Trading robots can be written in a specific language, similar to program code. QPILE is one of them, the article will consider this language, compare the QPILE and
LUA languages , and also provide examples of robots in this language.
- General information about QPILE
- Working with a table
- QPILE constructs
- Data types
- Expressions
- Functions
- Debugging programs
- QPILE or LUA?
- How to create a trading robot on QPILE?
- Trading robots on QPILE – ready-made solutions
- Moving average robot
- N. Moroshkin position calculator
- Volume filter
- Options Greeks
- TRIX trading robot for QUIK
- M4 preprocessor
General information about QPILE
QPILE is an abbreviation that stands for QUIK Programmable Interface and Logic Environment.
This is a series of commands interpreted by the QUIK workstation. It is mainly used to calculate the price of portfolios of securities. The language is also used for:
- dynamic recalculation of the price of clients’ assets on the broker’s desktop and in their portfolios. In the latter case, their total price is also recalculated;
- finding missing indicators using their own algorithms and data for margin lending;
- developing the right trading strategy.
The language describes the structure of the table: the appointment of columns and rows, formulas. In the latter, mathematical operations, variables, data from other tables can be used for calculation. The program code loaded from the QUIK server or from the user’s disk is processed by the language interpreter, which calculates the values in the formulas. The tables of one program have one data source, but the calculations are not duplicated and do not affect the efficiency of the system. When working with QUIK tables, tables on QPILE have standard functions. QUIK in the workplace is equipped with a QPILE code debugger. https://articles.opexflow.com/software-trading/torgovyj-terminal-quik.htm The language allows you to describe new tables with a given structure, highlight cells with certain values, calculate fields based on mathematical and logical expressions. The user will receive notifications in the form of a sound signal or a text message. Tables on QPILE can be edited, printed, copied, exported via ODBC and DDE server. The initial data are from the QUIK tables:
- transactions, including for execution and impersonal;
- orders, including stop orders, for over-the-counter trades and orders – reports for trades in settlement deals;
- “client portfolio”, “buy/sell”
- data from the participant’s positions by money, trading accounts, instrument.
Tables based on QPILE cannot be copied to a text file via the context menu and exported to technical analysis systems, and charts cannot be developed based on them. QPILE-based tables cannot be filtered or sorted.
Working with a table
To load the program code, you need to select the services menu, then QPILE scripts. You can also use the combination Ctrl+F11. After you need to click “Add” and select the desired file. It has a .qpl extension and its name will appear in the Available Scripts list.
- table name;
- number of columns and clients;
- list of identifiers and clients;
- the list of parameters and the source code of the file.
QPILE constructs
Data types
- String – string.
- Double is a floating point number.
- Collection – a collection.
- Map – an associative array – a sequence of pairs that allows you to get information by key.
Expressions
The arithmetic operations of addition, subtraction, multiplication, division are applied. The logical expressions “and”, “or”, equals, more, less, inequalities, conditional construction “if … then …” are also used.
Functions
Functions can be located anywhere in the program and have different names. In total, 18 groups of mathematical functions and functions are available to obtain the values of tables and parameters, associative arrays, a list of tables, and other tasks. First grade:
- Mathematical functions that allow you to return the value of the sine, cosine, tangent, cotangent of the argument, calculate the exponent of the argument, generate a random number, etc.
- General commands : NEW_GLOBAL to initialize a global variable and MESSAGE to open messages.
Functions to work with:
- Collections of objects (Collection) . They allow you to create a new collection, return the required number of elements, replace or insert the desired values.
- Associative Arrays (MAP) . Help to create and manage the array.
- Files – working with text files, maintaining a log-log of the program. The file name may contain the path to it.
- Strings .
- Graphs . Functions GET_CANDLE to access candle data and GET_CANDLE EX to return an associative array.
- Applications . Creating orders and sending them to the trading system.
- Tags . Their construction and installation on the chart. Adding, deleting one or all labels, getting and setting parameters for a specific label.
There are also functions for:
- For accessing rows of arbitrary QUIK tables and lists of available parameters . Access to workplace table data. These include GET_ITEM to return the MAP and GET_NUMBER_OF to return the number of entries.
- To work with a programmable table . These commands operate on the OWN table. It is readable by the standard functions from the previous paragraph and by these functions. This group includes commands for adding, modifying and deleting a row with an index, and completely clearing the OWN table.
To get values use:
- Tables of current trades . Getting exchange information parameters using GET_PARAM (_EX) commands.
- Quote windows . Obtaining the values of instrument quotes.
- Tables of positions by instruments and money . Obtaining data on a client, firm, instrument, depo account by code.
Service functions – returning the date of the current trading session, associative series, current date and time, determining the connection state, interrupting the calculation mode.
Debugging programs
Step-by-step control over the operation of the program is carried out in the “Debug” window. It is opened from the context menu “Start calculation in debug mode”. It can also be opened with the breakpoint() command, and the program line will be highlighted in red. The window contains fields with program code and variable values. At the bottom of the window there are buttons “Next step”, “Continue execution”, “Stop calculation”. Pressing F5 will continue the execution of the program, the combination Shift + F5 will stop debugging, the F10 key will direct to the next line.
QPILE or LUA?
LUA is a new programming language for creating trading robots. Like QPILE, it is implemented in the QUIK terminal. https://articles.opexflow.com/programming/lua.htm A site dedicated to the development of trading robots for trading shows the advantages of the LUA language over QPILE. So, it can function as a non-compiled script and bytecode, equipped with developer tools and object-oriented programming mechanisms. Objects written in other programming languages can be connected to LUA programs. LUA provides 8 data types, including metatables. The LUA language is multi-threaded, fast, and transactions and terminal events are asynchronous. LUA is more common than QPILE, and many extensions have been written for it.
The QPILE language is now deprecated. Experts on the forums recommend using LUA. Although useful and effective programs are still being used.
However, the QPILE language is simple compared to LUA, so if you have no experience in programming, it is better to choose QPILE. In this language, you can write a simple robot if you do not need to perform complex calculations.
How to create a trading robot on QPILE?
To create a trading advisor, you will need the following programs:
- ITS Quik.
- Notepad++ code editor.
- Guide to QPILE.
- XML plugin for code detection in Notepad++.
Download and install these programs. Enable the language syntax by placing userDefineLang.xml in the path C:\Users\User\ AppData\Roaming\Notepad++\
The “User settings” block is supplemented with the NUMBER and INTERVAL variables, which will be used in the function of obtaining the last N bars. The DATETIME function sets the server date and time, and the current date and time functions CURDATE and CURTIME are called from it. The current time is converted to a number on line 24. Line 26 sets the time for the algorithm to run from 10:00:01 to 18:40:00 UTC.
Trading robots on QPILE – ready-made solutions
Moving average robot
Demo robot not suitable for real trading.
N. Moroshkin position calculator
A program for calculating the levels of the maximum allowable drawdown and the target for long and short positions at current ask and bid prices. The levels are calculated for 2 values of the position entry volume. The robot finds the allowable position volume when assigning a stop order in one step from the opening price with the calculation of opening a position in the direction of the bar growth. The found levels are entered into the terminal window, which are subsequently reflected in the price chart. Transactions are fixed for a given instrument. If a position is opened, the robot starts calculating its parameters. Depending on the change in position, the assigned orders are adjusted.
Volume filter
Portfolio robot for calculating the arithmetic mean of the volume for candles and comparing it with the average product by the X coefficient. Works correctly with plotted charts in the selected time period.
Options Greeks
Portfolio for calculating and displaying “Greeks” of options. It differs from the Black-Showers method.
TRIX trading robot for QUIK
The program is based on the TRIX Indicator. When the indicator closes above the zero line, the specified level, the robot takes the Long position. The position is closed by Take Profit, Stop Loss or trailing stop.
M4 preprocessor
Program for working with QPILE and Lua. Includes archives with executable files, documentation and DLL files with regular expression parsing. To use the program, you need to unpack the executable files and place regexp2 in the C:\Windows path. Lessons on QPILE for QUIK: https://youtu.be/vMTXwDUujpI Installing a script on QPILE in the Quik terminal: https://youtu.be/0B7qL8Svh7I A section on github that describes the use of the QPILE algorithmic language built into the QUIK system workstation located at the link – https://euvgub.github.io/quik_user_manual/ch8.html. QPILE is an outdated language, but quite simple and accessible even to novice traders. Trading robots and programs that have proven themselves for a long time continue to work on it. However, for more complex tasks it is better to use LUA.
0к