MQL5 Tutorial - Advanced Trailing Stop
https://mql5tutorial.com
With MQL5 for Metatrader5 we create an Expert Advisor for multiple Trailing Stop Adjustments for several trades in one currency pair. That will enable you to protect your opened positions while you are not in front of your Forex Chart...
Introduction to Advanced Trailing Stop in MQL5 (00:00 – 00:14)
Overview of the advanced trailing stop feature in MQL5, with a demonstration of two open positions and their trailing stops.
Demonstration of Trailing Stops in Action (00:14 – 00:31)
Observing how the trailing stops adjust as the market price changes, with a focus on the stop's behavior when the price rises.
Opening Meta Editor for Expert Advisor Creation (00:31 – 01:04)
Instructions on opening the Meta Editor in MetaTrader 5 to create an expert advisor for trailing stops.
Setting Up the Expert Advisor in Meta Editor (01:04 – 01:20)
Steps to create a new expert advisor named "Advanced Trailing Stop" and initial setup in the Meta Editor.
Preparing the Expert Advisor Code (01:20 – 01:34)
Removing unnecessary code and including the 'trade.mqh' file for trading functions in the expert advisor.
Calculating the Ask Price and Setting Up Trades (01:34 – 01:48)
Coding to calculate the ask price and setting up conditions for opening buy positions.
Implementing the Trailing Stop Function (01:48 – 02:05)
Introduction to the trailing stop function and its implementation in the expert advisor.
Handling Multiple Positions with Trailing Stops (02:05 – 02:18)
Adjusting the expert advisor to handle multiple positions with individual trailing stops.
Creating the Check Trailing Stop Function (02:18 – 02:31)
Developing a function to check and adjust the trailing stop based on market conditions.
Defining Stop Loss and Position Checking (02:31 – 02:46)
Setting up the desired stop loss distance and checking open positions for the current symbol.
Modifying Stop Loss Based on Conditions (02:46 – 03:05)
Adjusting the stop loss for each position based on the trailing stop criteria.
Finalizing and Compiling the Expert Advisor (03:05 – 03:18)
Completing the coding of the expert advisor and compiling it in the Meta Editor.
Testing the Expert Advisor in MetaTrader 5 (03:18 – 03:31)
Instructions on how to test the newly created expert advisor in MetaTrader 5 using the Strategy Tester.
Observing the Trailing Stop in Live Action (03:31 – End)
Demonstrating the functionality of the advanced trailing stop in a live trading scenario within MetaTrader 5.
Today we are looking at the advanced trailing stop. We have two open positions here, and as you can see, we have two trailing stops. I will speed it up a little bit here and now our two stops have been triggered and our trailing stop is continually rising - if the price is going up. And if the trailing stop is below 150 points from the current ask price. So let's zoom in here and you can see what happens. Now the price is going up and you'll see the trading stop is rising and as the price falls nothing happens. But when it goes up again, you will also see the rising trailing stop here. Actually, it's two lines for two trailing stops. Now how can we create an expert advisor that is going to trail the stop loss for each of the open trades?
To do that, please click on the little button here or Press F4 to open the Meta Editor. And in the Meta editor, you want to click On File, new, Expert Advisor from Template. Continue. I will call this Expert Advisor advanced Trailing stop. Continue, continue, finish.
And now we can delete everything above the Ontick function and the two comment lines here. To use the trailing stop, we need an open trade, so let's include the trade MQ file here and create an instance of the class Ctrade. And in the Ontick function, we need to calculate the ask price. That is done with the function symbol info double, and we use normalize double and the expression digits to get the actual value for the currency. Because we have some currencies with three and other currencies with five digits behind the dot.
And we do that for the current symbol on the chart. And we use symbol underline Ask to get the ask price and put it into this double variable.
If you mark symbol underline Ask and press the F1 key, you will see that you can get lots of information. For example, symbol underline bid would deliver the bid price. In our example, we want the trailing stop to work for more than one position. So now we check if we have less than two opened positions, and if that is the case, we use our trade instance to open a buy position. It will have a stop loss of 1000 points, and it will have a take profit of 500 points above the ask price.
And now we want to call a function that will use the name Check trailing stop, and we deliver the ask price as a parameter here. This is the end of the Ontick function, and now we will create the function with the name check trailing stop.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «MQL5 Tutorial - Advanced Trailing Stop», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.