התחל במצב לא מקוון עם האפליקציה Player FM !
MQL4 TUTORIAL BASICS – 114 SIMPLE SHIFTED PRICE EA
סדרה בארכיון ("עדכון לא פעיל" status)
When? This feed was archived on December 18, 2021 00:33 (). Last successful fetch was on October 24, 2021 04:05 ()
Why? עדכון לא פעיל status. השרתים שלנו לא הצליחו לאחזר פודקאסט חוקי לזמן ממושך.
What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.
Manage episode 298896819 series 1615247
[This post contains video, click to play]
In this video, we are going to create an Expert Advisor that is able to trade price data from a shifted line chart. So let’s see how that can be done with MQL4. To get started, please click on a little icon 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 shifted price EA, click on Continue, continue and finish.
Now you can delete everything above the Ontick function and the two comment lines here. We start by creating a string variable called signal. What? We are not going to assign a value here because we want to calculate the signal later on. In the next step, we are going to use the integrated. IMA function that comes with MQL5, for the current symbol on the chart and the currently selected period. I would like to calculate an SMA for one candle and that should be drawn twenty candles ahead of the current time.
We are using mode SMA, the result should be calculated based on the close price. And this last one here is the candle number, we are going to calculate it for the current Candle zero. Well, when you cut this out here, you will see that the value is called MA shift. The last one here is also a shift value, and it’s hard to understand for beginners. But this shift value here is the one to draw the values on the chart.
And this shift value at the end is used to define for which candle you want to do that. Actually, this line chart here is the same as the simple moving average that we draw into the future. You can see the identical movements here and now we can check if the moving average value is below the close price for Candle zero. If that is the case, we consider that to be a Buy signal. So we assign the word buy to our signal.
In the other case, if the moving, average, value is bigger than the close price for Candle zero, that would be a Sell signal and that’s when we assign sell to our signal. And if our signal equals buy and the return value for OrdersTotal is zero, that would mean we have no open orders and a buy signal. And that’s when we use Ordersend to buy 10 Microlot. Otherwise, if the signal equals sell and OrdersTotal is also zero, that means we have no open orders and a sell signal and that’s when we use Ordersend to sell 10 Microlot.
Finally, I would like to add a comment output for the chart. That will show us the text “the current signal is” followed by the calculated signal. That’s about it. If this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos in this basic video series, or maybe even the Premium Course on our website might be interesting for you. That’s why we also have links to the shop to download source codes like this one.
But for now, please click on the Compile button or press F7 on your keyboard. You shouldn’t get any errors here. And if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader, please pick an empty chart, switch to the line chart view, that can be done by pressing ALT and 3, or clicking the little button here. So you have a single line chart, now.
Now, right click into the chart, select template, save template and save it as tester.tpl. You can override the current one. Tester.tpl is what we will see when we start the strategy tester. So let’s do that and click on View, strategy tester or press Control and R. Please pick the new file. Simple shifted price .EX4, mark the option for the Visual mode and start your test. Now you will see that the second moving average is not shown on the chart.
So let’s stop the test. And here it is. Now right click again. Select Template, save template and save this one as tester.tpl. And when you restart the test, you will see now are both lines on the chart. Currently we have a buy signal and this is our first position. Let’s speed that up a little bit. And once we see a cross over, the signal is now switching to sell, so our little Expert Advisor is working.
And in this little video, you have learned how to create an Expert Advisor for line charts that are based on price data. And you have coded it yourself with a few lines of MQL4 code.

Not sure what to do? Click on the automated trading assistant below

- MQL4 TUTORIAL BASICS - 65 SIMPLE BACKGROUND COLOR In this video we are going to create an expert…
- MQL4 TUTORIAL BASICS - 105 SIMPLE SELL GRID SYSTEM In this video, we are going to create a…
- MQL4 TUTORIAL BASICS - 94 SIMPLE SPREADSHEET FILE WRITER In this video we are going to create an…
- MQL4 TUTORIAL BASICS - 63 SIMPLE CHECK FOR NEW BARS In this video we are going to create an expert…
- MQL4 TUTORIAL BASICS - 80 SIMPLE SPREAD CHECKER In this video, we will create an expert advisor that…
- MQL4 TUTORIAL BASICS - 66 SIMPLE SHIFTED EMA In this video, we are going to create an expert…
- MQL4 TUTORIAL BASICS - 17 HOW TO PLACE A SELL STOP In this video we are going to set a sell…
- MQL4 TUTORIAL BASICS - 90 SIMPLE LOW PRICE TREND LINE OBJECT In this video we are going to draw a line…
- MQL4 TUTORIAL BASICS - 15 HOW TO SET A BUY STOP In this video we are going to set a buy…
- MQL4 TUTORIAL BASICS - 67 SIMPLE VERTICAL LINE In this video we are going to create an expert…

The post MQL4 TUTORIAL BASICS – 114 SIMPLE SHIFTED PRICE EA appeared first on MQL4TUTORIAL.COM.
32 פרקים
סדרה בארכיון ("עדכון לא פעיל" status)
When? This feed was archived on December 18, 2021 00:33 (). Last successful fetch was on October 24, 2021 04:05 ()
Why? עדכון לא פעיל status. השרתים שלנו לא הצליחו לאחזר פודקאסט חוקי לזמן ממושך.
What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.
Manage episode 298896819 series 1615247
[This post contains video, click to play]
In this video, we are going to create an Expert Advisor that is able to trade price data from a shifted line chart. So let’s see how that can be done with MQL4. To get started, please click on a little icon 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 shifted price EA, click on Continue, continue and finish.
Now you can delete everything above the Ontick function and the two comment lines here. We start by creating a string variable called signal. What? We are not going to assign a value here because we want to calculate the signal later on. In the next step, we are going to use the integrated. IMA function that comes with MQL5, for the current symbol on the chart and the currently selected period. I would like to calculate an SMA for one candle and that should be drawn twenty candles ahead of the current time.
We are using mode SMA, the result should be calculated based on the close price. And this last one here is the candle number, we are going to calculate it for the current Candle zero. Well, when you cut this out here, you will see that the value is called MA shift. The last one here is also a shift value, and it’s hard to understand for beginners. But this shift value here is the one to draw the values on the chart.
And this shift value at the end is used to define for which candle you want to do that. Actually, this line chart here is the same as the simple moving average that we draw into the future. You can see the identical movements here and now we can check if the moving average value is below the close price for Candle zero. If that is the case, we consider that to be a Buy signal. So we assign the word buy to our signal.
In the other case, if the moving, average, value is bigger than the close price for Candle zero, that would be a Sell signal and that’s when we assign sell to our signal. And if our signal equals buy and the return value for OrdersTotal is zero, that would mean we have no open orders and a buy signal. And that’s when we use Ordersend to buy 10 Microlot. Otherwise, if the signal equals sell and OrdersTotal is also zero, that means we have no open orders and a sell signal and that’s when we use Ordersend to sell 10 Microlot.
Finally, I would like to add a comment output for the chart. That will show us the text “the current signal is” followed by the calculated signal. That’s about it. If this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos in this basic video series, or maybe even the Premium Course on our website might be interesting for you. That’s why we also have links to the shop to download source codes like this one.
But for now, please click on the Compile button or press F7 on your keyboard. You shouldn’t get any errors here. And if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader, please pick an empty chart, switch to the line chart view, that can be done by pressing ALT and 3, or clicking the little button here. So you have a single line chart, now.
Now, right click into the chart, select template, save template and save it as tester.tpl. You can override the current one. Tester.tpl is what we will see when we start the strategy tester. So let’s do that and click on View, strategy tester or press Control and R. Please pick the new file. Simple shifted price .EX4, mark the option for the Visual mode and start your test. Now you will see that the second moving average is not shown on the chart.
So let’s stop the test. And here it is. Now right click again. Select Template, save template and save this one as tester.tpl. And when you restart the test, you will see now are both lines on the chart. Currently we have a buy signal and this is our first position. Let’s speed that up a little bit. And once we see a cross over, the signal is now switching to sell, so our little Expert Advisor is working.
And in this little video, you have learned how to create an Expert Advisor for line charts that are based on price data. And you have coded it yourself with a few lines of MQL4 code.

Not sure what to do? Click on the automated trading assistant below

- MQL4 TUTORIAL BASICS - 65 SIMPLE BACKGROUND COLOR In this video we are going to create an expert…
- MQL4 TUTORIAL BASICS - 105 SIMPLE SELL GRID SYSTEM In this video, we are going to create a…
- MQL4 TUTORIAL BASICS - 94 SIMPLE SPREADSHEET FILE WRITER In this video we are going to create an…
- MQL4 TUTORIAL BASICS - 63 SIMPLE CHECK FOR NEW BARS In this video we are going to create an expert…
- MQL4 TUTORIAL BASICS - 80 SIMPLE SPREAD CHECKER In this video, we will create an expert advisor that…
- MQL4 TUTORIAL BASICS - 66 SIMPLE SHIFTED EMA In this video, we are going to create an expert…
- MQL4 TUTORIAL BASICS - 17 HOW TO PLACE A SELL STOP In this video we are going to set a sell…
- MQL4 TUTORIAL BASICS - 90 SIMPLE LOW PRICE TREND LINE OBJECT In this video we are going to draw a line…
- MQL4 TUTORIAL BASICS - 15 HOW TO SET A BUY STOP In this video we are going to set a buy…
- MQL4 TUTORIAL BASICS - 67 SIMPLE VERTICAL LINE In this video we are going to create an expert…

The post MQL4 TUTORIAL BASICS – 114 SIMPLE SHIFTED PRICE EA appeared first on MQL4TUTORIAL.COM.
32 פרקים
כל הפרקים
×ברוכים הבאים אל Player FM!
Player FM סורק את האינטרנט עבור פודקאסטים באיכות גבוהה בשבילכם כדי שתהנו מהם כרגע. זה יישום הפודקאסט הטוב ביותר והוא עובד על אנדרואיד, iPhone ואינטרנט. הירשמו לסנכרון מנויים במכשירים שונים.