21.03.2021

Script trading from horizontal lines. Trendline Expert Advisor


»

And it's all in one bottle. Well, for those for whom this is not enough, the adviser can work not only with layoffs, but also with ordinary market orders. You can quickly set the Stop loss and Take profit levels using the horizontal lines of the adviser, press one button and the order is placed with all the specified parameters! Well, isn't it a miracle? It just makes life incredibly easy. Here's what it looks like on a chart.
Multi-colored horizontal lines correspond to the desired levels of stop loss, take profit and the level of placing the pending order itself. By the way, the adviser itself determines which order needs to be placed - a limit (Buy Limit, Sell Limit) or a stop order (Buy Stop, Sell Stop), so if you are confused about the types of orders, then you have less of one more headache. And in order to better understand the differences between the types of pending orders, read and watch the video (new tab). The PLines button switches on the mode of placing a pending order, the Lines button - a market order. The Hide button removes the adviser's lines. Well, as already mentioned, the FastOrder Expert Advisor simplifies the opening of ordinary, market orders. Just set the stop loss and take profit lines to the desired levels, press the BUY or SELL button in the lower left corner and that's it, the order is opened with the specified parameters.

Unfortunately, there were some downsides. The downside is that for one currency pair you can open only one order using an adviser. This seems to be related to the MagicNumber setting in the settings. The FastOrder EA assigns this number to each order, and the flaw of the authors is that the EA cannot automatically change this number for the next order. Thus, when trying to open another order on the same currency pair, this order simply cannot be assigned a number, since it is already busy and it is not possible to open an order. But this minus can be bypassed if you add the Expert Advisor to the chart again and change one digit in the MagicNumber parameter, then you can place another order. This technique can be repeated as many times as you like, but the Expert Advisor's Close button will become unavailable for the previous order. But the loss is not great, the order can always be closed in the terminal itself by clicking on the cross.

The file is available for download only to registered users - Refresh this page after that, so that the download link appears

In general, the interface and settings are quite intuitive and I will not write a sheet of text describing each one, as this will only bore you. Instead, watch the video where I go into more detail on the settings and clearly show how to open orders using the Expert Advisor to set pending orders FastOrder. https://www.youtube.com/watch?v=NS7_v4C9Dy8

Profit to everyone! Subscribe and read our.


This is the second, more functional version semi-automatic Expert Advisor Trade From Lines trading from lines set by the user. The EA needs two lines for normal operation: one must be higher current price and the other below. The EA supports two types of lines: horizontal and trend lines. You can install two lines, both of the same type and different. You can draw a channel with lines and set up the trading of the adviser inside the channel: buy from the bottom, sell from the top. And you can organize trading on the breakdown of a certain price range up or down: buying from the upper line, selling from the lower one. In the second version, the offset of the input level relative to the line is implemented. It is set by the parameter OffsetTL in points and can be either positive or negative. And also in the second version, it became possible, at the request of the user, to automatically place stop reversal orders at the stop level of the position being opened. The setting of these orders is controlled by the parameter SetRevStopOrd. Since this is a semi-automatic adviser, we recommend that you use in the second window, the accompanying transaction adviser Integra NR

In the adviser, you can set following parameters:
NameUpLine="UPLine" - The name of the top line.
NameDnLine="DNLine" - The name of the bottom line.
BuyFromUp=False- Buy from the top line if True. Sell ​​if False.
BuyFromDn=True- Buy from the bottom line if True. Sell ​​if False.
OffsetTL=3- Offset of the trading level in points.
SetRevStopOrd=False- Place reverse stop orders at the stop level. opened position.
ShowComment=True- Show comments.
MarketWatch=True- Form trade requests for the execution of "Market Watch".
MagicNumber=20080320- Identifier of positions and orders of the adviser.
UseSound=True- Use a sound signal when making trades.
NameFileSound="expert.wav"- The name of the sound file.
Lots=0.1- The size of the traded lot.
StopLoss=30- Stop size in points.
TakeProfit=70- The size of the take in points.
slippage=3- Price slippage in points.
NumberOfTry=5- Number of trading attempts.

The Expert Advisor for trading on trend lines opens signals to make a deal (order) in case of contact between the price and the trend line. Trading is conducted on the principle of rebound. This means that when the price crosses the support line, a BUY order will open, and when the price touches the resistance line, a SELL order will open.

Interested in pullback trading? Choose the right robot and start

.

The program simultaneously monitors two lines that the trader sets up manually. Having marked the trend lines, the user needs to specify their names given in the Expert Advisor settings. After opening an order, the adviser adds its commentary to the trend line. Please note that if you do not remove this description, the program will not open an order at the right time.

The EA is suitable for online trading. More than one user can work on one currency pair, if each user has their own Magic_Number settings. To start working with the Expert Advisor, you need to set trend lines and name them according to the Support_Line_Name and Resistance_Line_Name parameters. Note that it is not necessary to use two lines at the same time. If one is missing, this will be normally perceived by the program and will not bring failures.

Do you want to download a robot for efficient trading? Use our site

Trend lines are considered the most convenient and effective method for determining the current trend in the Forex market. The tool is suitable for identifying profitable trade entry points, and due to the simplicity of the trend line, it is possible to use the market reversal to your advantage. To ensure that your trading activity is not accompanied by unnecessary difficulties, use trading advisors. This is a universal assistant that you can use when compiling any currency pairs. For its free download, our Forex-portal is at your service. Here you will find a lot of useful thematic information and trading robots to simplify the automation of many processes. Waiting for you.

If you are interested in using Fractals effectively, then you should consider using an Expert Advisor.

Settings:

Support_Line_Name ="SP" – Support line name
Resistance_Line_Name = "RS" - Resistance line name
It is by these names that the Expert Advisor will determine which lines it will work with.
Invers_Orders = false – Invert trades. If this parameter is enabled (true), then a Buy order will open on the resistance line instead of a Sell order, and a Sell order will open on the support line instead of a Buy order.
SL = 50 – Stoploss size in points.
TP = 50 - The amount of takeprofit in points.
Lot = 0.1 – volume of positions opened by the expert.
Show_Alert = true if the parameter is enabled, signals about the opening of a position.
Magic_Number = 818798 – unique expert ID.

Place horizontal lines on the chart and name them “BUY” (for the first buy order) and/or “SELL” (for the first sell order).

As soon as the closing price of the bar (of the previous one) becomes higher than the “BUY” line, a BUY order is placed (for a sell order, the closing price of the bar must be below the “SELL” line)

Next, the averaging lines come into play. They can have any name and be located anywhere on the chart. They do not need to be renamed, the adviser will understand which lines are needed for what. If the horizontal line is higher than the buy order, then it will delete it, and if it is lower, it will consider it as its averaging one. At the same time, it will recolor it blue and make it dotted. The averaging line is the line where the order will be opened with a lot increased by the coefficient K. Further, the adviser will recalculate the take profit of all orders and set it at the distance of the total breakeven.

Work example:

We put a line and call it Sell.

The price crossed the line and as soon as the candle 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 along with setting the first line). There can be any number of averaging lines.

As soon as the candle 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 mark) moved higher and the take profits of both orders were also recalculated.

You can use the adviser as strategy tester, to do this, it must be put in a tester with visualization at low speed. Next, hang the necessary indicators there and set the necessary lines along the way. Thus, you can test almost any strategy on history without ordering the development of specialized advisors.

A script is a small program that performs a one-time action.
Unlike advisors or indicators that work constantly, the script performs its function and turns off.
In MT4, Scripts are located in the Navigator window after indicators and Expert Advisors.
Expand the list with Scripts by clicking on the + next to the section.

In order to run the script, it is enough to transfer it to the chart currency pair.
We hold the desired script with the left mouse button, drag it to the chart and release it.
After performing its function, the script will automatically be deleted from the chart.
Some scripts have terms of use.

For example: execute the function when the price is 1.3500 or execute the function on 20.08.2014 at 15.30.
Such scripts remain active on the chart and wait for the conditions to be met.
But if you need to stop the script, just right-click on the chart and Delete script.

In order to add new scripts (you can download them at the end of the article), run Metatrader 4.
In the terminal, press File -> Open Data Directory.

A directory with MT4 files will open.
We need a section MQL4 to catalog Scripts.

Copy the script files that you downloaded.
Then close the folder and restart Metatrader terminal 4.
When the terminal opens, press Ctrl+O.
In the settings window, select the tab Advisors and set permission for automatic trading.

Now in the Navigator window the list with Scripts has been replenished.
But they do not work and do not react in any way to dragging a currency pair onto the chart.
And marked with a gray diamond.

Script files are in the original MQL4 SourceFile format ( .mq4), and the terminal works with “EX4” files ( .ex4)
Need to convert/compile mq4 to ex4.
To do this, right-click on the script and select Change.

The program will open MetaEditor where you want to click the button Compile and close MetaEditor.

Now in the MT4 terminal in the navigation the script is marked with a yellow rhombus and can be used on the chart.

Such a simple operation must be done with all scripts of the format ( .mq4).

As you can see, everything is very fast and easy.

There are some useful scripts in the archive at the end of the article.
They will help you if you work with advisors or trade hands.

  • Two information scripts AccountInfo.mq4 and MarketInfo.mq4 files that display all the information about the account and the full specification of the instrument.

  • Script Trend_Line.mq4 draws trend lines on a currency pair chart. It is necessary to drag the script onto the chart, and depending on what time point the script was dropped to, how the script will plot the lines depends.

Scripts:

  • CloseAllLosses.mq4 - Closes all trades with a loss at the moment.
  • CloseAllOrders.mq4 - Closes all trades
  • CloseAllProfit.mq4 - Closes all trades with a profit at the moment.

Useful scripts, but the main thing here is not to confuse them. 🙂

  • SimulateTick.ex4 - the script is indispensable when working with advisors on weekends. When dropped on a chart, it sends one tick to it. Why is such a miracle necessary?

The usual situation: I attach the adviser to the chart on the weekend. Almost all Expert Advisors start on the first price tick. The next tick will only be on Monday. And I want the adviser to show an information window right now to check that everything is OK. This is where SimulateTick comes to the rescue.

  • Script put_market_order 3.0 opens an order for market price with a given lot, take, stop, comment and magic number, which is seen by advisers.
  • Script put_pending_order 3.0 opens a pending order at a specified price with a specified lot, take, stop, comment and magic number, which is visible to the advisers.

Settings:

direction: order direction (Direction = 1 buy order, -1 sell order).
StopLossPips and TakeProfitPips: stop loss and take profit orders in points (if 0, then disabled).
stop loss and take profit: explicit setting of stop loss and take profit of the order (if 0, then disabled).
lot size: order lot size.
Magic: order magic.
comment: order comment.

In script put_pending_order 3.0 when placing an order below or above the price, the script automatically places BuyLimit or buy stop if the parameter Direction:1 and SellLimit or SellStop if the parameter Direction:-1.

You can create ready-made settings with the given parameters and the required Magic number, or compile the script with different settings separately.
Why is it necessary?
A common situation: your adviser did not place or open an order due to a failure on the vps server. Orders opened by hands are not seen by Expert Advisors. This is where the put_market_order 3.0 or put_pending_order 3.0 script comes to the rescue. You can open an order with a Magic number and your Expert Advisor will accompany him further.

Magics are also convenient for manual trading. For example, you trade several strategies on one account. For each strategy, you can use your magic. Then the results of each strategy can be easily analyzed, for example, using the myfxbook service or the free one.

Few people know that scripts in the MT4 terminal can be assigned hotkeys. This is done very simply. Select the script in the Scripts section of the Navigator window, click right mouse button, select " Assign hot key” and select the desired key combination.

For manual scalping on a small timeframe, a delay of several seconds can be critical. In such a situation, it is desirable that the script put trading order by pressing a combination of hot keys without further questions. With the help of simple manipulations, the attached scripts can be configured in this way. I'll tell you how to do this using the put_market_order script as an example. Select the put_market_order script in the Scripts section of the Navigator window, click right mouse button, choose " Change". The MetaEditor window opens. In it we find the line

#property show_inputs

and comment on it, i.e. replace with

//#property show_inputs

In the following lines, we set the desired parameter values ​​with which the script will be launched. For example, we want to open an order to buy 0.2 lots without stop loss and take profit. Then we change only Direction and LotSize:

extern int Direction = 1;
extern double LotSize = 0.2;

All! Click Save(Control+S) and Compile. Now our script will be launched by pressing the hotkey and will instantly place an order to buy 0.2 lots without any questions. Separately, you can make a script for sell orders, name the scripts accordingly and assign them different hotkeys. To make changes to the settings, you need to change the script code again and compile it again.

For more details on how this is done, see the video:

Download: a selection of indispensable scripts


2022
ihaednc.ru - Banks. Investment. Insurance. People's ratings. News. Reviews. Credits