myeatrade

MQL4 Reference

MQL4 Common functions (1)

General-purpose functions not included into any specialized groups.

 

Alert()

void Alert(...)

Displays a dialog box containing the user-defined data. Parameters can be of any type. Amount of passed parameters cannot exceed 64.

Arrays cannot be passed to the Alert function. Arrays should be output elementwise.

Data of double type output with 4 decimal digits after point. To output with more precision use DoubleToStr() function.

Data of bool, datetime and color types will be output as its numeric presentation.

To output values of datetime type as string convert it by TimeToStr() function.

See also Comment() and Print() functions.

Parameters:

...   -   Any values, separated by commas. It can be up to 64 parameters. 

Sample:

  if(Close[0]>SignalLevel)
    Alert("Close price coming ", Close[0],"!!!");

Comment()

void Comment(...)

The function outputs the comment defined by the user in the left top corner of the chart. Parameters can be of any type. Amount of passed parameters cannot exceed 64.

Arrays cannot be passed to the Comment() function. Arrays should be output elementwise.

Data of double type output with 4 digits after the decimal point. To output with more precision, use the DoubleToStr() function.

Data of bool, datetime and color types will be output as their numeric presentation.

To output values of datetime type as strings, convert them with the TimeToStr() function.

See also Alert() and Print() functions.

Parameters:

...   -   Any values, separated by commas. It can be up to 64 parameters. 

Sample:

  double free=AccountFreeMargin();
  Comment("Account free margin is ",DoubleToStr(free,2),"\n","Current time is ",TimeToStr(TimeCurrent()));

Print()

void Print(...)

Prints a message to the experts log. Parameters can be of any type. Amount of passed parameters cannot exceed 64.

Arrays cannot be passed to the Print() function. Arrays should be printed elementwise.

Data of double type are printed with 4 decimal digits after point. To output more precisely, use the DoubleToStr() function.

Data of bool, datetime and color types will be printed as their numeric presentation.

To print values of datetime type as string, convert them with the TimeToStr() function.

See also Alert() and Comment() functions.

Parameters:

...   -   Any values, separated by commas. It can be up to 64 parameters. 

Sample:

  Print("Account free margin is ", AccountFreeMargin());
  Print("Current time is ", TimeToStr(TimeCurrent()));
  double pi=3.141592653589793;
  Print("PI number is ", DoubleToStr(pi,8));
  // Output: PI number is 3.14159265
  // Array printing
  for(int i=0;i<10;i++)
    Print(Close[i]);

PlaySound()

void PlaySound(string filename)

Function plays a sound file. The file must be located in the terminal_dir\sounds directory or in its subdirectory.

Parameters:

filename - Path to the sound file. 

Sample:

  if(IsDemo()) PlaySound("alert.wav");

MarketInfo()

double MarketInfo(string symbol, int type)

Returns various data about securities listed in the Market Watch window. A part of information about the current security is stored in predefined variables.

Parameters:

symbol - Security symbol. 
type   - Request identifier that defines the type of information to be returned. 
         Can be any of values of request identifiers. 

Sample:

   double bid   =MarketInfo("EURUSD",MODE_BID);
   double ask   =MarketInfo("EURUSD",MODE_ASK);
   double point =MarketInfo("EURUSD",MODE_POINT);
   int    digits=MarketInfo("EURUSD",MODE_DIGITS);
   int    spread=MarketInfo("EURUSD",MODE_SPREAD);
This article url: http://www.myeatrade.com/436/

Please login to post comment, if you haven't account you can register free