EA Protection & Licenses

MQL4 Experts

Trabalho concluído

Tempo de execução 14 dias
Comentário do desenvolvedor
A smart and patient customer with good coordination skill.
Comentário do cliente
Top programmer, highly recomended

Termos de Referência

Hi guys,

I need a code to carry out a web request to verify account number and password to secure my ea template. So when the ea is started a webrequest is done to check if account number and passwords is authorized to use the EA. API part is all set up

the list is in the following format 

so the steps are

1. login to api

2.check if account number and password are there.

3. if account number and password are there, run the EA. IF not shut down EA.

number of account number          password

12345....                                      example...........

I have attached some code if it helps.

class CLicenseOnline : public CObject
  {
private:
   string               m_login;
   string               m_password;
   datetime             m_nextCheck;
   int                  m_prevResult;
   string               m_url;
   int                  m_strategyId;
public:
                    CLicenseOnline(const string login,const string password,const int id):
                                m_login(login),m_password(password),m_nextCheck(0),m_strategyId(id),m_prevResult(-1)
 {

  bool isCheckingRequired=false;
  if(CLicenseOnline::isSuperAdmin(login,password))
    {
     printf("%i %s - Hello, SUPER ADMIN!",__LINE__,__FILE__);
     isCheckingRequired=true;
    }
  isCheckingRequired= isCheckingRequired || IsTesting();
  if(isCheckingRequired)
    {
     m_nextCheck=INT_MAX;
     m_prevResult=1;
    }
  else
    {
     m_url=CLicenseOnline::genUrl(login,password);
    }
 }
                   ~CLicenseOnline(){}
   int                  check()
 {
  if(TimeCurrent()>m_nextCheck)
    {
     int result=this.checkMain();
     switch(result)
       {
        case 1: m_nextCheck=this.generateNextDate();    m_prevResult=1;break;
        default:
        case 0: m_nextCheck=TimeCurrent()+PeriodSeconds(PERIOD_M1);  m_prevResult=0;break;
        case-1: m_nextCheck=TimeCurrent()+PeriodSeconds(PERIOD_H1);  m_prevResult=-1;break;
       }
    }
  return(m_prevResult);
 }
    static string           genUrl(const string login,const string password)
 {
  const string http="localhost";
  return(StringFormat("http://%s/verify/?Login=%s&&Password=%s&&Check=%d",http,login,password,2147483647));
 }
    static string           getHttpResponce(const string url)
 {
  char data[],res[];
  string cookies=NULL, headers=NULL,result;
  ResetLastError();
  int answer = WebRequest("GET",url,cookies,NULL,5000,data,0,res,headers);
  if(answer==200)
    {
     result = CharArrayToString(res);
     return(result);        
    }
  //printf("%i - result=%d|%s|size=%d; %d",__LINE__,answer,result,ArraySize(res),GetLastError());      
  return(NULL);
 }

private:
static bool             isSuperAdmin(const string login,const string password)
 {
  static string 
        superAdminLogin="Admin", 
        superAdminPassword="password";
           //ATTENTION! Edit the login and password here!
  return login==superAdminLogin && password==superAdminPassword;
 }
datetime             generateNextDate()const
 {
  return(iTime(_Symbol,PERIOD_D1,0)+PeriodSeconds(PERIOD_D1)+MathRand()%PeriodSeconds(PERIOD_D1));
 }
int                  checkMain()const
 {
  string respond=CLicenseOnline::getHttpResponce(m_url);
  if(respond==NULL)
     return(0);//try later
  CJAVal js(NULL,jtUNDEF);
  if(!js.Deserialize(respond))
    {
     printf("%i %s - failed to deserialize %s",__LINE__,__FUNCTION__,respond);
     return(-1);
    }
  int retCode=(int)js["key"].ToInt();
  switch(retCode)
    {
     case -1: Alert("incorrect password");return(0);
     case -2: Alert("incorrect key!");return(0);
     case -3: Alert("incorrect request method!");return(0);
     case -4: 
     case -5: Alert("no such login");return(0);
     default:
        Alert(StringFormat("%i %s - incorrect login/password/no such user!",__LINE__,__FUNCTION__));
        return(0);
     case 200:
       {
        CJAVal *valueJs=js["value"];
        if(!this.checkStatus(valueJs["Status"].ToStr()))
           return(-1);
        if(!this.checkAccount(
              (int)valueJs["Allow_account_1"].ToInt(),(int)valueJs["Allow_account_2"].ToInt(),(int)valueJs["Allow_account_3"].ToInt()))
           return -1;
        bool strategyX=(bool)valueJs["Allow_strategy_"+(string)m_strategyId].ToBool();
        if(!stategyX)
          {
           return(-1);
          }
        return(1);
       }
    }
  return(-1);
 }
bool                 checkStatus(const string status)const
 {      //printf("%i %s - status = |%s|%d",__LINE__,__FUNCTION__,status,IsDemo());
  if(status=="demo")
    {
     if(!IsDemo())
       {
        string message=StringFormat("your login %s is allowed to trade on Demo accounts only!",m_login);
        Alert(message);
        printf("%i %s - %s",__LINE__,__FILE__,message);
        return(false);
       }
     return(true);
    }
  if(status!="active")
    {
     string message=StringFormat("status of your login [%s] is [%s] so not allowed to trade!",m_login,status);
     Alert(message);
     printf("%i %s - %s",__LINE__,__FILE__,message);
     return(false);
    }
  return(true);
 } 
bool                 checkAccount(const int acc1,const int acc2,const int acc3)const
 {
  if(acc1==0 && acc2==0 && acc3==0)
     return(true);
  int currentAccount=AccountNumber();
  if(acc1==currentAccount || acc2==currentAccount || acc3==currentAccount)
     return(true);
  string message=StringFormat("allowed accounts are only %d, %d and %d, your account %d is not allowed!",acc1,acc2,acc3,currentAccount);
  Alert(message);
  printf("%i %s - %s",__LINE__,__FUNCTION__,message);
  return(false);
 }
};

Respondido

1
Desenvolvedor 1
Classificação
Projetos
0
0%
Arbitragem
1
0% / 100%
Expirado
0
Livre
2
Desenvolvedor 2
Classificação
(1)
Projetos
1
0%
Arbitragem
2
0% / 100%
Expirado
0
Livre
3
Desenvolvedor 3
Classificação
(63)
Projetos
68
25%
Arbitragem
12
42% / 42%
Expirado
4
6%
Livre
4
Desenvolvedor 4
Classificação
(66)
Projetos
143
34%
Arbitragem
10
10% / 60%
Expirado
26
18%
Livre
Pedidos semelhantes
I have a custom EA that works fine in the live market trading, but when doing a back test in the strategy tester , it does not open sell orders. There are no errors or warnings; it just doesn't open sell orders. I've checked every possible reason that might be the reason why it does not open sell orders, but I can't find anything, especially since it works fine in the real market and it opens both buys and sells
The Expert Advisor would use two built-in indicators as entry/exit signals and our own risk management strategy with customizable inputs. The goal is to create a reliable and efficient trading tool that can automate our trading process on the MT5 platform
Hi, I have an indicator from my friend, I want to copy it to my own MT5 can you do that for me. Here is the link
I installed the E.A. into the Experts folder in MT4. When I double click on it nothing happens. When I right click and "attach to chart" nothing happens. The E.A. is not grayed out, it simply will not attach. Any help would be greatly Appreciated
I have an EA and want to add few new logic to fetch profit taking factors and other values from an external master data and use it in existing EA
Hello Every one, Good day, I want from someone professional to create an EA is working on Mt5, This EA is working by depend on some indicators, and all those indicators must be working on MACD window, not on the chart, for more details please read my attached pdf file carefully. Many Thanks
I'm looking for an expert MQL5 developer that can create an EA that's based on my price action trading strategy with no indicators. The EA must analyze trades based on my price action rules, enter trades based on my price action rules, manage trades based on my price action rules and exit trades based on my price action rules
hi hi there i have an strategy on tradingview and i want to automate it like metatrader EA so i want the strategy to open and close trade automaticlly on tradingview
We are looking for an experienced Expert Advisor Developer who can build a customized MT5 Expert Advisor for us. The Expert Advisor would use two built-in indicators as entry/exit signals and our own risk management strategy with customizable inputs. The goal is to create a reliable and efficient trading tool that can automate our trading process on the MT5 platform. Skills required: - Strong understanding of
I need stochastic div (hidden &regular ea) that should perform task in all tf's ..divergence is a repaint stly so i want to use it with candlestick flips .. so bet for it

Informações sobre o projeto

Orçamento
30+ USD
Desenvolvedor
27 USD