Utility recommendation on SL/TP trailing robot?
Luka Popov:
Can someone recommend be some simple trailing robot which would automatically close the trades if the floating profit is above given amount in eur?
#property copyright"Akinbowale-Samuel" //extern double equity_percent_from_balances=1.2; extern double equity_from_balances=10; int start() { Comment(" ",AccountName()," ACCOUNT ",AccountNumber()," FREE MARGIN ",AccountFreeMargin()," EQUITY ",AccountEquity()," BALANCE ",AccountBalance()); /* if(AccountEquity()>AccountBalance()*equity_percent_from_balances) { int total=OrdersTotal(); for(int i=total-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS)==true) { int type=OrderType(); bool result=false; switch(type) { case OP_BUY : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red); break; case OP_SELL : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Red); } if(result==false) { Sleep(0); } } } } */ if(AccountEquity()>(AccountBalance()+equity_from_balances)) { int total=OrdersTotal(); for(int i=total-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS)==true) { int type=OrderType(); bool result=false; switch(type) { case OP_BUY : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red); break; case OP_SELL : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Red); } if(result==false) { Sleep(0); } } } } return(0); } //+------------------------------------------------------------------+
Files:
close_by_equity.mq4
2 kb
Hi all,
Can someone recommend be some simple trailing robot which would automatically close the trades if the floating profit is above given amount in eur?
For example, if I want to close all trades once the floating profit reaches 10 EUR?
Thank you.