Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1295

 
leon_17:
Please, advise how to calculate closed orders in history. I tried it like this:

It gives out some nonsense, much more than closed orders.

What is the status? FILLED, CANCELED, EXPIRED, REJECTED?

 
JRandomTrader:

What is the status? FILLED, CANCELED, EXPIRED, REJECTED?

I don't know what you mean. In the help, it is written as follows:

Returns the number of orders in the history. Before calling the HistoryOrdersTotal() function, you need to get the history of deals and orders, using theHistorySelect() orHistorySelectByPosition() functions.


There is nothing about any status.

Документация по MQL5: Торговые функции / HistorySelect
Документация по MQL5: Торговые функции / HistorySelect
  • www.mql5.com
HistorySelect - Торговые функции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
leon_17:
Can you tell me what to use to count closed orders in history. I tried it like this:

It gives out some nonsense, much more than closed orders.

Stay out of warrants. Work with the DREAMS. \

Reference:

Be sure to read the entireTransaction Properties section and see what properties a transaction can have. You specifically need the'DEAL_ENTRY_OUT' property.

ENUM_DEAL_ENTRY

Identifier

Description

DEAL_ENTRY_IN

Market entry

DEAL_ENTRY_OUT

Market exit

DEAL_ENTRY_INOUT

U-turn

DEAL_ENTRY_OUT_BY

Close counter position


Now your algorithm is as follows:

HistorySelect -> loop through all trades -> get deal properties -> summarise trades 'DEAL_ENTRY_OUT'

 
Vladimir Karputov:

Stay out of warrants. Work with the DREAMS. \

Reference:

Be sure to read the entireTransaction Properties section and see what properties a transaction can have. You specifically need the'DEAL_ENTRY_OUT' property

ENUM_DEAL_ENTRY

Identifier

Description

DEAL_ENTRY_IN

Market entry

DEAL_ENTRY_OUT

Market exit

DEAL_ENTRY_INOUT

U-turn

DEAL_ENTRY_OUT_BY

Close counter position


Now your algorithm is as follows:

HistorySelect -> loop through all trades -> get deal properties -> summarise trades 'DEAL_ENTRY_OUT'


Thank you! I'm still confused about the division of these concepts: position, order, deal... Especially between an order and a deal (HistoryOrdersTotal and HistoryDealsTotal return the same values). And it turns out they also have to be manually counted in the history :/

 
Vladimir Karputov:

Stay out of warrants. Work with the DREAMS. \

Reference:

Be sure to read the entireTransaction Properties section and see what properties a transaction can have. You specifically need the'DEAL_ENTRY_OUT' property.

ENUM_DEAL_ENTRY

Identifier

Description

DEAL_ENTRY_IN

Market entry

DEAL_ENTRY_OUT

Market exit

DEAL_ENTRY_INOUT

U-turn

DEAL_ENTRY_OUT_BY

Close counter position


Now your algorithm is as follows:

HistorySelect -> loop through all trades -> get deal properties -> summarise trades 'DEAL_ENTRY_OUT'.

This is if you are not FORTS. Or else clearing is added.

 
Would really like an answer to my question about the begin parameter in the onCalculate function
Or at least to see the code where these situations occur when begin != 0.
Thanks!
Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Функции обработки событий - Функции - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
MisterRight:
I would really like to get an answer to my question about the begin parameter in the onCalculate function
Or at least to see the code where such situations occur when begin != 0.
Thank you!

The article'Indicator by Indicator in MQL5'. For your convenience, after opening the article in your browser, I recommend to press 'Ctrl' + 'F' and type 'begin' in the search field. All occurrences of the word 'begin' will now be highlighted in the article:


Индикатор от индикатора в MQL5
Индикатор от индикатора в MQL5
  • www.mql5.com
При написании индикатора, который использует краткую форму вызова функции OnCalculate(), можно упустить то обстоятельство, что индикатор может рассчитываться не только на ценовых данных, но и на данных другого индикатора (встроенного или пользовательского - не имеет значения). Вы хотите улучшить индикатор, чтобы он правильно считался не только на ценовых данных, но и значениях другого индикатора? В этой статье мы по шагам пройдем все необходимые этапы такой модификации и выведем дополнительные полезные правила для правильного написания индикатора.
 
Got it, thank you very much!)
Ctrl+F I use to search the built-in help, but I can't always find it.
 
This is a question for mql experts. How do I change positions closing marks in EA? I want to have a red arrow to the left on a sell close and a blue arrow to the left on a buy close. Then I would immediately see that it is not the opposite opening, but exactly the closing. I have had it in MT4 and did not know a problem. I would like to change it in MT5. Thank you in advance.
 

There is an indicator for downloading news. A sample code from it is below. WebRequest returns 406. should I specify a different cookie or what could be the problem? Six months ago everything was working.

   string cookie=NULL,headers;
   char post[],result[];     string TXT="";
   int res=-1;
//--- to work with the server, you must add the URL "https://www.google.com/finance"  
//--- the list of allowed URL (Main menu-> Tools-> Settings tab "Advisors"): 
   cookie="accept-encoding: deflate";
   string google_url="https://ec.forexprostools.com/?columns=exc_currency,exc_importance&importance=1,2,3&calType=week&timeZone=15&lang=1";
//--- 
   ResetLastError();
//--- download html-pages
   int timeout=500/*0*/; //--- timeout less than 1,000 (1 sec.) is insufficient at a low speed of the Internet
   int max_try=5;
   int n=0;
   while(res==-1)
     {
      res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
      ...
     }

This is what's coming in:

"<html><head><title> 406 Not Acceptable</title></head><body><center><h1> 406 Not Acceptable</h1></center><hr><center> nginx/1.16.1</center></body></html>" (length: 149)
Документация по MQL5: Сетевые функции / WebRequest
Документация по MQL5: Сетевые функции / WebRequest
  • www.mql5.com
WebRequest - Сетевые функции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5