Try this out:
////+------------------------------------------------------------------+
//| CloseOrdersOnGainPercent |
//| MetaQuotes |
//| Forex / Ôîðåêñ Òðåéäèíã: Òîðãîâàÿ Ïëàòôîðìà MetaTrader 4 äëÿ Forex |
//+------------------------------------------------------------------+
#property copyright "MetaQuotes"
#property link "http://www.metaquotes.ru/"
extern double Ratio=1.02;//
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
//----
if (AccountEquity()/AccountBalance()>Ratio) closeOrders();
//----
return;
}
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int closeOrders()
{
//----
// ???????? ??? ?????, ? ???? ??? ?? ???? ???? ??????? ?????????????
// ? ???????? ?????? ???????
if (!IsDemo()) {Alert("?? ???????? ????? ?????? ?????????"); return;}
int total=OrdersTotal(); // ?????????? ???????
int ordertype;// ??? ??????
if (total==0) {Alert("??? ??????? ??? ????????/????????");return;}
int ticket; // ????? ?????????? ???? ????? ??????
double priceClose;// ????, ?? ??????? ????? ????????? ???????? ??????
for(int i=total-1;i>=0;i--)
{
if (OrderSelect(i,SELECT_BY_POS))
{
ordertype=OrderType();
ticket=OrderTicket();
switch(ordertype)
{
case 0:
// ??????? ???????
//??????? ???? Bid ?? ???????
priceClose=MarketInfo(OrderSymbol(),MODE_BID);
Print("????????? ?? ",i," ??????? ????? ? ??????? ?",ticket);
OrderClose(ticket,OrderLots(),priceClose,3,Red);
break;// ????? ?? ????? switch
case 1:
// ??????? ???????
//??????? ???? Ask ?? ???????
priceClose=MarketInfo(OrderSymbol(),MODE_ASK);
Print("????????? ?? ",i," ??????? ????? ? ??????? ?",ticket);
OrderClose(ticket,OrderLots(),priceClose,3,Red);
break;// ????? ?? ????? switch
default:
// ???????? ?? 2 ?? 5, ??????? ?????????? ?????
Print("??????? ?? ",i," ??????? ????? ? ??????? ?",ticket);
OrderDelete(ticket);
break;// ????? ?? ????? switch
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
sorry there seems to be a problem... can you please attache as EA ?
thanks a lot
I have been using ManageThePip ea for my manual trades. Google managethepip
These guys have been around for a few year now and have good support.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
can please anyone suggest/post an EA to close/manage open position. I should be able to set:
- max. loosing points/pips (afhtere open position)
- stoploss in point/pips
- trailing stops in points/pips -afhter break-even
- closing position afhtere XX points/pips in profit
It should be possible to apply to every chart/pairs his own EA.
Thanks fro any help and any post of EA that can meet my needs.