MT4 scripts and a selection of irreplaceable scripts. Trendline Expert Advisor Script that trades from horizontal lines
From the article you will learn:
My ardent greetings to all readers and visitors of the site. Today I am talking about a very relevant topic Are scripts. The script for opening orders and the Script for placing pending orders will become a good example for us of how a systematic approach and a desire to transfer some of the functions to a computer in trading makes a trader take the first step from manual trading to automatic. I'm talking about the fact that he begins to use scripts. On the other hand, an algorithmic trader will use scripts with the former on an equal footing when his automated system is under development.
Best Broker
So what exactly I want to tell you today. The fact is that trading at the very beginning of its appearance was manual. And the transition to automatic systems came with the evolution of computers. Accordingly, this evolutionary step, sooner or later, is made by many traders. They are starting to use robots instead of manual strategies. At the same time, it is important to use a systematic approach, without this this transitional step - the use of scripts, will not be relevant, because scripts are not a panacea. They cannot replace a complete trading system. It's just a tool in your arsenal.
In addition, traders who already use robots, according to the specifics of trading, also resort to using scripts. This is due to the fact that there are peculiarities of the terminal operation, which, with its in-depth use, are available only through robots and scripts. This does not mean that anyone who wants to trade in Forex cannot do this, on the contrary, trading is available to everyone. It's just that the process of trading under the influence of evolution is becoming more complicated, which means that traders are becoming more advanced. In general, scripts do not interfere, but help. So, more about everything.
Advantages and disadvantages, what is all this for
What is a script for?
- There are constantly repetitive operations that can be trusted to a computer. Conditions come under which one should open, close, change something, count, and so on. All this can be done semi-automatically using a script,
- Another good example is the order opening script. The fact is that most parts of trade orders can most often be changed using simple order opening windows. However, there is such a part of the order as the magic number, below I will tell you more about it. For now, I will say that this is a great important part of the order, it can only be changed with the help of a robot or a script. And already if we began to use the script for opening orders, then the comments can be edited, and so on.
- The script for placing pending orders will show us the other side of using these programs. Increasing the speed of reaction to certain market situations is a very urgent task. Everyone would like to snatch as much as possible in a volatile market. It is for these purposes that the script for placing pending orders is used, which I will talk about today.
However, what exactly is a magic number, and why is it so important? Imagine that you, like mine, have more than seventy open terminals. You might think that only one robot can work on one terminal within one account. That is, seventy robots are trading quietly for themselves. What else do you need? But that may not be the case. In fact, using the Magic number suggests using an infinite number of robots on one account, even on the same pair. Of course, the accounting of efficiency changes slightly, but, in general, nothing changes. And now imagine that there are 2-3 or more robots on each terminal. What results can be achieved? One can only guess. To you. And I enjoy what is happening on my VPS with a grin, and I advise you: go for free, and I will share with you what I know myself.
Returning to our auxiliary programs, I want to emphasize: you cannot create a trading system if there is nothing but a script in it. This program is not a panacea or a grail. It just helps you perform some operations. He will not think for you. Therefore, it should be used only within the framework of an integral trading system. Thus, the main disadvantage of scripts for opening orders, setting pending orders and all others is that manual labor is still needed. You make the decision to carry out the planned actions, and only you are responsible for the consequences of your actions. Of course, the result can be overwhelming, but the credit for this will be more yours than this auxiliary program.
I especially want to draw your attention to the speed of script execution. Actions that may take you and for several tens of minutes are performed in a few seconds. This frees you from some of the responsibility. Although it is not entirely correct to say so, I will still risk it. The fact is that you still assume your responsibility, but only at the moment when you are looking for a script and checking its suitability for your trading system. When you do it, there is no longer any question of responsibility. At least on a conscious level. Somewhere in the subcortex, it remains. But, I suppose, psychologically it will already be much easier for you.
On the need for a system and examples
Watch a video about the script
I think that you have already understood that without a system, there is nothing to do with this auxiliary program. Yes, he opens orders, he does it completely automatically, but he does it - he has no idea at all. No, of course, it contains the logic that you put into the moment of its selection or study. But at the moment of execution, nothing can stop him from doing what he has to do. But the conditions on the market can be either suitable for the work of this auxiliary program, or completely harmful, not working at this moment. The moment you decide to launch it.
Download
That is why you need some more advanced idea than just the decision to run a script. In simple terms, you have to use it as part of some simple yet workable manual strategy. Those who are ready to use it to correct the work of their advisor also need to understand that it should be launched only when conditions have been formed under which your advisor should have responded, but did not react, or in another suitable situation.
The system does not make a grail of your actions, but it brings them closer to it as much as the mind allows.
Let's look at a simple system for the script for placing pending orders, which you can download from this page, as well as the script for opening orders.
So, here we see the EURUSD pair, the M1 interval, as well as the indicator that showed the candle height required for entry. At the opening of the next one, we execute the script for placing pending orders at an effective distance previously checked in history and get two pending orders on two horizontal lines. Place stop-losses on opposite sides. In this case, take-profit can be omitted. Since we have established with the help of observations that on history, trades with a duration of 70 candles work well. On the right vertical line, we exit both trades. As a result, we get an impressive ratio of profit to loss of about 8 to 1, the second order did not even enter the market.
At the same time, you need to understand that if we did not go through history and set the length of the candlestick, after which it is advisable to enter, if we didn’t calculate that this very distance between orders gives, on average, a good mathematical expectation. If we had not calculated at what distance from the entry the orders will give a good profit, then we would not have been able to work according to the forecast. This is how we get great deals. What do I mean by all this? Only a systematic approach, coupled with the work of such auxiliary programs, can give a good result. No other approach, except the systemic one, can give a positive expected result. Do not forget that there are many such tools. For example, .
Place horizontal lines on the chart and call them “BUY” (for the first buy order) and / or “SELL” (for the first sell order).
As soon as the closing price of the bar (past) becomes above the “BUY” line, a BUY order is placed (for a sell order, the closing price of the bar must be below the “SELL” line)
Further, the averaging lines come into operation. They can have any name and can be located anywhere on the chart. They do not need to be renamed, the Expert Advisor will understand what lines are needed for what. If the horizontal line is above the buy order, it will delete it, and if it is below it, it will consider it as its averaging line. At the same time, it will repaint it blue and make it dotted. The averaging line is the order line on which the lot will be opened with the lot increased by the coefficient K. Next, the advisor will recalculate the take profit of all orders and place it at the distance of the general breakeven.
Example of work:
We put a line and name it Sell.
The price crossed the line and as soon as the candlestick closed below the line, a Sell order was placed. We put the averaging line above the open sell order (this can be done in advance, together with the installation of the first line). There can be any number of averaging lines.
As soon as the candlestick closed below the averaging line, a Sell order was placed with an increased lot. At the same time, the breakeven point (marked with a red price label) shifted higher and the take-profits of both orders were also recalculated.
You can use the EA as a strategy tester, to do this, it must be put into the tester with visualization at low speed. Next, hang the necessary indicators there and set the necessary lines in the direction of movement. Thus, you can test almost any strategy on history without ordering the development of specialized advisors.
Greetings to dear readers. Today I want to publish some Forex scripts that have been helping me in my work for many years. Let me remind you that a script, unlike an Expert Advisor, is intended for a one-time execution of any planned action.
Typically, scripts are run by the user, perform their function, and stop running. Scripts are usually used when it is necessary to avoid routine work of the same type that takes time, for example, closing all positions, setting a general stop loss for the order grid, moving positions to breakeven, and the like.
Scripts are installed in a folder Scripts the data catalog of the MT4 trading terminal, instructions for finding the data catalog and installing advisors, scripts, indicators are given in the article.
Forex scripts are launched from the "Scripts" section of the navigator by double clicking or dragging the script onto the price chart.
I also use a wonderful function built into the MT4 terminal - setting hotkeys that allow you to call a script or indicator.
It is very convenient if you urgently need to close all orders for the current instrument, just press the keyboard shortcuts and enjoy the result, rather than looking for the required script in the navigator, not to mention using the standard methods for managing positions provided by the Metatrader functions.
To set the hotkey by which the script will be called, you need to select the required Forex script in the navigator, press the right mouse button and select the "Set hotkey" section in the context menu that appears. Next, in the window that opens, for the selected script, set our unique keyboard shortcut Alt with a letter, or Ctrl with a letter. Carefully study the manual of the terminal itself so as not to override the default keyboard shortcuts that operate in the terminal itself.
So, here are the main forex scripts that I use almost every day:
The first group includes scripts for simultaneous closing of positions and pending orders.
KS_CloseAll- the script quickly closes all available open positions and pending orders. Convenient for multicurrency trading, when you need to fix the current achieved trading result. This script compares favorably with its counterparts in that it will do everything possible to complete the closing. Script fights against such phenomena as requotes, price changes, busyness of the trading flow, new order openings by other advisors or scripts, and other “intrigues” of the DC. In the script settings, you can set:
Close all positions - Close open positions
Delete Pended Orders - Delete pending orders
Magic Number (-1 for all) - Use magic number
Slippage - Allowable slippage
west_close- the script closes all positions and deletes pending orders without first displaying a window asking whether to run the script or not, and even without displaying the parameters window. It is activated immediately after launch and works quickly. Very convenient for scalping, the script sits on my hotkey Alt + K (from English Kill).
The following scripts require dragging the script itself from the navigator window to a specific place on the price chart with the mouse.
KS_Splitter- script for partial closing of the selected position. To select the desired position, you need to drop the script itself on the price chart directly on the order and set the volume of partial closing in lots in the window that opens.
west_SLTP_drop- a script for the simultaneous installation of Stop-Loss and Take-Profit for all positions and orders of the current instrument at the price at which the script was thrown. Depending on which side of the position the script was thrown from, it is automatically determined by the script itself whether to set a stop or take. It is very convenient when there are many positions, when the entry is performed in parts or by a grid of orders.
Important! To perform trade operations, it is necessary to click the "Auto-trade" button. Watch for this when you run scripts that perform any manipulations with positions and orders.
And the bonus: west_objdelete- a script that removes all constructions on the chart, clears it completely from objects, even from those that have the property “not displayed in the list of objects. I also have the script on the Alt_C hotkey (from Clear - clear).
Download forex scripts:
Use the proposed Forex scripts and your productivity will undoubtedly increase.
Semi-automatic trading system
"Trade along the lines".
Principle of operation.
The utility "Line trading" is designed to facilitate the work of a trader. Everything is very simple: using a special utility, we put a channel of 4 lines on the chart. Two lines will be required to enter, the other two will be required to exit. Then you can change the angle of inclination of each line, change the distance between them, etc. When the price reaches one of the entry lines, a buy or sell entry occurs. After that, when the price reaches one of the exit lines, the deal will be fixed with a profit (take profit) or with a loss (stop loss). Thus, you can easily organize trading by price channels and other strategies.
- Setting stop or limit orders based on custom lines (horizontal or trend);
- User adjustment of the position of the lines after the start of the advisor (robot);
- Tracking open and close prices according to trend lines;
- Calculation of the risk of all open positions for the current instrument;
- Calculation of risk based on user-set percent of the deposit;
- Calculation of the Risk / Profit ratio;
- Calculation of the channel width.
Installation and preparation for work.
1. Install the system in MetaTrader4, indicating the correct path.
3. Using the mouse pointer, drag the script for drawing lines LinesToChart onto the chart. The settings window will appear.
System requirements.
operating system Microsoft® Windows®98/2000/ XP / Vista / Windows 7
Pentium® 4 2Ghz or higher processor
terminal MetaTrader4 build 600 and higher
Trading from support and resistance levels, as well as based on their breakdown, is a fairly effective approach.
However, even to this day, there is no clear definition of levels, because two or three price touches are actually far from enough to assert that the drawn line is true, and not some speculation of a trader.
However, in flight from the subjectivity of market perception, traders and programmers have created hundreds of different technical indicators of levels, which, in one way or another, differ from each other.
A completely logical question arises, which of the presented indicators really draws real levels? In fact, levels are only those instruments that indicate the place where the stop orders of strong players are concentrated.
Trade big only with a leading broker
One of such an obvious place where major players concentrate is the lows and highs of the prices of the month and the week, since it is precisely the emphasis on these values that traders hardly overcome.
Actually, you will get acquainted with one of the scripts that makes it possible to see these levels on the chart in the article.
The Monthly Weekly Levels script is an educational tool technical analysis, which allows you to plot the minimum and maximum levels of the day or week on the chart of any time frame you choose.
The script itself can be safely used as an indicator of support and resistance levels. Therefore, Monthly Weekly Levels will be equally effective on all currency pairs or time frames, which makes it a truly multi-currency instrument.
Installing the Monthly Weekly Levels script
A notable feature of the Monthly Weekly Levels script is the fact that it is distributed completely free of charge. Moreover, the script itself, and the indicator in terms of functionality, was published in the official library of the developer of the trading terminal metatrader 4.
Thus, you have two options for installing this tool. The first, and it is the simplest, is through the built-in library directly in your trading terminal.
To implement this method, launch your trading platform and open a panel called "Terminal".
The next step is to perform a simple sort to enable displaying only scripts. In the list that appears, find the script called Monthly Weekly Levels, then download using the additional menu as shown in the image below:
If the installation of the script through the library was unsuccessful, you can install it in the second way, namely through the data directory of the trading terminal. To do this, go to the end of the article and download the script file.
Then just place the downloaded file in the appropriate folder of the terminal data directory, and in the Scripts folder. To trading platform could see the installed file it needs to be updated in the "Navigator" panel or just restart.
After updating the terminal, Monthly Weekly Levels will appear in the list of scripts, and in order for it to display information about the nearest levels, drag the symbol name onto the chart.
The principle of using the script
After you drag the script onto the chart, it will immediately display the lows and highs of the week, as well as the month, using horizontal lines on the chart.
It is worth noting that the script performs a one-time action, so after you add it to the chart, it will no longer update its data as the price changes.
So the green line shows the lows and highs of the weekly candle, and the yellow lines show the lows and highs of the monthly candle.
If we talk about the practice of application, the indicator is used like any other tool for trading from levels, or on their breakdown. Script type on the chart:
In the script settings, you can change the display of levels, line width, and so on. So, in the Number of Days line, you can set on the basis of how many days to display information on the chart.
The W1 Line Width variable you can set the line width, and in the W1 Collor Line line you can specify the line color.
Also, the script has the ability to display lines in solid or in pieces as seen on the chart. In order to change the display style, select the option you need in the Trend or Horizontal Line line.
In conclusion, it is worth noting that the Monthly Weekly Levels script is an excellent tool for automating the building of levels on the chart, moreover, the lines built by the script can be useful to all traders without exception.