In this video we are going to create a sell stop for this parabolic sar indicator, so let’s find out how to do that with mql5. To get started please click on the little button here or press F4 on your keyboard now you should see the Metaeditor window and here you want to click on file, new file, expert advisor from template, continue, I will call this file simple sar sell trailing stop, click on continue, continue and finish. Now you can delete everything above the on tick function and the two comment lines here, we start with an include statement to include the file trade dot mqh, afterwards we create an instance of the class ctrade that will be called trade and we needed to open a test position, so that we have something where we can place the trailing stop. As we are talking about a sell trailing stop we need 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 – all in capital letters – and with normalize double and underscore digits we make sure that we have the right number of digits behind the dot. Depending on the currency pair that could be either three digits or five digits and now we want to check if the number of current positions is below one, so if we don’t have any open positions we use trade dot sell to open a sell position for ten micro lot. Please remember we only do this on a demo account, we wouldn’t do that on a real account. Now let’s create an array and once that is done we use the integrated function isar for the current symbol on the chart and the currently selected period on that chart and these two parameters here are what we see if you click on insert, indicators, trend, parabolic sar, here we have a step value of zero point zero two and a max value of zero point two, so let’s click on ok, right-click into the chart, select templates, save template and save it as tester dot tpl because this is the template that we are going to use in the strategy test, so let’s click on ok, we can replace the old value here and go back to the Metaeditor, so let’s use array set as series to sort the array from the current candle downwards and in the next step we can use copy buffer to fill our sar array according to the sar definition that we have created here. We fill it for buffer zero – that’s the first indicator line – in our case that’s the dotted line here, and we fill it from candle zero for three candles and store the results in our sar array because that makes it possible to calculate the current sar value by looking into candle zero in our sar array and with normalize double and comma five we make sure that the value will be calculated according to the definition of the parabolic sar. You see here is the value zero point eight eight nine nine seven, that’s five digits behind the dot and that’s also what we get when we do it this way. And the last part of the on tick function is to call a function called check sar sell trailing stop, this one doesn’t exist so far so we need to code it now and we will pass the bid price and the sar value as parameters. So this is the function, it is called check sar sell trailing stop, we take the two parameters here, the first one for the bid price is a double value and that’s also true for the second parameter the sar value. Now we use a for loop to go through all the open positions, first we use position get symbol for the current counter value to get the currency for the current position, afterwards we want to check if the current symbol on the chart and the position symbol are equal, and if that is the case we use position get integer and position underscore ticket – all in capital letters – to get the ticket number for the position. We use position get double, position underscore sl to get the current stop loss and we only want to modify our stop loss if the current stop loss is above the current sar value or if the current stop loss equals zero,