Discussion of article "MQL5 Cookbook: Using Indicators to Set Trading Conditions in Expert Advisors"

 

New article MQL5 Cookbook: Using Indicators to Set Trading Conditions in Expert Advisors is published:

In this article, we will continue to modify the Expert Advisor we have been working on throughout the preceding articles of the MQL5 Cookbook series. This time, the Expert Advisor will be enhanced with indicators whose values will be used to check position opening conditions. To spice it up, we will create a drop-down list in the external parameters to be able to select one out of three trading indicators.

MQL5 Cookbook: Using Indicators to Set Trading Conditions in Expert Advisors

Author: Anatoli Kazharski

 

Anatoly, thank you for the article! I think that the MQL5-recipe approach is very successful...

I have a couple of questions and comments. And they are rather directed to the Developer.

In the article :

"...Напомню, для режима исполнения Market Execution открыть позицию сразу с установленными уровнями Stop Loss и Take Profit не получится: нужно сначала открыть позицию, а потом уже модифицировать ее, установив эти уровни..."

And literally right away:

Starting from build 803, for Market Execution and Exchange Execution execution types, you can set Stop Loss and Take Profit levels when opening a position.

I understand that the last paragraph cancels the meaning of the previous one.... then why this information was not initially included in the list of changes "MetaTrader 5 Client Terminal build 803"? And why it is not in the Documentation?

 
denkir:
I understand that the last paragraph cancels the meaning of the previous one.... then why this information was not originally included in the list of changes "MetaTrader 5 Client Terminal build 803"? And why it is not in the Documentation?

For some reason it was not mentioned in the news, but we decided to give a footnote in this article.

We will correct the documentation.

 
Rosh:

For some reason not mentioned in the news, but decided to give a footnote in this article.

Documentation will be corrected.

as for MT4 ?
 
Rosh:

For some reason not mentioned in the news, but decided to give a footnote in this article.

Documentation will be corrected.

Thank you.

And in passing, please deal with:

1) method

bool CTrade::FillingCheck(const string symbol)


2) whether a particular mode is allowed for a tool (SYMBOL_FILLING_ALL_OR_NONE, SYMBOL_CANCEL_REMAIND, SYMBOL_RETURN_REMAIND ).

I understand that item 2) can be customised by the broker.... maybe it makes sense to specify it in the Documentation?

If my understanding is wrong, then the question on point 2) is cancelled...


 
denkir:

I understand item 2) can be customised by the broker..... maybe it makes sense to specify it in the Documentation?

specify in the documentation that "item 2) can be customised by the broker" ?

 
sergeev:

specify in the documentation that "point 2) can be customised by the broker" ?

Mm-hmm. Why so... but because I noticed that for the same type of accounts (fix spread, FOK execution) at different brokers the function

SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE);

can return different values...

 
denkir:

Mm-hmm.

it's just not clear why.

in fact, the phrase "can be customised by broker" should be written on every page of the documentation on trading :)

But what you are asking is not about the broker, but about the symbol.

one symbol is a market execution, the second one is a stock exchange symbol.

they have different conditions, different types of fills and many other things.

This is why all the functions of polling the state of the trading environment are given.

 

sergeev:

...but what you are asking is not related to the broker, but to the symbol.

one symbol is a market execution, the other one is a stock exchange symbol.

they have different conditions, different types of fills and many other things ...


sergeev, you didn't pay attention to what I wrote earlier:

...but because I noticed that the same type of accounts (fix spread, FOK execution) at different brokers....


I have sketched a simple script. In it I got the following information on EURUSD symbol from different brokers:


Broker "A":

NQ    0    22:39:37    test_symbol (EURUSD,H1)    Число знаков после запятой: 4
GI    0    22:39:37    test_symbol (EURUSD,H1)    Плавающий спред: 1
KQ    0    22:39:37    test_symbol (EURUSD,H1)    Режим заключения сделок: SYMBOL_TRADE_EXECUTION_INSTANT
OK    0    22:39:37    test_symbol (EURUSD,H1)    Режим заливки оредеров: 1
DS    0    22:39:37    test_symbol (EURUSD,H1)    Путь в дереве символов: Forex\EURUSD


Broker "B":

ON    0    22:45:00    test_symbol (EURUSD,H1)    Число знаков после запятой: 4
EQ    0    22:45:00    test_symbol (EURUSD,H1)    Плавающий спред: 0
RN    0    22:45:00    test_symbol (EURUSD,H1)    Режим заключения сделок: SYMBOL_TRADE_EXECUTION_INSTANT
LS    0    22:45:00    test_symbol (EURUSD,H1)    Режим заливки оредеров: 3
OK    0    22:45:00    test_symbol (EURUSD,H1)    Путь в дереве символов: Forex-Fix\EURUSD


You can notice that at the same mode of concluding deals there is a different mode of filling orders. Yes, spreads modes are different (which I missed when stating that brokers have the same type of accounts).... question, are the modes (deal making and order filling) somehow connected?

//+------------------------------------------------------------------+
//|test_symbol.mq5 |
//| Copyright 2013, MetaQuotes Software Corp. | |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

#define  SymInt SymbolInfoInteger 
#define  SymS SymbolInfoString 

string _symbol="EURUSD";
//+------------------------------------------------------------------+
//| Script programme start function|
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 1) SymbolInfoInteger()
   long symb_digits=SymInt(_symbol,SYMBOL_DIGITS);
   PrintFormat("Number of decimal places: %u",symb_digits);
   bool symb_spread_float=SymInt(_symbol,SYMBOL_SPREAD_FLOAT);
   PrintFormat("Floating spread: %d",symb_spread_float);
   string trade_mode=EnumToString((ENUM_SYMBOL_TRADE_EXECUTION)SymInt(_symbol,SYMBOL_TRADE_EXEMODE));
   PrintFormat("Transaction mode: %s",trade_mode);
   long fil_mode=SymInt(_symbol,SYMBOL_FILLING_MODE);
   PrintFormat("Oreader fill mode: %u",fil_mode);
//--- 2) SymbolInfoString()
   string path=SymS(_symbol,SYMBOL_PATH);
   PrintFormat("Character tree path: %s",path);
  }
//+------------------------------------------------------------------+
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
 
denkir:

question, are the modes (making deals and pouring oreaders) somehow related?

no, of course not.

and the expiry time and the way of profit calculation are not related to the "deal making" mode either.

 

Very good article.

but I have difficulties to dowload the Zip file that seems to be corrupted