stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

How to add account protection in mql4 code
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4115
Page 1 of 1
Author:  komoles69 [ Sun Feb 15, 2015 7:48 pm ]
Post subject:  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 :jump:
Author:  milanese [ Sun Feb 15, 2015 8:07 pm ]
Post subject:  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 :jump:
The code of the new Empty4 build is not easy to decomplie as older versions were (509 and older)..
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
}
As the compressed code will not easy to be edited...

Cheers :)

Tommaso
Author:  komoles69 [ Mon Feb 16, 2015 11:04 am ]
Post subject:  How to add account protection in mql4 code

Thank you.... :hi:
Author:  MrLong [ Tue Feb 17, 2015 1:14 pm ]
Post subject:  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 :jump:

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;
  }
Andy
Author:  milanese [ Tue Feb 17, 2015 1:23 pm ]
Post subject:  How to add account protection in mql4 code

MrLong » Tue Feb 17, 2015 1:14 pm wrote:
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;
  }
Andy
with new builds there is no need for the

Code: Select all

int hWnd=WindowHandle(Symbol(),0);

   PostMessageA(hWnd,WM_COMMAND,EA_KILL,0);
better you will use

Code: Select all

ExpertRemove();
Cheers :)

Tommaso
Author:  MrLong [ Tue Feb 17, 2015 2:57 pm ]
Post subject:  How to add account protection in mql4 code

Thanks.
All times are UTC Page 1 of 1