1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

Question CAn someone do coding In Ea for expiry with special condition

Discussion in 'Belajar MQL dari Nol' started by muhammadalidhedhi, 19 Nov 2017.

  1. muhammadalidhedhi

    muhammadalidhedhi Member

    Equity
    Credit
    Ref Point
    Hi guys,

    I want some expiry coding with special condition like
    If expiry is invalid and license key is valid than ea should not work
    for example if ea is running on demo account and expiry is not valid than ea should not work and same goes for live account

    these are the coding of ea for license and i want to add expiry coding like i have explained above to link with that expiry coding like ea will work if both condition meet
    no.1 condition should be expiry if expiry is invalid than ea should not even if license key is valid on demo or live condition

    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+
    int OnInit()
    {
    if(LicenseVerification())
    {
    return (INIT_SUCCEEDED);
    }
    else
    {
    return (INIT_FAILED);
    }
    //---
    }
    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
    //---

    }
    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    bool LicenseVerification()
    {
    if(AccountNumber()==0)
    {
    Alert("Seems You are not Connected to Internet. License Key verification Failed");
    return (false);
    }
    if(IsDemo()==true)
    {
    return (true);
    }

    /*** Login Key Generation Formula ***/
    int key=3*(StringToInteger(StringSubstr(IntegerToString(AccountNumber()), 0, 3)))+333333;

    if(LicenseKey==0)
    {
    Alert("Please Enter Your License Key in Inputs Section.");
    return (false);
    }

    if(LicenseKey==key)
    {
    Alert("License Key Verified");
    return (true);
    }
    else
    {
    Alert("Invalid License Key, Enter Correct License Key");
    return (false);
    }
    }
    //+------------------------------------------------------------------+
     
  2. arby1108

    arby1108 Member Credit Hunter

    Equity
    Credit
    Ref Point
    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+

    string ExpiryDate="2017.12.31";


    int OnInit()
    {
    if(TimeCurrent() >= StrToTime(ExpiryDate)){
    Alert("The trial Version of My EA has expired...");
    return(0);
    }

    if(LicenseVerification())
    {
    return (INIT_SUCCEEDED);
    }
    else
    {
    return (INIT_FAILED);
    }
    //---
    }
    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
    //---

    }
    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    bool LicenseVerification()
    {
    if(AccountNumber()==0)
    {
    Alert("Seems You are not Connected to Internet. License Key verification Failed");
    return (false);
    }
    if(IsDemo()==true)
    {
    return (true);
    }

    /*** Login Key Generation Formula ***/
    int key=3*(StringToInteger(StringSubstr(IntegerToString(AccountNumber()), 0, 3)))+333333;

    if(LicenseKey==0)
    {
    Alert("Please Enter Your License Key in Inputs Section.");
    return (false);
    }

    if(LicenseKey==key)
    {
    Alert("License Key Verified");
    return (true);
    }
    else
    {
    Alert("Invalid License Key, Enter Correct License Key");
    return (false);
    }
    }
    //+------------------------------------------------------------------+
     
    • Useful Useful x 1
  3. muhammadalidhedhi

    muhammadalidhedhi Member

    Equity
    Credit
    Ref Point
    Thanks Bro will try now and let you know if it working or not one thing i need to know that if i check this ea in offline still that expiry condition works or not
     
  4. muhammadalidhedhi

    muhammadalidhedhi Member

    Equity
    Credit
    Ref Point
    requirement is fullfilled but still ea is attached with the chart after getting alert that ea is expired and ea is working in backtest
     
  5. muhammadalidhedhi

    muhammadalidhedhi Member

    Equity
    Credit
    Ref Point
    Thanks bro i have edited now its ok
     
  6. grugged

    grugged Member Credit Hunter

    Equity
    Credit
    Ref Point
    Please can someone give some lines that can pause a running EA when some condition is met. I have tried sleep() and it does not seem to work.

    Thanks
     
  7. arby1108

    arby1108 Member Credit Hunter

    Equity
    Credit
    Ref Point
    let me an example of a condition on which one you what pause EA,
     
  8. arby1108

    arby1108 Member Credit Hunter

    Equity
    Credit
    Ref Point
    if (NormalizeDouble(Ask - Bid, Digits) < NormalizeDouble(MaxSpread * Point, Digits)) LowSpread = 1;
    else {LowSpread = 0; Print("Spread to High ");}

    if (LowSpread == 1) ticket=OrderSend(Symbol(),OP_BUY,tempLot(),Ask,(int)MarketInfo(Symbol(),MODE_SPREAD),0,0,Comments,Magic,0,Blue);

    this pice of code check if spread is lower than MaxSpread to open an order, if spread is higer it don't open any order
     

Share This Page