Features of the mql5 language, subtleties and tricks - page 43

 
fxsaber:
In such cases it will work even without extra brackets.
The brackets are for myself. I can see better this way.
 
When it is tiring to select the right function under the property of interest
double TerminalInfo( const ENUM_TERMINAL_INFO_DOUBLE Property )
{
  return(TerminalInfoDouble(Property));
}

long TerminalInfo( const ENUM_TERMINAL_INFO_INTEGER Property )
{
  return(TerminalInfoInteger(Property));
}

string TerminalInfo( const ENUM_TERMINAL_INFO_STRING Property )
{
  return(TerminalInfoString(Property));
}

void OnStart()
{
  Print(TerminalInfo(TERMINAL_COMMUNITY_BALANCE));
  Print(TerminalInfo(TERMINAL_LANGUAGE));
  Print(TerminalInfo(TERMINAL_BUILD));
}
 

Forum on trading, automated trading systems and testing trading strategies

Libraries: TypeToBytes

fxsaber, 2017.06.13 16:01

string GetDirectory( const string FileName )
{
  int Pos = StringFind(FileName, "\\");
  int LastPos = Pos;
  
  while (Pos >= 0)
  {
    LastPos = Pos;
    
    Pos = StringFind(FileName, "\\", Pos + 1);
  }

  return((LastPos >= 0) ? StringSubstr(FileName, 0, LastPos + 1) : "");
}

// Возвращает список всех файлов по фильтру
int GetFileNames( string &FileNames[], int Pos = 0, string Filter = "*", const int Common_Flag = 0 )
{
  string FileName;
  const long handle = FileFindFirst(Filter, FileName, Common_Flag);

  if (handle != INVALID_HANDLE)
  {    
    const string Directory = GetDirectory(Filter);    
    Filter = StringSubstr(Filter, StringLen(Directory));
    
    do
    {
      const string TmpFileName = Directory + FileName;
      
      ArrayResize(FileNames, Pos + 1);      
      FileNames[Pos] = TmpFileName;      
      Pos++;
        
      if (!FileIsExist(TmpFileName, Common_Flag))
        Pos = GetFileNames(FileNames, Pos, TmpFileName + Filter, Common_Flag);
    }
    while (FileFindNext(handle, FileName));  
    
    FileFindClose(handle);
  }
  
  return(Pos);
}
 
What is the meaning of the HistoryDealSelect function, when in the HistoryDealGetInteger, HistoryDealGetDouble,
HistoryDealGetString functions, you need to specify the ticket_number again?
 
. ... Rick D. ... .:
Tell me what is the point of the HistoryDealSelect function when the functions HistoryDealGetInteger, HistoryDealGetDouble,
HistoryDealGetString functions, you need to specify ticket_number again?

Forum on trading, automated trading systems and trading strategies testing

Peculiarities of mql5 language, tips and tricks

fxsaber, 2017.06.07 22:20

There are two current history tables whose data is available through History functions - Orders table and Deals table.

Their contents can be influenced only through HistorySelect-functions. And it happens in the following way

  • The HistorySelect and HistorySelectByPosition - affect both tables simultaneously.
  • The HistoryDealSelect affects ONLY the Deals table (it has no effect on the current Orders-historical table).
  • HistoryOrderSelect affects Orders table ONLY (does not affect current Deals-history table).

The Deal table becomes of one element.
 
Is there any limitation on the number of graphical objects that can be placed on the chart? We are not talking about pixel graphics, but graphic elements - trend lines, rectangles, etc.
 
Konstantin:
Is there any limitation on the number of placed graphical objects on the chart? I mean not pixel graphics, but graphical elements - trend lines, rectangles, etc.
I tried more than 2000 - it worked
 
Vitaly Muzichenko:
tried more than 2000 - it worked

How will it be less expensive in terms of resources if you need to make changes on every tick:

1. to use 2000 graphical objects

2. use class Canvas and create on each tick one drawing with the same 2000 drawings of graphical objects

 
Konstantin:

How will it be less expensive in terms of resources if you need to make changes on every tick:

1. to use 2000 graphical objects

2. use the class Canvas and create on every tick one figure containing the same 2000 drawings of graphical objects

Canvas will be several times more productive, I tried it.
 
Vitaly Muzichenko:
Canvas will be several times more productive, I tried it.

I can't deal with Canvas, for example I need to draw an array of horizontal lines on the chart, can you throw the example code?

Oops )) It turns out that the Help is more extended on the site, I found what I'm looking for - the CLineChart class ))

Reason: