I am new to coding and would like to add a code to expire an EA in say 10 days. How do I do this?
Thank you
string expire_date = "2006.06.11"; datetime e_d = StrToTime(expire_date); if (CurTime() >= e_d) { Alert ("The trial version has been expired!"); return(0); }
That part should work, depending on where you put it in your program.
Post all your code so we can see what else you are doing,
That part should work, depending on where you put it in your program.
Post all your code so we can see what else you are doing,
extern string ExpertName = "Close All Open & Pending Trades"; string expire_date = "2006.06.11"; datetime e_d = StrToTime(expire_date); if (CurTime() >= e_d) { Alert ("The trial version has been expired!"); return(0); } //Start++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ int start() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); break; //Close pending orders case OP_BUYLIMIT : case OP_BUYSTOP : case OP_SELLLIMIT : case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } if(result == false) { Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); Sleep(3000); } } return(0); }
Are you trying to create a script or an indicator?
Ah, an EA... Ok...
Put your expiration code after start(){
Are you trying to create a script or an indicator?
Ah, an EA... Ok...
Put your expiration code after start(){
Yes. Examples:
---
(easy)
Have the EA create a file containing the time of the first run. (this is easy to defeat, if they know it is there)
Have the EA check for existence of the file, if it is there, read it, if not there create it.
Use the date in the file.
---
(hard)
Create a DLL
Have it "phone home" to your server for permission, accessing a database of your authorized users.
---
Yes. Examples:
---
(easy)
Have the EA create a file containing the time of the first run. (this is easy to defeat, if they know it is there)
Have the EA check for existence of the file, if it is there, read it, if not there create it.
Use the date in the file.
---
(hard)
Create a DLL
Have it "phone home" to your server for permission, accessing a database of your authorized users.
---
do you have a link on how to do it??
Yes. Examples:
---
(easy)
Have the EA create a file containing the time of the first run. (this is easy to defeat, if they know it is there)
Have the EA check for existence of the file, if it is there, read it, if not there create it.
Use the date in the file.
---
(hard)
Create a DLL
Have it "phone home" to your server for permission, accessing a database of your authorized users.
---

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Thank you