How to add account protection in mql4 code
-
komoles69
How to add account protection in mql4 code
i need code for protect my ea for my client also time limit protection for demo version . i have old code that not working in 600++. Please help me 
- milanese
- TechAdmin
- Posts: 3293
- Joined: Wed Jan 09, 2013 9:02 am
- Location: btr rdx, r8 +
How to add account protection in mql4 code
The code of the new Empty4 build is not easy to decomplie as older versions were (509 and older)..komoles69 » Sun Feb 15, 2015 7:48 pm wrote:i need code for protect my ea for my client also time limit protection for demo version . i have old code that not working in 600++. Please help me
New ex4 are native code (like DLL) and no more pseudo code. So they are more difficult to decompile.
New ex4 are compressed (or other obfuscation technique not known) so have decompiled it's hard to understand it.
The ex4 for Market are encrypted. The exact technique used is not publicly available.
About the limit protection you can easy code a check like:
Code: Select all
if(TimeCurrent()>StrToTime(expiryDate))
{
//put here what you want your EA in that case to do
}Cheers
Tommaso
Global Prime is the official SHF broker 
Searching for Servers and Workstations with individual configuration?
Just PM
Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
Searching for Servers and Workstations with individual configuration?
Just PM
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
-
MrLong
How to add account protection in mql4 code
komoles69 » Sun Feb 15, 2015 7:48 pm wrote:i need code for protect my ea for my client also time limit protection for demo version . i have old code that not working in 600++. Please help me
I do the following:
Code: Select all
#include <WinUser32.mqh>
datetime ExpirationTime=D'2015.04.28 00:00'; //set up any date and time
datetime WarningTime=D'2015.04.27 00:00'; //set up any date and time
//int init()
if(TimeCurrent()>=WarningTime || TimeLocal()>=WarningTime)
Alert("Expert will expired, withi 24 hours.");
if(TimeCurrent()>=ExpirationTime || TimeLocal()>=ExpirationTime)
{
Alert("Expert has expired");
SelfDestruct();
return(0);
}
//int start()
if(TimeCurrent()>=ExpirationTime || TimeLocal()>=ExpirationTime)
{
Alert("Expert has expired");
SelfDestruct();
return(0);
}
//+------------------------------------------------------------------+
//| Remove when expired |
//+------------------------------------------------------------------+
void SelfDestruct()
{
abort=true;
Print("Self-destruct initiated");
int hWnd=WindowHandle(Symbol(),0);
PostMessageA(hWnd,WM_COMMAND,EA_KILL,0);
return;
}- milanese
- TechAdmin
- Posts: 3293
- Joined: Wed Jan 09, 2013 9:02 am
- Location: btr rdx, r8 +
How to add account protection in mql4 code
with new builds there is no need for theMrLong » Tue Feb 17, 2015 1:14 pm wrote:
I do the following:
AndyCode: Select all
#include <WinUser32.mqh> datetime ExpirationTime=D'2015.04.28 00:00'; //set up any date and time datetime WarningTime=D'2015.04.27 00:00'; //set up any date and time //int init() if(TimeCurrent()>=WarningTime || TimeLocal()>=WarningTime) Alert("Expert will expired, withi 24 hours."); if(TimeCurrent()>=ExpirationTime || TimeLocal()>=ExpirationTime) { Alert("Expert has expired"); SelfDestruct(); return(0); } //int start() if(TimeCurrent()>=ExpirationTime || TimeLocal()>=ExpirationTime) { Alert("Expert has expired"); SelfDestruct(); return(0); } //+------------------------------------------------------------------+ //| Remove when expired | //+------------------------------------------------------------------+ void SelfDestruct() { abort=true; Print("Self-destruct initiated"); int hWnd=WindowHandle(Symbol(),0); PostMessageA(hWnd,WM_COMMAND,EA_KILL,0); return; }
Code: Select all
int hWnd=WindowHandle(Symbol(),0);
PostMessageA(hWnd,WM_COMMAND,EA_KILL,0);Code: Select all
ExpertRemove();Tommaso
Global Prime is the official SHF broker 
Searching for Servers and Workstations with individual configuration?
Just PM
Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
Searching for Servers and Workstations with individual configuration?
Just PM
NOTE: Cookies and JavaScript are required for the using the board, with full functionality