![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Since this thread, I have needed to do something similar i.e. lock an EA to an account and have an expiry date which is potentially different for every user without going down the DLL route.
The approach I took was:
The EA runs (a part of) the account number through CryptEncode. It pops up on the screen and the User hands it over to get their activation key.
You have a script which takes this encoded account number (supplied by the User), tags a date on the end and encrypted it again. This becomes the activation key that is sent back to the User.
The User enters the activation key as an input setting.
The EA decrypts the activation key back into an encrypted account number with a date tagged on the end. It checks that (1) the encrypted account number matches the current account number, and (2) that the expiry date has not passed.
This process could be simplified further if you don't want to lock the EA to a specific account.
Hope that helps someone
I know this is an old thread, but I recently came across as the same question Gordon was asking here. Yes it is possible to reverse the output of ArrayToHex. Here's my (very inelegant) solution. It should print two identical copies of the string to the Experts log. I'm sure there's a better way to perform the actions my HexToDecimal function's doing, but hey it was written at 2am :)
...
bool HexToArray(string str, uchar &arr[])
{int arrcount = ArraySize(arr);
int strcount = StringLen(str);
if (arrcount < strcount / 2) return false;
int i=0, j=0;
for (i=0; i<strcount; i+=2)
{
string sub = StringSubstr(str, i, 2);
uchar tmpchr = HexToDecimal(StringSubstr(str, i, 1))*16 + HexToDecimal(StringSubstr(str, i+1, 1));
arr[j] = tmpchr;
j++;
}
return true;
}
Just for fun. Here is my version, more than 10 times faster :-)
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool HexToArray2(string str,uchar &arr[])
{
int strcount = StringLen(str);
int arrcount = ArraySize(arr);
if(arrcount < strcount / 2) return false;
uchar tc[];
StringToCharArray(str,tc);
int i=0, j=0;
for(i=0; i<strcount; i+=2)
{
uchar tmpchr=(HEXCHAR_TO_DECCHAR(tc[i])<<4)+HEXCHAR_TO_DECCHAR(tc[i+1]);
arr[j]=tmpchr;
j++;
}
return true;
}
Just for fun. Here is my version, more than 10 times faster :-)