time trader

Author: Copyright � 2012, www.FxAutomated.com
Profit factor:
0.56
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Miscellaneous
It issuies visual alerts to the screen
6 Views
0 Downloads
0 Favorites
time trader
//+------------------------------------------------------------------+
//|                                                  time trader.mq4 |
//|                            Copyright © 2012, www.FxAutomated.com |
//|                                       http://www.FxAutomated.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, www.FxAutomated.com"
#property link      "http://www.FxAutomated.com"
//---- input parameters
extern string   time_trader_v2="visit www.FxAutomated.com for more!!!";
extern double   Lots=0.1;
extern int      TakeProfit=20;
extern int      StopLoss=20;
extern int      Slip=5;
extern string   TradeSettings="Mt4 time(min-max): hours 0-23, minutes 0-59, seconds 0-59";
extern bool     AllowBuy=true;
extern bool     AllowSell=true;
extern int      TradeHour=0;
extern int      TradeMinutes=0;
extern string   MagicNumbers="To be changed in case of conflict with other EAs";
extern int      BuyMagicNumber =10001;
extern int      SellMagicNumber =10002;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   Alert("Visit www.FxAutomated.com for more goodies!");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert starts                                  |
//+------------------------------------------------------------------+

int start()
  {
//----
int StopMultd,Sleeper=1;



int digits=MarketInfo("EURUSD",MODE_DIGITS);
StopMultd=10;
double TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
double SL=NormalizeDouble(StopLoss*StopMultd,Digits);
int Slippage=Slip*StopMultd;

// Calculate stop loss
double slb=NormalizeDouble(Ask-SL*Point,Digits);
double sls=NormalizeDouble(Bid+SL*Point,Digits);

// Calculate take profit
double tpb=NormalizeDouble(Ask+TP*Point,Digits);
double tps=NormalizeDouble(Bid-TP*Point,Digits);

//-------------------------------------------------------------------+
//Check open orders
//-------------------------------------------------------------------+
if(OrdersTotal()>0){
  for(int i=1; i<=OrdersTotal(); i++)          // Cycle searching in orders
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
        {
          if(OrderMagicNumber()==BuyMagicNumber) {int halt1=1;}
          if(OrderMagicNumber()==SellMagicNumber) {int halt2=1;}
        }
     }
}
//-------------------------------------------------------------------+


if((halt1!=1)&&(AllowBuy==true)){// halt1

// Buy criteria
if ((TradeHour==Hour())&&(TradeMinutes==Minute())) //Signal Buy
 {
   int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"time trader buy order ",BuyMagicNumber,0,Blue);
   if(openbuy<1){int buyfail=1;}
 }
 
}// halt1
 
if((halt2!=1)&&(AllowSell==true)){// halt2
RefreshRates();
 // Sell criteria
 if ((TradeHour==Hour())&&(TradeMinutes==Minute())) //Signal Sell
 {
   int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"time trader sell order ",SellMagicNumber,0,Green);
   if(opensell<1){int sellfail=1;}
 }
 
}// halt2

//-----------------------------------------------------------------------------------------------------
if(OrdersTotal()>0){
  for(i=1; i<=OrdersTotal(); i++){          // Cycle searching in orders
  
      if (OrderSelect(i-1,SELECT_BY_POS)==true){ // If the next is available
        
          if((OrderMagicNumber()==BuyMagicNumber)&&(OrderTakeProfit()==0||OrderStopLoss()==0)) { OrderModify(OrderTicket(),0,slb,tpb,0,CLR_NONE); }
          if((OrderMagicNumber()==SellMagicNumber)&&(OrderTakeProfit()==0||OrderStopLoss()==0)) { OrderModify(OrderTicket(),0,sls,tps,0,CLR_NONE); }

        }
     }
}
//-------------------------------------------------------------------+
// Error processing
//-------------------------------------------------------------------+
if(buyfail==1||sellfail==1){
int Error=GetLastError();
  if(Error==130){Alert("Wrong stops. Retrying."); RefreshRates();}
  if(Error==133){Alert("Trading prohibited.");}
  if(Error==2){Alert("Common error.");}
  if(Error==146){Alert("Trading subsystem is busy. Retrying."); Sleep(500); RefreshRates();}

}


//-------------------------------------------------------------------
   return(0);
  }
//+-----------------------------------

Profitability Reports

NZD/USD Jul 2025 - Sep 2025
0.70
Total Trades 102
Won Trades 42
Lost trades 60
Win Rate 41.18 %
Expected payoff -3.53
Gross Profit 840.00
Gross Loss -1200.00
Total Net Profit -360.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.84
Total Trades 116
Won Trades 53
Lost trades 63
Win Rate 45.69 %
Expected payoff -1.72
Gross Profit 1060.00
Gross Loss -1260.00
Total Net Profit -200.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.18
Total Trades 100
Won Trades 15
Lost trades 85
Win Rate 15.00 %
Expected payoff -10.00
Gross Profit 214.28
Gross Loss -1214.06
Total Net Profit -999.78
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.19
Total Trades 64
Won Trades 10
Lost trades 54
Win Rate 15.63 %
Expected payoff -8.95
Gross Profit 130.22
Gross Loss -703.25
Total Net Profit -573.03
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.93
Total Trades 114
Won Trades 55
Lost trades 59
Win Rate 48.25 %
Expected payoff -0.70
Gross Profit 1100.00
Gross Loss -1180.00
Total Net Profit -80.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.89
Total Trades 102
Won Trades 48
Lost trades 54
Win Rate 47.06 %
Expected payoff -1.18
Gross Profit 960.00
Gross Loss -1080.00
Total Net Profit -120.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.71
Total Trades 116
Won Trades 48
Lost trades 68
Win Rate 41.38 %
Expected payoff -3.45
Gross Profit 960.00
Gross Loss -1360.00
Total Net Profit -400.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.62
Total Trades 126
Won Trades 48
Lost trades 78
Win Rate 38.10 %
Expected payoff -4.76
Gross Profit 960.00
Gross Loss -1560.00
Total Net Profit -600.00
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2024 - Jan 2025
0.66
Total Trades 88
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2.96
Gross Profit 507.07
Gross Loss -767.80
Total Net Profit -260.73
-100%
-50%
0%
50%
100%

Comments