https://mql5tutorial.com/?s=sar
Introduction to Creating a Parabolic SAR Expert Advisor in MQL5 (00:00 – 00:31)
Introduction to the tutorial on automating the Parabolic SAR indicator using MQL5.
Opening MetaEditor and Creating a New Expert Advisor File (00:31 – 00:56)
Instructions on opening MetaEditor and creating a new Expert Advisor file named "SimpleParabolicSAREA".
Setting Up the Code Structure and Including Trade.mqh (00:56 – 01:22)
Removing unnecessary code and including the 'Trade.mqh' file for trading functions.
Calculating Ask and Bid Prices (01:22 – 01:58)
Using 'SymbolInfoDouble' to calculate the Ask and Bid prices and normalizing them for currency pair precision.
Creating a Variable for the Signal and Price Array (01:58 – 02:22)
Initializing a variable for the trading signal and creating an array for price data.
Defining Parabolic SAR Properties and Filling the Price Array (02:22 – 03:10)
Defining properties for the Parabolic SAR and using 'CopyRates' to fill the price array with data.
Determining Buy and Sell Signals Based on Parabolic SAR (03:10 – 03:34)
Setting conditions for buy and sell signals based on the Parabolic SAR value relative to the price.
Executing Trades Based on Signals (03:34 – 04:09)
Using 'trade.Sell' and 'trade.Buy' to execute trades based on the determined signals.
Creating Chart Output for the Signal (04:09 – 04:23)
Using the 'Comment' function to display the current trading signal on the chart.
Compiling the Code and Testing in MetaTrader (04:23 – 04:48)
Compiling the code and testing the Expert Advisor in MetaTrader using the Strategy Tester.
Observing the Parabolic SAR EA in Action on the Chart (04:48 – 05:17)
Watching the Expert Advisor trade the Parabolic SAR on the chart and analyzing its performance.
Conclusion and Further Learning Resources (05:17 – 06:25)
Conclusion of the tutorial and invitation to explore more videos and courses for further learning.
In this video, we are going to create this interesting Expert Advisor for the Parabolic SAR Indicator.
You see the little green points here, this is the signal, whenever the points are above the price that’s a sell signal and when they are below the price that’s a buy signal until the direction changes.
So let’s find out how to automate the Parabolic SAR with MQL5.
To do that please click on a 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 (template)” from template, “Continue”, I will call this file: “SimpleParabolicSAREA”, click on “Continue”, “Continue” and “Finish”.
Now you can remove everything above the “OnTick” function and the two comment lines here.
We start with an include statement to include the file: “Trade.mqh”, this one is included in MQL5 and it comes with trading functions that we are going to use to open our positions, so let’s create an instance of “CTrade” that will be called: “trade” and we are going to use it later.
Inside of the “OnTick” function we start by calculating the Ask price and the Bid price that is done by using “SymbolInfoDouble” for the current symbol on the chart, with “SYMBOL_ASK” – all in capital letters – we will get the Ask price and with “SYMBOL_BID” we would get the Bid price. “NormalizeDouble” and “_Digits” is used to calculate the number of digits behind the dot because “_Digits” stores the number of digits after the decimal point and depending on the currency pair that can be 3 digits or 5 digits.
Let’s create a variable for the signal we will also call it “signal” and we don't assign a value, that is going to be calculated later on.
First we need to create a price array for the prices on the chart that is done with “MqlRates”, we use “ArraySetAsSeries” for our price array (PriceArray) to sort it from the current candle downwards and now we need to fill the array (PriceArray) with price data hat is done by using “CopyRates” for the current symbol on the chart and the currently selected period.
By the way “_Symbol” and this symbol (Symbol()) is the same so we also could use “_Symbol” and the same is true for “_Period”, we start with the current candle 0 (zero) and we want to get the price data for 3 candles and store it in our price array (PriceArray).
Let’s create another array (mySARArray) for the Parabolic SAR Indicator, let's define (SARDefinition) what we are going to do, we use the “iSAR” function that comes with MQL5 for the current symbol on the chart and the currently selected period. So let’s find out about these two values here.
Смотрите видео LEARN MQL5 TUTORIAL BASICS - 23 HOW TO CODE A SIMPLE PARABOLIC SAR EXPERT ADVISOR онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь MQL5 Tutorial 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 9,618 раз и оно понравилось 127 людям.