Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 674

 

Dear Connoisseurs!

I hope I am asking a question in the right branch!

The question is: is it possible to use #define to define a construct that would unfold into the following code:

if(a) printf("%s(%04d)", __FUNCTION__, __LINE__) +printf("%s", _Symbol);

This is for understanding... The right construction could be different. Ideally, I would like to find a solution so that any printf() at the beginning of the output string would print with the "Function(string in function) " construct preceding the string when the condition matches. This is all to shorten the written instructions

And I would like the red highlighted construct to be replaced with this (similar):

#define P(a) if(variable>=a) printf("%s(%04d)", __FUNCTION__, __LINE__)

I've found something in Inet, a bit similar, but I haven't worked with classes, therefore I can't manage to work out the working codes yet. I tried to apply the lower construct in the form

P(3)+printf("%s(%s) Accuracy=%d", Symbol, (Command==0? "Buy": "Sell"), Accuracy);

But any such entry in the code causes the 'Print' error - expression of 'void' type is illegal ...

 

Hello!

Please explain the difference between

if(!OrderSelect(order,SELECT_BY_TICKET,MODE_TRADES)){PrintFormat("OrderSelect error %d",GetLastError());return;}

и

if(OrderSelect(order,SELECT_BY_TICKET,MODE_TRADES)==false){PrintFormat("OrderSelect error %d",GetLastError());return;}

thank you!

 
ski1973:

Hello!

Please explain the difference between

if(!OrderSelect(order,SELECT_BY_TICKET,MODE_TRADES)){PrintFormat("OrderSelect error %d",GetLastError());return;}

и

if(OrderSelect(order,SELECT_BY_TICKET,MODE_TRADES)==false){PrintFormat("OrderSelect error %d",GetLastError());return;}

thanks!

There is no logical difference. The difference lies only in how this logical comparison is written.

The "!" sign is "NOT". I.e., if(!Select()) is the same as if(Select()==false). In Russian, it looks like this: if(NOT Select()).

You can quickly "invert" the value of a boolean variable:

bool var = true;
Print("1. var=",(string)var);
var=!var;
Print("2. var=",(string)var);
 

I have another question. The following is an example of a program.

double Lots=0.01;

int slippage=30;

int Subr1()

{

int result=-1;

int_result=OrderSend(_symbol,OP_BUY,Lots,slippage,0,0);

if(int_res<0){PrintFormat("OrderSend error = ",GetError());}

return int_result;

}

void OnTick()

{

int numer=-10;
if(OrdersTotal()==0)numer=Subr1();

if(OrdersTotal()>0)Subr2(numer);

return;

}

void Subr2(int order)

{

if(!OrderSelect(order,SELECT_BY_TICKET,MODE_TRADES)){PrintFormat("OrderSelect error %d",GetLastError());return;} else PrintFormat("Ok, OrderTicket = ",OrderTicket());

}

Response: OrderSelect error 4051. If I replace it with SELECT_BY_POS, OrderSelect error 1. Reaction is the same for the strategy tester and the "run on real data". I tried to remove MODE_TRADES for the case of SELECT_BY_TICKET: There is no difference. What is the problem and how to fix it. Thank you!

 
ski1973:

Response: OrderSelect error 4051. If I replace it with SELECT_BY_POS, OrderSelect error 1. Reaction is the same for strategy tester and "run on real data". I tried to remove MODE_TRADES for the case of SELECT_BY_TICKET: There is no difference. What is the problem and how to fix it? Thank you!

SELECT_BY_POS is the selection of an order "by priority" in the list of orders and in your design:

void Subr2(int order)
{
if(!OrderSelect(order,SELECT_BY_TICKET,MODE_TRADES)){PrintFormat("OrderSelect error %d",GetLastError());return;} else PrintFormat("Ok, OrderTicket = ",OrderTicket());
}

You are trying to select an order that is by order queue # ... and you are using ticket # here and you only have 1 order and ticket # 10023444 .... so what ? here you need a number from 1 to 2,3 ... well, how many orders you have in the market ,... corrected the number from 0,1,2 ... - Numbering starts with 0 and goes up toOrdersTotal()-1...

SELECT_BY_TICKET should work, but only up to the moment when you have the ticket number, i.e. the order you have in the market, and above you have a check to send the order, and if the order is not sent, the ticket = -1 !

And all in all, your design for working with orders is not correct. If you decided to study MQL, here are ready-made examples for working with ordershttps://www.mql5.com/ru/forum/131859

Только "Полезные функции от KimIV".
Только "Полезные функции от KimIV".
  • 2011.02.18
  • www.mql5.com
Все функции взяты из этой ветки - http://forum.mql4...
 
Vitaly Muzichenko:

You talk about arrays and you talk about forex. What a paradox!

And a fool knows that all basic arrays in MT4/MT4 are buffered.

Not the same level of programmers in MT4/MT5, to allow users to work with basic arrays.

Moreover, the basic arrays in MT4/MT5 have their own extension (.hts or .hss - I don't remember exactly, but something like this).

So, they don't come to the terminal in a text format (with .txt extension), but in their own format.

And in MT4/MT5 the basic arrays are decoded and converted into arrays of selected timeframes (1-minute, 5-minute, 15-minute, etc.), and only after that they are duplicated and buffered.

Why are they buffered?

For comparison. So that no data is lost. One of these arrays is constantly recalculated (from time to time), and the second (copied from the first) is used when we copy into our user data.

In other words, the procedure for making the data available to users is quite complex.

This is about arrays, in case you are interested.

By the way, both Android and Window's basic MT4/MT5 arrays have the same extension.

--------------------------------------------------------------------------------------------------------------------------------

As for importing DYNAMIC data into MT4/MT5 from third party sources, as far as I understand, such import is not provided.

So there is no Client/Server procedure in C++Builder in MT4/MT5.

--------------------------------------------------------------------------------------------------------------------------------

I wonder if this procedure will be in the library

http://tol64.blogspot.com/2015/12/easy-and-fast-gui-mql.html

Most probably, of course, it won't be there either.

That is, you can try to import dynamic arrays into MT4/MT5 only in basic format, where they will automatically go through standard data processing .

Библиотека "Easy And Fast GUI" для создания графических интерфейсов на MQL
  • tol64.blogspot.com
С этой статьи я начинаю еще одну серию, относящуюся к разработке графических интерфейсов. На текущий момент нет ни одной библиотеки кода, которая позволяла бы легко и быстро создавать качественные графические интерфейсы в MQL-приложениях. Я имею в виду графические интерфейсы, к которым мы все привыкли в известных операционных системах. Цель проекта — дать конечному пользователю такую возможность и научить это делать с помощью моей библиотеки. Я постарался сделать ее максимально понятной в изучении, с возможностями дальнейшего развития.
 
neverness:

And a fool knows that all basic arrays in MT4/MT4 are buffered.

The programmers in MT4/MT5 are not of the same level as the ones in MT4/MT5, who allow users to work with basic arrays.

Moreover, the basic arrays in MT4/MT5 have their own extension (.hts or .hss - I don't remember exactly, but something like this).

So, they don't come to the terminal in a text format (with .txt extension), but in their own format.

And in MT4/MT5 the basic arrays are decoded and converted into arrays of selected timeframes (1-minute, 5-minute, 15-minute, etc.), and only after that they are duplicated and buffered.

Why are they buffered?

For comparison. So that no data is lost. One of these arrays is constantly recalculated (from time to time), and we use the second (copied from the first) when copying into our user data.

In other words, the procedure for making the data available to users is quite complex.

This is about arrays, in case you are interested.

By the way, both Android and Window's basic MT4/MT5 arrays have the same extension.

You have such a mess in your head that I couldn't even get past

You have made a mess of things in MQL - arrays, files, time series and indicator buffers.

If you manage to digest the information I gave in one line, I'll give you some food for thought: MT4 and MT5 store historical data in different ways, in MT4 a user has access to .hst fileshttps://docs.mql4.com/ru/files/fileopenhistory

In MT5 there is no direct access to history files, but there is work with custom symbolshttps://www.mql5.com/ru/docs/customsymbols

FileOpenHistory - Файловые операции - Справочник MQL4
FileOpenHistory - Файловые операции - Справочник MQL4
  • docs.mql4.com
[in]  Режим открытия. Это может быть одна величина или их комбинация: FILE_BIN, FILE_CSV, FILE_READ, FILE_WRITE, FILE_SHARE_READ, FILE_SHARE_WRITE. Клиентский терминал может подключаться к серверам разных брокерских компаний. Исторические данные (файлы HST) каждой брокерской компании хранятся в соответствующей подпапке папки истории...
 
Igor Makanu:

You have such a mess in your head that I couldn't even get past it

You have made a mess of all MQL - arrays, files and indicator buffers

If you manage to digest the information I've given in one line, then I'll give you some food for thought: MT4 and MT5 store historical data in different ways, in MT4 a user has access to .hst fileshttps://docs.mql4.com/ru/files/fileopenhistory

In MT5 there is no direct access to history files, but there is work with custom symbolshttps://www.mql5.com/ru/docs/customsymbols

I didn't say a single word about history files in my post at all.

You got something mixed up again, and again, off topic.

I was talking about DYNAMIC data sets. That's a completely different topic. Feel the difference.

 
neverness:

I didn't say a word about the history files in my post at all.

You are confused again, and again off topic.

I was talking about dynamic data arrays. That's a completely different topic.

Moreover, the basic arrays in MT4/MT5 even have their own extension (.hts or .hss - I don't remember exactly, but something like that).

Ok, go ahead, I don't understand the purpose of your being in this forum thread

Neverness:

I was talking about DYNAMIC data sets. This is a totally different topic. Feel the difference.

felt, you should also understand that in all programming languages dynamic arrays are just dynamic arrays andtimeseries aretimeseries and part of the work (access) withtimeseries is organised as working with arrays...
 
Igor Makanu:

OK, go ahead, I don't understand the purpose of your being in this forum thread

I feel you should also understand that in all programming languages dynamic arrays are just dynamic arrays andtimeseries aretimeseries and part of work (access) withtimeseries is organized as work with arrays...

This is where the question of data formation in the terminal is discussed in great detail:

http://profitraders.com/Python/hstRead.html

I want to draw readers' attention to the fact that this article is NOT about historical data, which is located at: MT4->Service->Figures Archive,

and directly about the DYNAMIC data of the terminal in .hst format, which are directly involved in the process of obtaining and processing of market quotes.

------------------------------------------------------------------------------------------

Maybe I haven't made it clear enough. Read other authors. I hope it will become clearer.

Чтение файла HST истории котировок Metatrader 4 — ProfiTraders.com
  • profitraders.com
Файлы истории котировок Metatrader 4 имеют расширение и находятся в папке данных торгового терминала, в каталоге . Они сгруппированы в подкаталогах, имена которых совпадают с названиями серверов, например: или . Имена файлов начинаются с наименования торгового инструмента, далее указывается таймфрейм (количество минут), например, для часового...