EA Protection & Licenses

MQL4 エキスパート

仕事が完了した

実行時間14 日
開発者からのフィードバック
A smart and patient customer with good coordination skill.
依頼者からのフィードバック
Top programmer, highly recomended

指定

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);
 }
};

応答済み

1
開発者 1
評価
プロジェクト
0
0%
仲裁
1
0% / 100%
期限切れ
0
2
開発者 2
評価
(1)
プロジェクト
1
0%
仲裁
2
0% / 100%
期限切れ
0
3
開発者 3
評価
(63)
プロジェクト
68
25%
仲裁
12
42% / 42%
期限切れ
4
6%
4
開発者 4
評価
(66)
プロジェクト
143
34%
仲裁
10
10% / 60%
期限切れ
26
18%
類似した注文
Creating of an expert advisor or trading bot that uses a Top Down analysis (using monthly, weekly, daily, hourly, minutes ( 30, 15, 5, 1) to determine trade direction or trend direction and makes multiple trade decisions for mt4. You can use or combine accurate trend indicators
Creating of an expert advisor or trading bot that uses a Top Down analysis (using monthly, weekly, daily, hourly, minutes ( 30, 15, 5, 1) to determine trade direction or trend direction and makes multiple trade decisions for mt4. You can use or combine accurate trend indicators
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA
I am looking forward to automate my trading strategy where I use renko bars on Tradingview. I really want to use unirenkos too, but unfortunately I couldn't figure out how to use ninjatrader on my MacBook and Tradingview does not offer unirenkos. As far as I see from your offered services you are very familiar with ninjatrader. I wanted to ask you if you could code me an Indicator for unirenkos for Tradingview so I
I am looking forward to automate my trading strategy where I use renko bars on Tradingview. I really want to use unirenkos too, but unfortunately I couldn't figure out how to use ninjatrader on my MacBook and Tradingview does not offer unirenkos. As far as I see from your offered services you are very familiar with ninjatrader. I wanted to ask you if you could code me an Indicator for unirenkos for Tradingview so I
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA
Hello, I want to create an EA that can be able to take and optimise trade bids using the trend tracker concept I have developed. The tracker will monitor 2 lines to determine the trend of the market and afterwards take bids towards the correct direction. It will also be able to use a distance between the bids for the direction of the trend and plan a reverse bid when the price of the extreme doesn’t change again. The
Gradient boosting and L2 100 - 200 USD
I am looking for a well experienced programmer to put/implement a gradient boosting algorithm and an L2 to reduce overfitting in my ea which l already have which uses indicators . If you are experienced please adhere
Hello, I'm looking for a developer for repair calendar in EA MT4/MT5 (News Filter - https://ec.forexprostools.com ) for all windows servers. Note: EA MT4/MT5 works with calendar on PC Win 10, 11 but not on all windows servers. I have the source code and will post within the comments section for review. If you are able to do this and quality. Please apply. Thanks
Create mt4 ea 50+ USD
To convert the provided MT4 indicator script into an Expert Advisor (EA) and implement prompt functionality for user input, we need to modify the code to handle external parameters and provide a user-friendly interface. Below is the EA code that incorporates prompts for user inputs

プロジェクト情報

予算
30+ USD
開発者用
27 USD