Using the Lua programming language, you can create various games, utilities,
trading robots and other developments. The Lua language is easy to understand, has a popularized interpreter. It is proposed to get acquainted with Lua closer, as well as learn how to write a trading robot or script in this language.
- What is the Lua language and how is it useful?
- Short historical data
- Features of the Lua programming language
- Advantages and disadvantages
- Comparison with Javascript
- Features of programming robots for trading in the Lua language
- Overview of the best trading robots on Lua – ready-made solutions for beginners
- Robot-terminal “Delta Pro”
- RQ: One Percent
- RQ: Martin
- Types of Lua scripts for the QUIK terminal
- How to write a robot in Lua
- How to program in LUA in QUIK terminal
- How to install a LUA script in a trading terminal
What is the Lua language and how is it useful?
Lua is an easy to use embeddable language. Beginners admit that with its help, you can learn the basics of programming in a short time. Lua is successfully combined with developments that were compiled in another language. It is often recommended to students who are just starting out in the science of electronic design.
- A user who plays computer games (write plugins).
- Game development specialist (develop the engine).
- Application development programmer (write plugins for various utilities).
- Developer in the direction of embedded (the language does not slow down the process and allows you to work efficiently)
- Traders for writing scripts and trading bots.
Trading robot for QUIK on Lua by rebuy levels
Thanks to Lua, more than one trading robot has been created. The advantage is that each user can quickly understand the nuances of the language and independently create such a program. Through it, it will be possible to send commands to
the Quik terminal and carry out technical analysis. What is the Lua language for, an overview of the LUA programming language: https://youtu.be/PbYf6uNZFCE
Short historical data
Lua was invented in 1993 by Brazilian programmers from the Tecgraf division. The developers made sure that each user could make certain amendments to the development of the language. This can be done through open access to the code. For Brazil, the emergence of its own programming language was a real discovery. Indeed, before that, this country did not achieve such success in the field of computer development.
Features of the Lua programming language
Faced with Lua, the developer is given the opportunity to use this language, both built-in (due to the fact that it is scripted) and standalone (in certain cases, it can be used without add-ons). When the authors worked on the creation of Lua, they deliberately went to make an operational tool that does not take up much space and will easily function on any device.
Advantages and disadvantages
- Quality transportation . Unlike many programs, Lua is easy to transfer from one operating system to another. In this case, there are no major changes. In any case, there will be no errors in the code.
- Lots of libraries . Compared to JavaScript , Lua has much fewer library options. However, the official resource has everything you need to fully work with the language.
- Efficiency . The system allows you to add those libraries that are important for a particular coding process in a short time.
- Ease of use . Programming gurus only need to learn a few details of the language, and even then they can safely use it in their developments. For those just starting out with programming, it doesn’t take long to understand Lua either.
- Substantial memory savings . By creating programs in this language, a specialist is guaranteed to notice the difference with other analogues. After all, Lua developments need less memory on the device.
The only significant disadvantage of the language is that it is scripted. And this means that often it can only be used in combination with other development languages. The most popular of these is C. That is, you will have to learn an additional programming language.
Comparison with Javascript
Many users compare Lua to JavaScript, claiming that their codes are almost the same. There are indeed more similarities between languages than differences. But, despite the obvious similarities, there are many differences. For example, Lua has its own software support. However, JavaScript developers have recently introduced an update, according to which, it is enough for the user to write the word “yield” between the generators, after which the program will be supported.
Features of programming robots for trading in the Lua language
Creating robots on QLua is not at all difficult, even beginners can handle it. The main thing is to understand the basic theory at the very beginning. In order to compose the code, the simplest text editor is useful. The scheme of creation is similar to the compilation of an indicator. However, there is an insignificant difference in the code itself. Another good “highlight” – the newly minted robot can be placed anywhere on your PC.
Important! There should be only one function in the code – “main”.
Once the robot code is compiled and edited, it is recommended to save it. Don’t forget about the lua extension. As already mentioned, the program can be placed anywhere on the computer. To test your code, you need to run the robot. To do this, go to the “Services” section. At the bottom there will be a line “Lua scripts”, it should be clicked.
Overview of the best trading robots on Lua – ready-made solutions for beginners
Using the Lua programming language, you can create various types of robots of any complexity. However, you can purchase a ready-made program. It is proposed to get acquainted with the well-known algorithms that are already ready for work. You can buy them or try out the demo version. Complete trading robot for the QUIK terminal in Lua: https://youtu.be/Z2xzOfNZFso
Robot-terminal “Delta Pro”
Allows you to activate about 120 any options on one platform. In this case, you can use different types of strategies and tools.
RQ: One Percent
The robot is designed for trading in the field of trading. The algorithm allows you to increase the income from this activity several times. Risks are minimized, they can be easily calculated.
RQ: Martin
The system allows you to calculate the lot before making a deal. Trading in the “semi-automatic” mode is provided. Levels can be successfully tracked and set manually.
Types of Lua scripts for the QUIK terminal
When performing a certain task in the QUIK terminal, the following scripts are used:
- Lua scripts . They can be stored on the network, on a local disk, or in another place where they will be accessible to the terminal. They are functional enough to create a trading robot with their help. It will be possible to create tables in QUIK, use tool options, give commands to perform various tasks, and so on.
- Custom indicators . Here, compared with the previous view, much less functionality. The program is intended for the user to display the algorithm of actions on the terminal charts.
Programming in Lua for those who want to master the language thoroughly – download the complete guide:
Programming in Lua Robots in Lua for QUIK – Iceberg robot: https://youtu.be/cxXwF_xmTHY
How to write a robot in Lua
Having decided to create his own robot, the user must follow a pre-compiled algorithm. When he gains experience in programming, he will be able to easily write his own codes and experiment. By choosing Lua to study this area, a beginner will not be mistaken. After all, in the beginning, the main thing is to stop at a simple and most understandable programming language. To get started, open the QUIK trading terminal program. In its window, you need to create a folder. This is the place where all written scripts will be saved. The user can give the folder absolutely any name, but it must consist only of Latin characters. Let’s say its name is “LuaScripts”. Next, you need to activate the folder and create a text editor there, for example, Notepad. In an empty space (within the program window) you need to right-click
. A dialog box will appear, in the list of which you need to select the “Create” tab, and then the “Text Document” row.
function main()
message(“My first script has been launched”);
end Next, you need to click on the save button in the menu.
How to program in LUA in QUIK terminal
There are 3 popular ways:
- Any text file is created, where the .lua extension should be put. Next, you need to open the editor and write the code. After starting, such an algorithm will be executed only once. You can run it manually indefinitely. You can use it for a one-time calculation of certain information.
- In the Lua script itself, you need to create a function called main() . Further, in the same function, you need to insert the written code. And the sleep() function is useful to temporarily pause the script or, conversely, resume it. That is, if you activate the main () function, and then insert the sleep () function, you will be able to achieve calculation with a frequency of a specific time interval.
- In a QLUA program, you can use the event-driven development model. Thus, now it is not necessary to “detect” changes in one function and, due to this, execute the following commands.
It is proposed to analyze the latter method in more detail. To handle a specific event, you should write a function in a script in Quick. You can use the following scheme: A
main() function . Then, you need to declare
is_run , the function will contain the value
trueuntil the user activates the Stop Script button. Then the function variable goes into false mode inside OnStop(). After that, the main() function ends, and the script itself stops. The written script must be saved and run. When making transactions, the user will see the data for each lot and the final amount of transactions.
How to install a LUA script in a trading terminal
The training and standard terminals require the same algorithm for installing a trading robot:
- It is necessary to click on the “Services” section in the top menu of the terminal.
- Next, find the “LUA scripts” button in the drop-down dialog box and click:
- At that time, the “Available Scripts” window should appear. Then, you should activate the “Add” button and select the file of the required trading robot.
Taking data from the Lua chart with a script in the Quik terminal: https://youtu.be/XVCZAnWoA8E Lua is a great option for learning programming and for success in the future. The main thing is not to stop only at reading the theory. It is better to learn the material by constantly practicing. After a certain time, the developer will begin to make progress and be able to create his own worthwhile product.