• 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 :)

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

Credits
0
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);
}
}
//+------------------------------------------------------------------+
 
//+------------------------------------------------------------------+
//| 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);
}
}
//+------------------------------------------------------------------+
 
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
 
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
 
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
 
Back
Top