Guest dave_rimmer Posted December 7, 2009 Report Share Posted December 7, 2009 Can someone modify this Close all profit loss ea , so it has ''symbol specific'' and ''magic number'' as external parameters. This ea closes orders ''fast'' 100% of the time, I have tried many management ea's like swiss army but they dont always close. This is handy as a global closure for set profit and loss on an account but i need it to be magic and symbol specific so it only closes down orders on whatever i am running 'ea;s' without affecting others i am running on same terminal. Many Kudos If one can help http://depositfiles.com/files/ksa76zzje Quote Link to comment Share on other sites More sharing options...
scarface Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi dave_rimmer, Good day, I'm not a pro programmer, but maybe I can help you with something since you are looking for CloseAll indicator or EA. I'm still intermediate programmer, but I guess these CloseAll EAs will help depending on your needs. This is a short explanation for options of CloseAll.mq4: // Set this prameter to the type of clsoing you want: // 0- Close all (instant and pending orders) (Default) // 1- Close all instant orders // 2- Close all pending orders // 3- Close by the magic number // 4- Close by comment // 5- Close orders in profit // 6- Close orders in loss // 7- Close not today orders http://rapidshare.com/files/317819983/CloseAll.mq4.html And here another one: http://rapidshare.com/files/317820215/CloseAll-PL.mq4.html And this one close based on the time: http://rapidshare.com/files/317820524/CloseOnTime.mq4.html If there is anything I can do, please let me know. Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
Guest dave_rimmer Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Good day, I'm not a pro programmer, but maybe I can help you with something since you are looking for CloseAll indicator or EA. I'm still intermediate programmer, but I guess these CloseAll EAs will help depending on your needs. This is a short explanation for options of CloseAll.mq4: // Set this prameter to the type of clsoing you want: // 0- Close all (instant and pending orders) (Default) // 1- Close all instant orders // 2- Close all pending orders // 3- Close by the magic number // 4- Close by comment // 5- Close orders in profit // 6- Close orders in loss // 7- Close not today orders http://rapid*share.com/files/317819983/CloseAll.mq4.html And here another one: http://rapid*share.com/files/317820215/CloseAll-PL.mq4.html And this one close based on the time: http://rapid*share.com/files/317820524/CloseOnTime.mq4.html If there is anything I can do, please let me know. Best wishes, hi and thanks..the first one 'close all' would be ok if you can set a figure amount for closure,However the reason why i ask for my version to be modified is because it closes VERY FAST!!! Quote Link to comment Share on other sites More sharing options...
scarface Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, I will give it a try and see if works that way you want. You should know there is no promise about that, but as I said I'll do what I can. I might a little bit late since there are other requests on modification EAs and indicators. Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
scarface Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, Here you are. I tried and didn't check it yet. You can try it yourself and tell me whether it works or not. By the way, add a number like 32134 to the magic number so it works. Here is the download link: http://rapidshare.com/files/318004100/CloseAllProfit.mq4.html Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
Guest dave_rimmer Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, Here you are. I tried and didn't check it yet. You can try it yourself and tell me whether it works or not. By the way, add a number like 32134 to the magic number so it works. Here is the download link: http://rapid*share.com/files/318004100/CloseAllProfit.mq4.html Best wishes, Hi Seems fine but to make it perfect if you could add also ext 'symbols' and 'trade comment ..this will make this ea universal and a very good trading tool Quote Link to comment Share on other sites More sharing options...
scarface Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, I have added the symbol function so it should be fine now. You can try it and see how it works. I just want to know what do you mean by trade comments, I mean what kind?? http://rapidshare.com/files/318021578/CloseAllProfit_v1.mq4.html Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
Guest dave_rimmer Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, I have added the symbol function so it should be fine now. You can try it and see how it works. I just want to know what do you mean by trade comments, I mean what kind?? http://rapid*share.com/files/318021578/CloseAllProfit_v1.mq4.html Best wishes, HI Trade comments is normally the ea 'name' which shows up in your trade window and journal ..IT Can be either magic number or trade comment. Maybe you can use the code from the first closeall ea you provided to add 'trade comment' external regards I have just noticed that i cannot see 'symbol' in external parameters in the above link Quote Link to comment Share on other sites More sharing options...
scarface Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, O.K, I have modified the EA to make the symbol choice as an external parameter, but you need to ensure that the currency pair in Capital Letters. [url]http://rapidshare.com/files/318048059/CloseAllProfit_v1.mq4.html[/url] check it and let me know how it goes. Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
Guest dave_rimmer Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, O.K, I have modified the EA to make the symbol choice as an external parameter, but you need to ensure that the currency pair in Capital Letters. [url]http://rapid*share.com/files/318048059/CloseAllProfit_v1.mq4.html[/url] check it and let me know how it goes. Best wishes, OK Thanks The only difference with what i requested is that this ea only closes 'in profit' trades' The original Plan was to have an ea like this where you can have as external '+' or '-' number in the external field so you can have trades close in profit or in loss which you can see in code from my first post so you could have close trades -100 $ or say close trades +100 $ in the original ea you only have to add a minus sign for the ea to close at loss amount Is it not possible to put your modified code in my original ea post since this code logic closes Very FAST and this is what i am after. The original CloseAll-PL EA with 'symbol' , magic no , trade comment as externals Here is the original code that needs modifying: //+------------------------------------------------------------------+ //| CloseAll-PL.mq4 | //| | //+------------------------------------------------------------------+ extern int Profit=30; double myProfit=0; int EnableClose=0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- myProfit=CalcProfit(); ShowInit(); if (EnableClose==1 && CntOrdAll(OP_BUY)==0 && CntOrdAll(OP_SELL)==0 && CntOrdAll(OP_BUYSTOP)==0 && CntOrdAll(OP_BUYLIMIT)==0 && CntOrdAll(OP_SELLSTOP)==0 && CntOrdAll(OP_SELLLIMIT)==0) { EnableClose=0; // Before Debug: EnableClose=1 } if ( (Profit>0 && myProfit>=Profit) || (Profit<0 && myProfit<=Profit)) { EnableClose=1; } CloseAll(); //---- return(0); } //+------------------------------------------------------------------+ void CloseAll () { // #function of CloseAll if (EnableClose==1) { // #if Close is yes int _total=OrdersTotal(); // number of lots or trades ???? int _ordertype;// order type if (_total==0) {return;} // if total==0 int _ticket; // ticket number double _priceClose;// price to close orders; for(int _i=_total-1;_i>=0;_i--) { //# for loop if (OrderSelect(_i,SELECT_BY_POS)) { //# if _ordertype=OrderType(); _ticket=OrderTicket(); switch(_ordertype) { //# switch case OP_BUYLIMIT: OrderDelete(OrderTicket()); case OP_BUYSTOP: OrderDelete(OrderTicket()); case OP_BUY: // close buy _priceClose=MarketInfo(OrderSymbol(),MODE_BID); Print("Close on ",_i," position order with ticket ¹",_ticket); OrderClose(_ticket,OrderLots(),_priceClose,3,Red); break; case OP_SELLLIMIT: OrderDelete(OrderTicket()); case OP_SELLSTOP: OrderDelete(OrderTicket()); case OP_SELL: // close sell _priceClose=MarketInfo(OrderSymbol(),MODE_ASK); Print("Close on ",_i," position order with ticket ¹",_ticket); OrderClose(_ticket,OrderLots(),_priceClose,3,Red); break; default: // values from 1 to 5, deleting pending orders // Print("Delete on ",_i," position order with ticket ¹",_ticket); // OrderDelete(_ticket); break; } //# switch } // # if } // # for loop } // #if Close yes return; } // #function of CloseAll void ShowInit() { string sComment = ""; string sp = "-----------------------------------------------------\n"; string NL = "\n"; sComment = sp; sComment = sComment + "CloseByPL will close all trades at: " + Profit + NL; sComment = sComment + sp; sComment = sComment + "Current P/L="+DoubleToStr(myProfit,0)+ NL; Comment(sComment); return; } double CalcProfit() { double _sum=0; int _total=OrdersTotal(); // number of lots if (_total==0) {return (0);} _sum=AccountProfit(); return(_sum); } int CntOrdAll(int Type) { //return number of orders with specific parameters int _CntOrd; _CntOrd=0; for(int i=0;i<OrdersTotal();i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType()==Type) _CntOrd++; } return(_CntOrd); } Quote Link to comment Share on other sites More sharing options...
scarface Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, Good day, I believe now you can test this version. I have added everything you were looking for. Test it and see how it goes. http://rapidshare.com/files/318064304/CloseAllProfit_v1.2.mq4.html Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
Guest dave_rimmer Posted December 8, 2009 Report Share Posted December 8, 2009 Re: REQ:Code Modification to Close PL Ea Hi, Good day, I believe now you can test this version. I have added everything you were looking for. Test it and see how it goes. http://rapid*share.com/files/318064304/CloseAllProfit_v1.2.mq4.html Best wishes, Thanks again for your help but it is still not what i am looking for! 1)the ea must close orders either in profit or in loss selectable in ext with PL amounts to be set 2)the ea must distinguish trades to be closed by either 'magic no' or 'trade comment' or 'symbol' 3)The original CloseAll-PL EA is the code i want modified 'ONLY' since it closes very fast Regards Quote Link to comment Share on other sites More sharing options...
scarface Posted December 10, 2009 Report Share Posted December 10, 2009 Re: REQ:Code Modification to Close PL Ea Thanks again for your help but it is still not what i am looking for! 1)the ea must close orders either in profit or in loss selectable in ext with PL amounts to be set 2)the ea must distinguish trades to be closed by either 'magic no' or 'trade comment' or 'symbol' 3)The original CloseAll-PL EA is the code i want modified 'ONLY' since it closes very fast Regards Hi, I'm sorry to reply late. Life is getting so hectic and no time to check all posts. O.K, if you look at your original post your EA on the link is ColseAllProfit.mq4 not CloseaAll_PL.mq4 :) please double check. You need to decide which EA you want me to fix :D otherwise, it would take weeks to reach our goals. O.k, You want the EA to close on whether it is profit or loss " just closing all positions with adjusted P/L" It should have the following features: symbol(), magic () and trade comment (comment). I got it. please let me know so I can work on your request whenever it is possible. Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
scarface Posted December 11, 2009 Report Share Posted December 11, 2009 Re: REQ:Code Modification to Close PL Ea Hi dave_rimmer, Thanks for your patience. Here is the EA with an external option for magic number and symbol selection for now. I will add the trade comment whenever you think this EA is working well first. Here is the EA: [url]http://www.4shared.com/file/170315414/5c0e4be2/CloseAll-PL-EA_v1.html[/url] There is something you should know, there is a choice for symbol so you should write the right symbol in capital letter like this "USDJPY". Please let me know whether it works or not. Best wishes, Quote a New Year 2011 has come, and the challenge has just started 8-) Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.