In this video we are going to create a sell trailing stop that is triggered by the Average True Range indicator. So let’s find out how to do that with MQL 5. To get started please click on the little button here or Press F4 on your keyboard. Now you should see the Meta Editor window until you want to click on File, new File, Expert Advisor from Template, continue. I will call this file Simple Average True Range Sell Stop. Click on Continue, continue and finish. Now you can delete everything above the on tick function and let’s remove the two comment lines here. We start with an Include statement to include the file trade mqh. This one contains the class Ctrade and we are going to use an instance called Trade. Let’s set a basic variable for the stop loss points. We also need to calculate the stop point value and we use a global declaration for the bid price. And inside of the Ontick function we want to have a string variable for our signal. Now we are going to calculate the bid price. That is done by using symbol info double. For the current symbol on the chart we use symbol underscore bid. And with normalize double and underscore digits we can automatically calculate the right number of digits behind the dot depending on the currency pair. Now let’s create a price array. This is a double array and let’s define the Average True range here. That is done by using the IATR function that is included in MQL5. It uses a few parameters. The first one is for the current symbol on the chart, the second is for the selected period on that chart and we will calculate the result based on 14 candles. Now we use array set as series to sort our price array from the current candle downwards. And with copy buffer we fill our price array according to the definition that we have created here for buffer zero starting from the current candle zero and we want to copy the data for three candles and store them in the array. Now we can get the Average True Range value for the current candle by looking at candle zero in our price array. I use Normalize Double and Five to cut off five digits. Because that is how we see the Average True range indicator is shown on the chart. I also want to declare a static variable for the old value because I want to know if the current value is below the old value and if that is the case, we want to set our signal to sell and now we use trade sell. And if the signal equals Sell and positions total is below one, we have no open positions but a sell signal and that’s when we use Trade sell to sell it 10 microlot. This is a test position. We do it on a demo account because to trigger a sell trailing stop we need to have a position. And now we want to get the calculated stop point value by calling a user defined function called Check ATR Sell trailing stop. We pass the average true range value that we have calculated as a parameter. Now let’s add a chart output by using the comment statement. This will output the current signal, the average true range value, and the calculated stop point value. Afterwards we assign the average true range value to the old value for the next time. And that’s it for the main function. But this function doesn’t exist, so we need to create it right now. Our user defined function will have the name Check ATR Sell trailing stop. It gets the average true range value as a parameter here. We use this little formula to calculate the stop point value by using the defined basic stop point value and we will add this multiplication here. Now we are able to calculate the stop loss price. That is the current bid price plus the calculated stop point value times the point value. With the for loop we go through all the open positions to get the symbol of the current position we use Position get symbol for the current counter value. And if the current symbol on the chart equals the position symbol we want to continue. So let’s get the position ticket by using position get integer and the paramete...