Przejdź do trybu offline z Player FM !
MQL5 TUTORIAL – SIMPLE ITEMA EXPERT ADVISOR
Manage episode 370800261 series 1376757
Introduction to ITEMA Expert Advisor (00:00 – 00:11)
- Introduction to the ITEMA Indicator, specifically the Triple Exponential Moving Average Indicator, with a focus on the red line representing the indicator.
Explanation of ITEMA Indicator and Strategy Test (00:11 – 00:34)
- Detailed explanation of the Triple Exponential Moving Average, its calculation based on 14 candles, and the goal to create an Expert Advisor for it.
Setting Up in MetaEditor (00:34 – 01:07)
- Instructions for opening MetaEditor in MetaTrader and creating a new Expert Advisor file named ‘Simple ITEMA’. Initial setup and code preparation.
Creating and Sorting Price Array (01:07 – 01:49)
- Steps to create a price array using ‘MqlRates’, sorting it with ‘ArraySetAsSeries’, and filling it for 3 candles using ‘CopyRates’.
Setting Up EA Data Array and ITEMA Definition (01:49 – 02:33)
- Creating and sorting an array for the Expert Advisor data (EAArray). Defining the ITEMA Expert Advisor using the ‘iTEMA’ function.
Configuring ITEMA Indicator Parameters (02:33 – 03:27)
- Setting up parameters for the ITEMA indicator, including the currency pair, period, shift value, and price type. Using ‘CopyBuffer’ to fill the EAArray.
Calculating ITEMA Value and Outputting Signals (03:27 – 04:59)
- Calculating the ITEMA value for the current candle and creating chart outputs for ‘SHORT’ and ‘LONG’ signals based on the ITEMA value and close price.
Compiling and Testing the Expert Advisor (04:59 – 05:27)
- Instructions for compiling the Expert Advisor in MetaEditor and testing it in MetaTrader using the Strategy Tester.
Adjusting Signal Frequency and Quality (05:27 – 06:39)
- Adjusting the shift value for candles to reduce signal frequency and improve signal quality. Recompiling and retesting the Expert Advisor.
Conclusion and Demonstration (06:39 – 06:47)
- Conclusion of the tutorial with a demonstration of the Expert Advisor in action, showing improved signal quality with fewer signals.
Please let me know if you need any further details or adjustments to this format.
This time we are talking about the ITEMA Indicator. This is for the Triple Exponential Moving Average Indicator. You see this red line here. If we pass the strategy test and hover over the red line you will see that it is called the Triple Exponential Moving Average and its calculated based on 14 candles.
In this video we are going to find out how to create an Expert Advisor to calculate a Triple Exponential Moving Average Indicator and how to improve the frequency of the signals that are created.
To do that please click the little button here in your Metatrader or press F4 on your keyboard and now you should see the Metaeditor window and here you want to click on “File -New -Expert Advisor” from template (template), Continue (Next). I will call this one: “Simple ITEMA” (SimpleITEMA). Click on continue, continue and finish.
Now everything above the “OnTick” function can be removed, let’s also delete the two comment lines.
First we need to create an array for the prices, that’s done by using “MqlRates” and the array will be called: “PriceArray”. We use the MQL5 built-in function “ArraySetAsSeries” to sort the price array from the current candle downwards and with “CopyRates” we fill the array for 3 candles. That’s enough to calculate the current candle and calculate crossovers. “CopyRates” takes a few parameters, first one is the symbol parameter – that’s for the current currency pair on the chart – the second one is for the currently selected period on the chart. We start with candle zero; that’s the current candle, copy the data for 3 candles and store it in the price array.
In the next step we to create another array for the Expert Advisor data, that will be called “EAArray” and the Expert Advisor array also need to be sorted by using “ArraySetAsSeries”.
Now it’s time to actually define the ITEMA Expert Advisor. That is done by using the built-in function: “iTEMA”, it takes a few parameters: the first one once again is the currency pair on the chart, the second one is once again the selected period on the chart, these are 14 candles because if you click on “Insert -Indicators -Trend -Triple Exponential Moving Average” you will see that the default value for the built-in indicator also is 14 candles. We use a shift value of 0 here and it applies to the close price, so that’s what we are using here: shift value 0 and “PRICE_CLOSE “. Now that we have created the definition we use “CopyBuffer” for the ITEMA definition (iTEMADefinition) we have created here. The 0 is for the first buffer, this 0 stands for the current candle, the 3 is to copy 3 candles and we want to save it in the array called: “EAArray”. Now that we have done that we calculate the ITEMA value (ITEMAVALUE) for the current candle 0 in our array. I use float, usually it’s a double and if you press F1 you will see that a double variable is 8 bytes in size, a float variable only takes half of the size and it’s better to read for us humans. So, let’s create a chart output depending on the direction. If the ITEMA value is bigger than the close price of the first candle in the price array – remember the first candle is always this one, this is candle zero, candle one, candle two and so on – so, if this expression is true we use the “Comment” function to output the text: “iTEMA IS SHORT”, followed by the calculated ITEMA value. In the other case if the close price for candle one in our price array is above the ITEMA value we will output: “iTEMA IS LONG”, also followed by the value.
Okay, that’s it.
When you are done you can click on the compile button here, we get a warning that says that we have a possible loss of data due to type conversion, that’s because I used a float variable here but for this little Expert Advisor that is okay. So, if the compilation works without any errors you can click the little button here or press F4 to go back to Metatrader.
In Metatrader please click on “View -Strategy Tester” or press CTRL and R and now you should select the file: SimpleITEMA.ex5, mark the visualization option here and start a test.
This is how our Expert Advisor looks like, you see it saying: “iTEMA IS SHORT “or “iTEMA IS LONG”.
The frequency of the signals is much too high, so let’s fix that!
We go back into the Metaeditor and change the shift value for the candles to 100 candles. Let’s recompile the code, press F4, stop the current test and start a new one!
This is how it looks like, just press the minus key a few times and now you see that the indicator is calculated 100 candles before the price and whenever the price is crossing here we will get another signal. Let’s speed that up a little bit, now we are getting much fewer signals but the signal quality is better!
Okay. That’s it!
Now you know how to create an Expert Advisor for a Simple Triple Exponential Moving Average Indicator and you have coded it yourself with a few lines of MQL5 code.
The post MQL5 TUTORIAL – SIMPLE ITEMA EXPERT ADVISOR appeared first on MQL5 Tutorial.
27 odcinków
Manage episode 370800261 series 1376757
Introduction to ITEMA Expert Advisor (00:00 – 00:11)
- Introduction to the ITEMA Indicator, specifically the Triple Exponential Moving Average Indicator, with a focus on the red line representing the indicator.
Explanation of ITEMA Indicator and Strategy Test (00:11 – 00:34)
- Detailed explanation of the Triple Exponential Moving Average, its calculation based on 14 candles, and the goal to create an Expert Advisor for it.
Setting Up in MetaEditor (00:34 – 01:07)
- Instructions for opening MetaEditor in MetaTrader and creating a new Expert Advisor file named ‘Simple ITEMA’. Initial setup and code preparation.
Creating and Sorting Price Array (01:07 – 01:49)
- Steps to create a price array using ‘MqlRates’, sorting it with ‘ArraySetAsSeries’, and filling it for 3 candles using ‘CopyRates’.
Setting Up EA Data Array and ITEMA Definition (01:49 – 02:33)
- Creating and sorting an array for the Expert Advisor data (EAArray). Defining the ITEMA Expert Advisor using the ‘iTEMA’ function.
Configuring ITEMA Indicator Parameters (02:33 – 03:27)
- Setting up parameters for the ITEMA indicator, including the currency pair, period, shift value, and price type. Using ‘CopyBuffer’ to fill the EAArray.
Calculating ITEMA Value and Outputting Signals (03:27 – 04:59)
- Calculating the ITEMA value for the current candle and creating chart outputs for ‘SHORT’ and ‘LONG’ signals based on the ITEMA value and close price.
Compiling and Testing the Expert Advisor (04:59 – 05:27)
- Instructions for compiling the Expert Advisor in MetaEditor and testing it in MetaTrader using the Strategy Tester.
Adjusting Signal Frequency and Quality (05:27 – 06:39)
- Adjusting the shift value for candles to reduce signal frequency and improve signal quality. Recompiling and retesting the Expert Advisor.
Conclusion and Demonstration (06:39 – 06:47)
- Conclusion of the tutorial with a demonstration of the Expert Advisor in action, showing improved signal quality with fewer signals.
Please let me know if you need any further details or adjustments to this format.
This time we are talking about the ITEMA Indicator. This is for the Triple Exponential Moving Average Indicator. You see this red line here. If we pass the strategy test and hover over the red line you will see that it is called the Triple Exponential Moving Average and its calculated based on 14 candles.
In this video we are going to find out how to create an Expert Advisor to calculate a Triple Exponential Moving Average Indicator and how to improve the frequency of the signals that are created.
To do that please click the little button here in your Metatrader or press F4 on your keyboard and now you should see the Metaeditor window and here you want to click on “File -New -Expert Advisor” from template (template), Continue (Next). I will call this one: “Simple ITEMA” (SimpleITEMA). Click on continue, continue and finish.
Now everything above the “OnTick” function can be removed, let’s also delete the two comment lines.
First we need to create an array for the prices, that’s done by using “MqlRates” and the array will be called: “PriceArray”. We use the MQL5 built-in function “ArraySetAsSeries” to sort the price array from the current candle downwards and with “CopyRates” we fill the array for 3 candles. That’s enough to calculate the current candle and calculate crossovers. “CopyRates” takes a few parameters, first one is the symbol parameter – that’s for the current currency pair on the chart – the second one is for the currently selected period on the chart. We start with candle zero; that’s the current candle, copy the data for 3 candles and store it in the price array.
In the next step we to create another array for the Expert Advisor data, that will be called “EAArray” and the Expert Advisor array also need to be sorted by using “ArraySetAsSeries”.
Now it’s time to actually define the ITEMA Expert Advisor. That is done by using the built-in function: “iTEMA”, it takes a few parameters: the first one once again is the currency pair on the chart, the second one is once again the selected period on the chart, these are 14 candles because if you click on “Insert -Indicators -Trend -Triple Exponential Moving Average” you will see that the default value for the built-in indicator also is 14 candles. We use a shift value of 0 here and it applies to the close price, so that’s what we are using here: shift value 0 and “PRICE_CLOSE “. Now that we have created the definition we use “CopyBuffer” for the ITEMA definition (iTEMADefinition) we have created here. The 0 is for the first buffer, this 0 stands for the current candle, the 3 is to copy 3 candles and we want to save it in the array called: “EAArray”. Now that we have done that we calculate the ITEMA value (ITEMAVALUE) for the current candle 0 in our array. I use float, usually it’s a double and if you press F1 you will see that a double variable is 8 bytes in size, a float variable only takes half of the size and it’s better to read for us humans. So, let’s create a chart output depending on the direction. If the ITEMA value is bigger than the close price of the first candle in the price array – remember the first candle is always this one, this is candle zero, candle one, candle two and so on – so, if this expression is true we use the “Comment” function to output the text: “iTEMA IS SHORT”, followed by the calculated ITEMA value. In the other case if the close price for candle one in our price array is above the ITEMA value we will output: “iTEMA IS LONG”, also followed by the value.
Okay, that’s it.
When you are done you can click on the compile button here, we get a warning that says that we have a possible loss of data due to type conversion, that’s because I used a float variable here but for this little Expert Advisor that is okay. So, if the compilation works without any errors you can click the little button here or press F4 to go back to Metatrader.
In Metatrader please click on “View -Strategy Tester” or press CTRL and R and now you should select the file: SimpleITEMA.ex5, mark the visualization option here and start a test.
This is how our Expert Advisor looks like, you see it saying: “iTEMA IS SHORT “or “iTEMA IS LONG”.
The frequency of the signals is much too high, so let’s fix that!
We go back into the Metaeditor and change the shift value for the candles to 100 candles. Let’s recompile the code, press F4, stop the current test and start a new one!
This is how it looks like, just press the minus key a few times and now you see that the indicator is calculated 100 candles before the price and whenever the price is crossing here we will get another signal. Let’s speed that up a little bit, now we are getting much fewer signals but the signal quality is better!
Okay. That’s it!
Now you know how to create an Expert Advisor for a Simple Triple Exponential Moving Average Indicator and you have coded it yourself with a few lines of MQL5 code.
The post MQL5 TUTORIAL – SIMPLE ITEMA EXPERT ADVISOR appeared first on MQL5 Tutorial.
27 odcinków
Wszystkie odcinki
×Zapraszamy w Player FM
Odtwarzacz FM skanuje sieć w poszukiwaniu wysokiej jakości podcastów, abyś mógł się nią cieszyć już teraz. To najlepsza aplikacja do podcastów, działająca na Androidzie, iPhonie i Internecie. Zarejestruj się, aby zsynchronizować subskrypcje na różnych urządzeniach.