Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2013.02.22 07:12

Skype Control Library - library for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

votes: 34 (749.56 KB)
skypemql.mqh (2.26 KB)view

In the automatic trading Skype can be used for sending text messages with the necessary information. In this case work with Skype is realized via library Skype4COM, i.e. an ActiveX component that represents access to program management.

At present time Skype4COM.dll is distributed with skype, by default it is located in the following folder:

For an operating system x86:

  • c:\Program Files\Common Files\Skype\Skype4COM.dll

For an operating system x64:

  • c:\Program Files (x86)\Common Files\Skype\Skype4COM.dll

This SkypeMQL.dll library file must be installed in the folder: [terminal directory]\MQL5\Libraries

The project supports only 32-bit version of MetaTrader 4/5.


1. Sending instant messages

int SkypeSendInstantMessageW(string skype_name,string message,int status);
int SkypeSendInstantMessageA(string skype_name,string message,int status);// for MetaTrader 4

There are several tests in a function before sending instant message:

  • The user name cannot be empty or begin with a number.
  • The user with the specified name must be in the contact list.
  • The message cannot be an empty string.
  • The network status of the recipient must coincide with the specified value.

The list of the network status constants:

constant name
Out of place
Do not disturb

To set several allowed statuses simultaneously bit-by-bit addition of constants is used, for example: STATUS_ONLINE | STATUS_AWAY.

The maximum length of an instant message is ~8000 ANSI symbols, ~4000 Unicode symbols.

The example of a code:

string InpSkypeName     =  "echo123";        // Skype name
string InpTextMessage   =  "Hello :)";       // Text message

string msg;

if(err==ERROR_NO_ERRORS) msg=StringFormat("Sent IM to %s, %s",InpSkypeName,InpTextMessage);
else msg=StringFormat("Error sending IM to %s, error: %s",InpSkypeName,EnumToString(err));



2. Sending SMS messages

The service to send SMS messages is fee-paid at the moment!

int SkypeSendSmsMessageW(string phone_number, string message);
int SkypeSendSmsMessageA(string phone_number, string message);// for MetaTrader 4

There are several tests before sending SMS message:

  • The telephone number must be specified in the international format: + [country code] [city or network code] [telephone number]
  • The length of the string which contains the telephone number must be at least 7 symbols and start with a '+' sign
  • Text message must not be an empty string

Sending SMS to a non existing number is not an error. The cost for this operation will be charged, but returned after a short time, as the actual message wasn't delivered.

The SMS message is limited to 116 ANSI symbols, 58 Unicode symbols.

The example of a code:

input string InpPhoneNumber   =  "+380123456789";  // Phone number
input string InpTextMessage   =  "Hello :)";       // Text message

string msg;
ENUM_SKYPE_ERROR err==(ENUM_SKYPE_ERROR) SkypeSendSmsMessageW(InpPhoneNumber,InpTextMessage);

if(err==ERROR_NO_ERRORS) msg=StringFormat("Sent SMS to %s, %s",InpPhoneNumber,InpTextMessage);
else msg=StringFormat("Error sending SMS to %s, error: %s",InpPhoneNumber,EnumToString(err));


3. Description of the return values

Both functions return an integer value which can be analyzed, if necessary.

constant name
Unknown error
0 Successful execution
Failed to connect to Skype
There is no specified user in the contact list
Invalid user status
Timed out
ERROR_RUNNING 5 Skype is not loaded to memory
Sending error
ERROR_VALUE 7 Transferred parameters error
ERROR_ACCESS 8 Access to Skype is denied
ERROR_SKYPE4COM 9 for x86: Skype4COM.dll is not registered
for x64: COM-object creation error


4. The first launch

At first connection MetaTrader 5 to Skype a pop up window appears which enables program management access.

After confirming access to Skype, the requesting process enters to the list stored in the program settings: Tools -> Options -> Advanced -> Manage other programs' access to Skype.


5. Runtime errors

By unknown reasons, the work with the library compiled for MetaTrader 5 x64 ends with "Stack overflow" error. If it is connected with Skype4COM, then you have to wait for the new messages where this error will be corrected.

The attachment has an archive with library source code (a project for Microsoft Visual C++ 2010) and test script to check its performance.

Translated from Russian by MetaQuotes Software Corp.
Original code:

FX_Sniper_Ergodic_CCI FX_Sniper_Ergodic_CCI

The ergodic CCI.

TrendPower TrendPower

The trend indicator drawn on the basis of a comparison of six levels of simple Moving Averages with High and Low of the current candlestick

OpenBuyPosition_X OpenBuyPosition_X

The OpenBuyPosition_X script is designed to buy at fixed values of Stop Loss and Take Profit in points from the current price. Position volume is determined on the basis of the level of losses.

OpenSellPosition_X OpenSellPosition_X

The OpenSellPosition_X script is created to sell at fixed values of Stop Loss and Take Profit in points from the current price. Position volume is determined on the basis of the level of losses.