Evgeny Zhdan - Expert advisor for MT4 for one evening

Здесь есть возможность читать онлайн «Evgeny Zhdan - Expert advisor for MT4 for one evening» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. ISBN: , Жанр: russian_contemporary, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Expert advisor for MT4 for one evening: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Expert advisor for MT4 for one evening»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

The reader along with the author will independently write an advisor for the MetaTrader-4 trading terminal. The book describes the basic actions that are performed when developing 95% of trade experts. Thanks to the knowledge gained, immediately after reading the book the reader will be able to write a simple expert himself.

Expert advisor for MT4 for one evening — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Expert advisor for MT4 for one evening», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать
Lets make a brief design specification If the upper peak of the ZigZag - фото 2

Let’s make a brief design specification:

– If the upper peak of the ZigZag indicator (hereinafter – ZZ) is generated above the upper line of the Envelopes indicator (with the parameter Shift = 10, with the standard others), we should make a sell order with a fixed lot set in the Advisor’s settings.

– If the lower ZZ peak is generated below the lower Envelopes one – a buy order (i.e., vice versa compared to the buy signal).

– By modification (we’ll examine later while writing the code, why we should do it this way and not immediately by installing the order), the adviser should be able to set Stop-Losses and Take-Profits over the orders.

– to add the option of closing the orders when the price reaches the opposite line of Envelopes. This function can be turned off in the settings.

If you are reading this book, I hope that you already have a MetaTrader4 trading terminal on your computer and you know how to set a demo account. If not, you need to install this terminal by pre-registering with any broker supporting MetaTrader4.

And now, translate your terminal into English!If you set your sights on pursuing programming, get used to English, no way round it! Leave the MetaEditor code editor in Russian, because when you translate it into English, its Help (F1) would also be in English. It’s not everyone’s cup of tea.

NOW WE GET THE INDICATORS” DATA

Open your MetaTrader4 and press F4 on the keyboard, or left click here:

In the popped up code editor, click New (Create), then the Expert Advisor (template), then Next, in the Name field after Experts\ add MyFirstEA – this will be the name of your first Expert Advisor. You’ll get Experts\MyFirstEA. We do not need the Autor and link fields for this test advisor. Click the Next button. The Event Handles of the Expert Advisor window should pop up. There is nothing to set here and just click Next. The Tester event handless of the Expert Advisor window will pop up, once more, do not select anything there and click Finish. Now we get a working area where our trading bot will soon be born.

In the comments on the image below we indicated which blocks are responsible - фото 3

In the comments on the image below, we indicated which blocks are responsible for what.

To know the price values of indicators, we need to assign the global variables of the double type for the top and bottom lines of the Envelopes indicator. Let’s call them enveUP and enveDW. You can call them yourself. The same should be done to get the price value of the ZZ indicator. Let’s call this variable ZZ. Why the global variables, of all of them? In order for these values to be requested anywhere in the program (namely, in the advisor). The fact is that we will request the indicator values not with each incoming tick, but once for each candle. This will significantly improve performance because the terminal would not need to perform the same operation for each tick. If we enclose the request for our indicators in curly braces, while assigning their values NOT for the global variables, then these values will be visible only within those curly braces. And outside of them, we will get an error. I’ll try to describe the specifics in the picture below.

Copy this code into your editor - фото 4

Copy this code into your editor:

//+ – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – +

//| MyFirstEA.mq4 |

//| Copyright 2017, |

//+ – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – +

#property copyright “Copyright 2017”

#property link””

#property version “1.00”

#property strict

//+ – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – +

double enveUP, enveDW, ZZ;

datetime open;

//+ – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – — – +

int OnInit ()

{

return (INIT_SUCCEEDED);

}

void OnDeinit (const int reason)

{

}

void OnTick ()

{

if (Open [0]!= open)

{

enveUP = iEnvelopes (NULL,0,13,MODE_SMA,10,PRICE_CLOSE,0.2,MODE_UPPER,1);

enveDW = iEnvelopes (NULL,0,13,MODE_SMA,10,PRICE_CLOSE,0.2,MODE_LOWER,1);

ZZ = iCustom (Symbol (),0,“ZigZag”, 0,1);

if (enveUP> 0 && enveDW> 0 && ZZ> 0) open = Open [0];

}

}

Let’s examine what each line means.

In global variables, except the variables for indicator values, we assigned a variable of datetime type with the open name. Now it set to 0.

IMPORTANT:Position the cursor on the word datetime and press the F1 on the keyboard – the HELP window will pop up with a description of what the datetime type is. You can do it for allbuilt-in commands!

if( Open [0]! = open ): If the Zero Candle Open Time IS NOT EQUAL open (i.e., it is set to zero), the code in curly braces will be executed. The Open [0] command means the Zero Candle Open Time (i.e., the time of the current, not yet closed candle). Again, position the cursor on Open and press F1 – read about this command.

EnveUP = iEnvelopes (NULL,0,13,MODE_SMA,10,PRICE_CLOSE,0,2,MODE_UPPER,1); – click on iEnvelopes and see what data should be indicated and in which order:

double iEnvelopes (

– string symbol, // the symbol name

– int timeframe, // timeframe

– int ma_period, // period

– int ma_method, // the averaging method

– int ma_shift, // the average shift

– int applied_price, // the price type

– double deviation, // the deviation (as %)

– int mode, // the line index

– int shift // shift

);

In our code, we did not foresee the option of changing the data of the Envelopes indicator. Let’s fix it. We need to reassign the Period and Deviation, expressed as percentage, as external parameters.

In the advisor’s code, write in front of the global variables:

input int period = 14;

input double deviation = 0.10.

The input command makes the variable visible in the properties of the Expert Advisor so the user can change it.

Конец ознакомительного фрагмента.

Текст предоставлен ООО «ЛитРес».

Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Expert advisor for MT4 for one evening»

Представляем Вашему вниманию похожие книги на «Expert advisor for MT4 for one evening» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Expert advisor for MT4 for one evening»

Обсуждение, отзывы о книге «Expert advisor for MT4 for one evening» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x