How to add account protection in mql4 code

Post Reply
komoles69

How to add account protection in mql4 code

Post by komoles69 »

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:
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

How to add account protection in mql4 code

Post by milanese »

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
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
komoles69

How to add account protection in mql4 code

Post by komoles69 »

Thank you.... :hi:
MrLong

How to add account protection in mql4 code

Post by MrLong »

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
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

How to add account protection in mql4 code

Post by milanese »

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
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
MrLong

How to add account protection in mql4 code

Post by MrLong »

Thanks.
Post Reply

Return to “Coders Hangout”