Trade manager tools experts

close all and take profit experts

close all pending

close all specific

close on time

can someobody make these into one ea

Clipboard01.jpg
 

Attachments

Last edited:
Can somebody make a free trade manager to share?

More experts

input bool CloseAllMarket=false;
input bool CloseAllPending=false;
input bool CloseAllMarketAndPending=false;
input bool PlaceSLTPForPending=false;
extern int StopLoss=100;
extern int TakeProfit=300;
extern int BreakEven=100;
input bool UseCloseFriday=true;
input string FridayCloseTime="19:00";
input string MondayStartTime="10:00";
 

Attachments

Last edited:
more with trade manager

MQL4:
//+------------------------------------------------------------------+
//|                                                SL_TP_manager.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             [URL]https://www.mql5.com[/URL] |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015,https://www.profitabletraders.co.uk."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
extern int StopLoss=600;
extern int TakeProfit=800;
extern int c_TP_1=40;
extern int c_TP_2=60;
extern int trailingStart    = 12;
extern int TrailingDistance = 20;
extern string CloseTime="19:00";
extern int BreakEven=20;
int slippage=3;
double point;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   point=1/MathPow(10,(Digits-1));
//  EventSetTimer(60);
 
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
 
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
//  set_tp_sl();
   if (CloseTime!="" && (TimeCurrent()-TimeCurrent()%60)==StrToTime(TimeToStr(TimeCurrent(),TIME_DATE)+"  "+CloseTime))CloseAll();
   if (BreakEven>0)MoveBreakEven();
   if (trailingStart>0) Trailing();
   PartialClose();
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
 
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
 
  }
//+------------------------------------------------------------------+
void set_tp_sl()
  {
   double SL,TP;
   int i,Total;
   int Dig=Digits();
   bool res;
 
//+------------------------------------------------------------------+
 
   Total=OrdersTotal();
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderStopLoss()==0 && OrderTakeProfit()==0)
              {
               if(StopLoss>0)SL=OrderOpenPrice()+StopLoss*Point;else SL=0;
               if(TakeProfit>0)TP=OrderOpenPrice()-TakeProfit*Point;else TP=0;
               res=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(SL,Dig),NormalizeDouble(TP,Dig),OrderExpiration(),CLR_NONE);
               if(!res) Print("Error in OrderModify. Error code=",GetLastError());
              }
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderStopLoss()==0 && OrderTakeProfit()==0)
              {
               if(StopLoss>0)SL=OrderOpenPrice()-StopLoss*Point;else SL=0;
               if(TakeProfit>0)TP=OrderOpenPrice()+TakeProfit*Point;else TP=0;
               res=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(SL,Dig),NormalizeDouble(TP,Dig),OrderExpiration(),CLR_NONE);
               if(!res) Print("Error in OrderModify. Error code=",GetLastError());
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAll()
  {
   bool result=false;
   int count=0,total=OrdersTotal();
   for(count=total-1; count>=0; count--)
     {
      if(OrderSelect(count,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol())
           {
            result=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,CLR_NONE);
           }
        }
     }
  }
//+------------------------------------------------------------------+
void MoveBreakEven()
  {
   bool modify;
   int count=0,total=OrdersTotal();
   for(count=total-1; count>=0; count--)
     {
      bool select=OrderSelect(count,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()==OP_BUY&&Bid>(OrderOpenPrice()+BreakEven*point)&&OrderStopLoss()!=OrderOpenPrice())  modify= OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
      if(OrderType()==OP_SELL&&Ask<(OrderOpenPrice()-BreakEven*point)&&OrderStopLoss()!=OrderOpenPrice())  modify= OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
     }
  }
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   int count=0,total=OrdersTotal();
   for(count=total-1; count>=0; count--)
     {
      bool select=OrderSelect(count,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()==OP_BUY && Bid>(OrderOpenPrice()+trailingStart*point))
        {
         if(NormalizeDouble(Bid-TrailingDistance*point,Digits)>OrderStopLoss())
           {
            mod=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-TrailingDistance*point,Digits),OrderTakeProfit(),
                            OrderExpiration());
           }
        }
      if(OrderType()==OP_SELL && Ask<(OrderOpenPrice()-trailingStart*point))
        {
         if(NormalizeDouble(Ask+TrailingDistance*point,Digits)<OrderStopLoss()||OrderStopLoss()==0)
           {
            mod=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+TrailingDistance*point,Digits),OrderTakeProfit(),
                            OrderExpiration());
           }
        }
     }
  }
//+------------------------------------------------------------------+
void PartialClose()
{
   bool result=false;
   int count=0,total=OrdersTotal();
   for(count=total-1; count>=0; count--)
     {
      bool select=OrderSelect(count,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()==OP_BUY && Bid>(OrderOpenPrice()+c_TP_1*point)&&StringFind(OrderComment(),"from",0)==-1)
        {
        result = OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/2,2),OrderClosePrice(),slippage);  
        }
           if(OrderType()==OP_BUY && Bid>(OrderOpenPrice()+c_TP_2*point)&&StringFind(OrderComment(),"from",0)!=-1)
        {
        result = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage);  
        }
      if(OrderType()==OP_SELL && Ask<(OrderOpenPrice()-c_TP_1*point)&&StringFind(OrderComment(),"from",0)==-1)
        {
        result = OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/2,2),OrderClosePrice(),slippage);  
        }
      if(OrderType()==OP_SELL && Ask<(OrderOpenPrice()-c_TP_2*point)&&StringFind(OrderComment(),"from",0)!=-1)
        {
        result = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage);  
        }
     }
}
 

Attachments

Last edited by a moderator:
Try the EA in a demo account first before using in a live account.
The EA is free to use, but not to distribute. If someone wants to have a copy, tell them to download from here.
Disclaimer: I am not responsible for any loss you may incur using the Trade Manager EA. Use it at your own risk.


https://www.earnforex.com/forum/threads/trade-manager-tools-experts.30111/#post-150053



The partial close may not work , because many mt4 brokers do not allow partial close.This way broker gets two spreads by closing and re entering partial .Meta trader is designed for MAKING MONEY FOR BROKERS , not the trader.Broker tricks to stop partial from working.


To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
 
  • 👍
Reactions: Henryudy