ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

MQL4 Tutorial - Simple Moving Average Crossover Expert Advisor

Programming

daytrading

trading

forex

mql4 reference

mql4 forum

jim dandy mql4 courses

mt4 indicatorcounted

mql4

mql4 tutorial

mql4 lessons

learn mql4

moving average

sma

simple moving average

expert advisor

ea

metatrader

metaeditor

metaquotes

onInit

onTick

Take Profit

Stop Loss

bilal haider

jimdandy1958

forex boat

Автор: MQL4Tutorial

Загружено: 2022-04-18

Просмотров: 17891

Описание: https://mql4tutorial.com

What you see on the chart is a yellow and a red line. The yellow line is a simple moving average for ten candles and the red line is a simple moving average for twenty candles. One of my MQL 5 channel subscribers with the name Alexander Lim wanted me to create a simple moving average crossover robot for MQL 4, and here it is. And when the yellow line crosses the red line from below it goes up. In the other case if the yellow line crosses from above it goes down. Now how can we create an Expert Advisor for that in MQL 4? To do that please click on the little button here or press the F4 key, that will bring up the Meta Editor. Let’s click on File, New Expert Advisor from template, Continue and we will call it simple as in a crossover, Continue, Continue and finish. Now we delete everything above the Ontick function and remove the two Comment lines here and the first thing we need is to create a slow moving average, this is done with the function IMA for the current chart and the current period on the chart, the period might be a one minute or an hourly chart.
We want to calculate the twenty last candles, we don't need any shift to the left or to the right and because we want to calculate a simple moving average we use the mode SMA that stands for Simple Moving Average and we want to calculate the close price of the candles and the slow moving average should be calculated for the current candle- this is candle zero. Now to find out if something has crossed we do it again for candle one, the rest is exactly the same. So now we can compare the last Slow Moving Average for the last candle with the current slow moving average for the current candle. Okay let's do the same for the other moving average, this one is based on the last ten candles and here we also want to calculate the fast moving average for the current candle and the last fast moving average for the candle before the current candle. And now we want to know if the last fast moving average was below the last slow moving average and if it's above the slow moving average now we want to use the comment function for the chart output of a buy signal.
Now we check if the last fast moving average was above the last slow moving average, and if the current fast moving average is below the slow moving average. In this case we want to output the word “Sell” on our chart. So let's click on the compile button here and that worked without any warnings or errors so now we can go back to Meta Trader by clicking this little button here or pressing the F4 key. Now we want to use a little trick because you don't see any moving averages here on the chart we click on Insert, Indicators trend, Moving Average, we want a moving average to be calculated for ten candles without any shift. It should be a simple moving average and it should have the colour yellow so let's click on okay here. And here it is.
Now we need another one, this time it should be calculated for twenty candles. Also no shift and simple, apply to the close price and it should be red, and here we are. Now please right click on your template, go to template, safe template and we want to save it as test.tpo because this is the template that is used by the Strategy Tester. And now you can click on View Strategy Tester or hit the control and the R key to bring up the Strategy Tester Panel here, the simple as an a crossover.ex4 file. So let's click on Start to start the test. Please make sure that you have activated the visual mode here and click on start, and here we are. Now we have a cross over here and that generated a buy signal and the cross over here generated the sell signal. Okay now you know how to create an Expert Advisor for two crossing moving averages and you have done it all with a few lines of MQL 4 code.

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
MQL4 Tutorial - Simple Moving Average Crossover Expert Advisor

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]