how do i put this code into my indicator to protect it

 

hi i want to use this code to protect my indicator

Protection by Time
Another way to protect an Expert Advisor is to limit its work by time. You can let it work only until a certain date on any account or server. When demo period expires, the Expert Advisor will no longer work and user will have to ask you for properly protected version of the expert.

Here is the text of the script with this mechanism of protection.

//+------------------------------------------------------------------+
//|                                                  Protect-005.mq4 |
//|                                Copyright © 2009, Sergey Kravchuk |
//|                                         http://forextools.com.ua |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Sergey Kravchuk"
#property link      "http://forextools.com.ua"

int start()
{  
  string char[256]; int i;

  for (i = 0; i < 256; i++) char[i] = CharToStr(i);

  // Date, until which the expert is allowed to work
  int LastAllowedDate = StrToTime(
  /* 2009.09.11 23:59:00 */ 
  char[50]+char[48]+char[48]+char[57]+char[46]+char[48]+char[57]+char[46]+char[49]+
  char[49]+char[32]+char[50]+char[51]+char[58]+char[53]+char[57]+char[58]+char[48]+char[48]

  ); 

  if (TimeCurrent() >= LastAllowedDate) 
  {
    Print("Demo period has expired " + TimeToStr(LastAllowedDate,TIME_DATE|TIME_SECONDS));
    return(1);
  }
  
  Print("You can work until "+ TimeToStr(LastAllowedDate,TIME_DATE|TIME_SECONDS));
}

now how do i put the code above into this indicator code below to protect it by time for all of next week

note this is not my modified indicator but the example i used to modifiy and get my new indicator

//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+

//
//    ?????????? ?? ???????????? ???D 
//    1. ?????????? ? ????? ??/??
//    2. ???????? ?? ??????????? ???????? ????
//
//    Difference from ???D of standart
//    1. color of style of AC/AO
//    2. unvisible null bar
#property  copyright "Aleksandr Pak,Almaty, 2006"
#property  link  "ekr-ap@mail.ru" 
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Green
#property  indicator_color2  Red
#property  indicator_color3  Silver

#property  indicator_width1  2
#property  indicator_width2  2
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double     MacdBuffer[],   MacdBufferUp[],   MacdBufferDown[];
double     SignalBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
  IndicatorBuffers(4);
   
   SetIndexBuffer (0,MacdBufferUp);
   SetIndexStyle  (0,DRAW_HISTOGRAM);
   SetIndexBuffer (1,MacdBufferDown); 
   SetIndexStyle  (1,DRAW_HISTOGRAM);
   SetIndexBuffer (2,SignalBuffer);
   SetIndexStyle  (2,DRAW_LINE);
   SetIndexDrawBegin(2,SignalSMA);
   SetIndexBuffer (3,MacdBuffer);
   SetIndexStyle  (3,DRAW_NONE);   
   
   SetIndexLabel  (0,"Buffer 0");
   SetIndexLabel  (1,"Buffer 1");
   SetIndexLabel  (2,"Signal");
   IndicatorDigits(Digits+3);
   IndicatorShortName("MACD_color("+FastEMA+","+SlowEMA+","+SignalSMA+")");
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(i=0; i<limit; i++)
         {
         MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
         }
   for(i=0; i<limit; i++)
   {
      MacdBufferDown[i]=0.0; MacdBufferUp[i]=0.0;
     
         if(i>=0) //??? ????? ?? ??????????? ???????? ???? //break the null bar  
            {
               if(MacdBuffer[i]-MacdBuffer[i]>=0)MacdBufferDown[i]=MacdBuffer[i]; //??????? ???????? //condition of color
                  else MacdBufferUp[i]=MacdBuffer[i];}
            }
   for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
   return(0);
  }
//+------------------------------------------------------------------+
 
Just put the code at the top of start(), but this is not going to protect anything. Search, for more info -> https://www.mql5.com/en/search.
 

what do you mean it not going to protect anything

 
hustlerscreed:

what do you mean it not going to protect anything

The indicator can be easily decompiled and the 'protection' code removed. Again, this subject has been discussed many time, so please search and read about it.
 

i info does not explain it very well

 
Which part don't u understand? Compiled MQL4 code can be easily decompiled. This means that anyone can take your compiled indicator and convert it back to source code. Then all he has to do is erase the lines that "protect" the indicator (even a beginner would mange to do that) and recompile it. So this protection is worthless... Get it?
 
the only way to protect mql4 program is to hide the most of it into a dll. Even this is not 100% protected but crack Dlls is harder than ex4.
 
 /* 2009.09.11 23:59:00 */ 
  char[50]+char[48]+char[48]+char[57]...
can be simplified by
 '2'+'0'+'0'+'9'...
Still useless though
 
 
encrypted file -> ex4guardian -> mt4 memory -> memory dump -> find code -> decompile -> no protection.
 
wow this is interesting although i haven't write any commercial codes... but i think metaquotes should eye on this...
Reason: