Can I secure my expert advisor robot to be work on the only one pc ?

 

Yes

You could make a call to the windows APi and get a unique idetefier for the computer like Windows serial number or hardrive Serial number and lock the EA to run only on that PC

 
BillyJoe:

Yes

You could make a call to the windows APi and get a unique idetefier for the computer like Windows serial number or hardrive Serial number and lock the EA to run only on that PC


Can you give me the sample code ?
 
puncher:

Can you give me the sample code ?
Your programmer should know how to do this.
 
BillyJoe:

You could make a call to the windows APi and get a unique idetefier for the computer like Windows serial number or hardrive Serial number and lock the EA to run only on that PC

There are two general problems with this:

  • There is no form of computer ID which meets all of the following criteria: (a) guaranteed to be available on all computers; (b) not falsifiable by the user; and (c) does not potentially require installation of additional libraries which the user does not have. For example, hard disk volume number is easy to query but is also easy to manipulate. Hard disk serial number can only be queried using something like WMI, which is not guaranteed to be present on a computer, and is a pig to call from MQL4/5. Similarly, locking against MAC address is hard, partly because most computers have multiple MAC addresses, and partly because the standard way of querying them is anyway open to user manipulation (i.e. doesn't actually touch the hardware).
  • EX4 files can be decompiled. Therefore, any security mechanism which is built into MQL4 code can easily be removed.
In short, the means which is used for identifying a computer has to be a compromise between security and practicability. And there's no point doing the check within MQL4 code; it has to be in something which is harder to break, e.g. a DLL. And then you also have to protect the bridge between the MQL4 code and the DLL.
 

puncher, there you go

//+------------------------------------------------------------------+
//| Function..: SystemDriveSerialNumber                              |
//| Purpose...: Retrieve the serial number of a logical drive stored |
//|             in the drive's boot sector.                          |
//| Parameters: sDrive -  root diretory of volume to retrieve Serial |
//|                       number.                                    |
//| Returns...: sNumber - drive serial number, or null string in the |
//|             case of an error.                                    |
//| Example...: string sNumber=SystemDriveSerialNumber("C");         |
//| Thank You.: Big thank you to Stanislav Starikov of MetaQuotes    |
//|             www.metaquotes.net for correcting the parameter type |
//| Notes.....: Insert the following code at the top of your program |
/*|             in the EX4 imports section:                          |
#import "Kernel32.dll"
  bool GetVolumeInformationA(string RootPathName,
       string VolumeNameBuffer, int VolumeNameSize,
       int& VolumeSerialNumber[], int MaximumComponentLength,
       int FileSystemFlags, string FileSystemNameBuffer,
       int FileSystemNameSize);
#import  
//+------------------------------------------------------------------+*/
string SystemDriveSerialNumber(string sDrive) {
  int    iVolumeSerialNumber[1]={0};
  string sVolumeSerialNumber="";
  if(GetVolumeInformationA(sDrive+":\\", "                ", 15, iVolumeSerialNumber, 0, 0, "                ", 15))
  {
    sVolumeSerialNumber=IntegerToHexString(iVolumeSerialNumber[0]);
    sVolumeSerialNumber=StringConcatenate(StringSubstr(sVolumeSerialNumber,0,4), "-", StringSubstr(sVolumeSerialNumber,4));
  }
  return(sVolumeSerialNumber);
}
 

[offtopic]

@sxTed

i have noticed you comment your functions extensively which is a good thing and every programmer should do it.

Have you ever considered formatting these comments in JavaDoc style so you can later simply run Doxygen over your entire include folder to generate nice structured HTML (or CHM or PDF) documentation like this: http://7bit.99k.org/files.html with a single mouse click?

With the wealth of information you provide for every function it should produce really nice comprehensive documentation, all you have to do is use the standard tokens like @param, @return, etc. inside your blocks and make the blocks recognizable to doxygen itself by starting them with /**

 
hi 7bit, i comment because i have a bad memory! thank you for the JavaDoc link and to the link to your code (it is going to keep me busy over the week end), wow EURUSD dropping fast, take care
 
@sxTed, there is an article concerning Doxygen with MQL5 but everything also applies to MQL4, just set it to optimize for C instead of C++: https://www.mql5.com/en/articles/12
 
sxTed:

puncher, there you go

...Linking this back to my previous comment, GetVolumeInformation() returns the volume ID, which can easily be manipulated by the user, not the hard disk serial number which is built into the hardware. And any check such as this which is done through MQL4 code can be removed extremely easily by decompiling the EA.
Reason: