- is there any solution for multi symbols back testing ?
- Is it possible to get the user placed Indicator parameters values in code
- How to get data from custom indicator in mql4
Hi I write some Custom Indicator in MQL4 and MQL5. I currently use account number and broker name so that each indicator can be executed on only one account. But I have to change this value for every user who wants to buy my indicator. For this reason, I want to take the serial number of the user's motherboard and hard drive and store it on a server through an API. So that every license I create runs on one system and not one account. So how can do this? In my search I do not find any solution in Mql5 and 4. is there any third party dll and solution for this? please help.
Unfortunately that will not work for when the terminal is used in portable mode, where one can place it wherever, including the same path on different computers.
Here is an example from one of my setups, which is the same on both my home computer and VPS.
Print( TerminalInfoString( TERMINAL_PATH ) ); Print( TerminalInfoString( TERMINAL_DATA_PATH ) );
2023.10.30 12:05:59.362 TestCalc (AUDNZD,H1) C:\Trading\MetaQuotes\MetaTrader 5 2023.10.30 12:05:59.362 TestCalc (AUDNZD,H1) C:\Trading\MetaQuotes\MetaTrader 5
Hi I write some Custom Indicator in MQL4 and MQL5. I currently use account number and broker name so that each indicator can be executed on only one account. But I have to change this value for every user who wants to buy my indicator. For this reason, I want to take the serial number of the user's motherboard and hard drive and store it on a server through an API. So that every license I create runs on one system and not one account. So how can do this? In my search I do not find any solution in Mql5 and 4. is there any third party dll and solution for this? please help.
You can use GumRoad . It tracks licenses and how many instances are active . The API will provide the buyer with a code and that code can be added in the Indicator in the inputs tab for checking the license .I don't remember if it tracks by ip or machine but since its online it probably is per ip (some changes may have occured as this was the case 2 years ago,also the new designs hurts the eyes) .
Unfortunately that will not work for when the terminal is used in portable mode, where one can place it wherever, including the same path on different computers.
Here is an example from one of my setups, which is the same on both my home computer and VPS.
Also now I have another problems, I ask here. I will be happy if you answer this too.But if you think a separate topic should be created for it. After getting the answer I create their current answer.
1. I find id that the WebRequest not working on Custom Indicator. So for check it my Indicator, I should create EA that user enter their license for the Indicator as input parameter in it. am I right?
2. then send this license and motherboard serial number through the API to my server to check if the license correct and the system is the same as before and not the new system.
3. After the License find is correct and active i save the motherboard serial number as encrypted data in the file, registry or the global variable of meta trader . but the file and registry can be easily manipulated. specially the global variable can be easily change of remove when user click on F3 key. so how can secure this?
4. after all of this I get the motherboard serial number in the Indicator too. then check if that EA exist and run on any chart. also check if the motherboard serial number is the same as the data retrieve from EA. if Everything current the indicator can run otherwise should remove from the chart.
Currently I find this solution for my problems. but I do not Know if this is correct or not. or if we have better solution. please answer this questions too. or at least for the API and i ask them in the separated topic later.
thank you.
thank you for your response. So the third party library is the only way I have for getting the user system data like motherboard and created uniq data for each system base on them. can you introduce the library for this?
Also now I have another problems, I ask here. I will be happy if you answer this too.But if you think a separate topic should be created for it. After getting the answer I create their current answer.
1. I find id that the WebRequest not working on Custom Indicator. So for check it my Indicator, I should create EA that user enter their license for the Indicator as input parameter in it. am I right?
2. then send this license and motherboard serial number through the API to my server to check if the license correct and the system is the same as before and not the new system.
3. After the License find is correct and active i save the motherboard serial number as encrypted data in the file, registry or the global variable of meta trader . but the file and registry can be easily manipulated. specially the global variable can be easily change of remove when user click on F3 key. so how can secure this?
4. after all of this I get the motherboard serial number in the Indicator too. then check if that EA exist and run on any chart. also check if the motherboard serial number is the same as the data retrieve from EA. if Everything current the indicator can run otherwise should remove from the chart.
Currently I find this solution for my problems. but I do not Know if this is correct or not. or if we have better solution. please answer this questions too. or at least for the API and i ask them in the separated topic later.
thank you.
Sorry for interjecting , Fernando may answer if he wants separately .
- A person buys your indicator , you give them a serial key
- The serial key is sent along with the ip and the hardware info and user info to your server
- Your server keeps tab of how many ips are active for that serial key.
You have to anticipate the following :
- User uses the indicator in multiple devices
- User uses the indicator in multiple devices and multiple ips
- User's IP changes so you need a cooling off period before you decide to discontinue service
- Hackers are always better than coders
Sorry for interjecting , Fernando may answer if he wants separately .
- A person buys your indicator , you give them a serial key
- The serial key is sent along with the ip and the hardware info and user info to your server
- Your server keeps tab of how many ips are active for that serial key.
You have to anticipate the following :
- User uses the indicator in multiple devices
- User uses the indicator in multiple devices and multiple ips
- User's IP changes so you need a cooling off period before you decide to discontinue service
- Hackers are always better than coders
You should learn to code such a DLL yourself. It is in not a trivial task nor can such a task be generalised. It has to be made in accordance with your specific requirements.
thank you for your help. so can you introduce the dll for communicating with the server without a webrequest in custom indicator. and also dll for read the motherboard and hard serial number please. I can not find it until now.
try this , i havent used wininet for a long time however so not sure how much things differ now.
- www.mql5.com
thank you for your help. I now the C# language and create this Dll right now:
using System.Management; namespace SystemInformation { public class SystemInfo { public string GetMotherboardSerialNumber() { using (var searcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BaseBoard")) { foreach (var queryObj in searcher.Get()) { return queryObj["SerialNumber"].ToString(); } } return string.Empty; } public string GetStorageDeviceSerialNumber() { using (var searcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_DiskDrive WHERE MediaType='Fixed hard disk media'")) { foreach (var queryObj in searcher.Get()) { return queryObj["SerialNumber"].ToString(); } } return string.Empty; } } }
then copy it on the library folder and call it like this in my Custom indicator:
#import "SystemInformation.dll" string GetMotherboardSerialNumber(); string GetStorageDeviceSerialNumber(); #import int OnInit() { string motherBoard = GetMotherboardSerialNumber(); string hardDrive = GetStorageDeviceSerialNumber(); Alert(motherBoard + " " + hardDrive); return(INIT_SUCCEEDED); }
after Compile the indicator not getting error and everything is seems fine. but want drag it on the chart or dubbing in real data, in journal tab message show the indicator load successfully but not working and show anything. also when i put the debug poing on my code after code read this line (string motherBoard) the program is dropped and not going further. how to fix this?
I find the solution with some help and search the internet for both mql4 and mlq5 to create and add C# DLL and add it to the custom indicator and Expert Adviser:
for mql5:
we only need add the static to method, so the code change like this:
using System.Management; namespace SystemInformation { public class SystemInfo { public static string GetMotherboardSerialNumber() { using (var searcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BaseBoard")) { foreach (var queryObj in searcher.Get()) { return queryObj["SerialNumber"].ToString(); } } return string.Empty; } public static string GetStorageDeviceSerialNumber() { using (var searcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_DiskDrive WHERE MediaType='Fixed hard disk media'")) { foreach (var queryObj in searcher.Get()) { return queryObj["SerialNumber"].ToString(); } } return string.Empty; } } }
and then add this too mql5:
#import "SystemInformation.dll" int OnInit() { string motherboard = SystemInfo::GetMotherboardSerialNumber(); string hardDrive = SystemInfo::GetStorageDeviceSerialNumber(); Alert(motherBoard + " " + hardDrive); return(INIT_SUCCEEDED); }
for the mql4:
you can use this 2 link for the start: https://www.mql5.com/en/forum/353293[^]Calling a DLL from MQL | Andres Jaimes[^]
first of all we should put the output project on x86 and .NET framework 3.5. also need install package unmanaged exports for nugget. because the MQL4 only can read the x86 and C++ DLL so we need the unmanagedexports to worked as the middle ware.
the example on 2 link is worked but for the string we should do the extra work. because the MQL4 encoding the string in UTF-16 or UCS-2. so you should convert the string in utf-16 code on DLL.
the final code for C# DLL and change the code too this is:
using RGiesecke.DllExport; using System.Runtime.InteropServices; using System.Management; using System; namespace SystemInformationMQL4 { public class Class1 { [DllExport("GetMotherboardSerialNumber", CallingConvention = CallingConvention.StdCall)] public static IntPtr GetMotherboardSerialNumber() { string serialNumber = string.Empty; using (var searcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BaseBoard")) { foreach (var queryObj in searcher.Get()) { serialNumber = queryObj["SerialNumber"].ToString(); break; // only need the first result } } return Marshal.StringToHGlobalUni(serialNumber); } [DllExport("GetStorageDeviceSerialNumber", CallingConvention = CallingConvention.StdCall)] public static IntPtr GetStorageDeviceSerialNumber() { string serialNumber = string.Empty; using (var searcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_DiskDrive WHERE MediaType='Fixed hard disk media'")) { foreach (var queryObj in searcher.Get()) { serialNumber = queryObj["SerialNumber"].ToString(); break; // only need the first result } } return Marshal.StringToHGlobalUni(serialNumber); } } }
and the mql4 code is:
#import "SystemInformationMQL4.dll" string GetMotherboardSerialNumber(); string GetStorageDeviceSerialNumber(); #import int OnInit() { string motherBoard = GetMotherboardSerialNumber(); string hardDrive = GetStorageDeviceSerialNumber(); Alert(motherBoard + " " + hardDrive); return(INIT_SUCCEEDED); }
so everything worked fine in both mql4 and 5 now.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use