Profit factor:
1.02

This automated trading script is designed to manage specific buy and sell positions on a trading platform based on a pre-defined starting time, profit targets, and volume rules. It functions as a systematic "set-and-forget" tool that handles the opening, monitoring, and closing of trades independently.

Core Trading Logic

1. Scheduled Entry Window The script operates within a specific 5-minute window starting at a user-defined time. During this period, it scans the current market to determine if any active positions are already open for the specific currency pair.

2. Automated Position Opening If the script detects that there are no active "Buy" or "Sell" orders currently open:

  • Buying: It automatically places a "Buy" order at the current market price.
  • Selling: It automatically places a "Sell" order at the current market price.
  • Profit Targets: Every trade is automatically assigned a take-profit level based on the user's preferred point distance.
  • Dynamic Volume Scaling: The script includes a smart volume logic. If a previous position was closed, it checks a memory variable to determine if it should double the trading volume for the next trade or stick to the standard amount.

3. Order Identification To ensure it only manages its own trades and doesn't interfere with other manual trades, the script applies a unique "comment" (label) to every position it opens. It specifically looks for these labels before making any decisions.

Trade Management & Exit Strategy

4. Time-Based Exits The script acts as a safety monitor for open positions. It continuously checks how long each trade has been running. If a position remains open for 2 days without hitting the profit target, the script will automatically close that position to free up capital and reduce risk.

5. Feedback & Notifications For every major action taken—whether it is opening a new trade or closing an old one—the script triggers an audible alert (a sound file) to notify the user of the activity. It also includes a brief "sleep" period after actions to ensure the platform processes the data correctly before moving to the next step.

Summary of User Controls

The system allows the user to define:

  • Start Time: When the script should begin looking for opportunities.
  • Take Profit: How many points in profit are required to close a trade automatically.
  • Lot Size: The base volume of the trades to be executed.
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Miscellaneous
It plays sound alerts
10 Views
0 Downloads
0 Favorites
HedgeHog
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                      Hans123 testing version.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

//---- input parameters
extern int       Start=0;
extern int       TakeProfit=14;
extern double    Lots=1;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   //---- 
   int i,j,Ticket,StartTime,Bought=0,Sold=0,Closed;
   double Vol;
   string Text;
   
   //Count time
   StartTime= StrToTime(Start+":00");
   
   //Setup comment
   Text="HH"+Symbol();
   
   //Set orders
   if(CurTime()>= StartTime && CurTime()<StartTime+300){
      //Check Orders
      for (i=0;i<OrdersTotal();i++){
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderComment()==Text && OrderType()==OP_BUY && OrderOpenTime()>CurTime()-3600) Bought++;
         if(OrderComment()==Text && OrderType()==OP_SELL && OrderOpenTime()>CurTime()-3600) Sold++;
      }
      if(Bought==0){ //no buy order
         if(GlobalVariableGet("Closed")==1) Vol=2*Lots; else Vol=Lots;
         Ticket=OrderSend(Symbol(),OP_BUY,Vol,Ask,3,0,Ask+TakeProfit*Point,Text,0,0,Green);
         PlaySound("expert.wav");
         Sleep(10000);
      }
      if(Sold==0){ //no sell order
         if(GlobalVariableGet("Closed")==2) Vol=2*Lots; else Vol=Lots;
         Ticket=OrderSend(Symbol(),OP_SELL,Vol,Bid,3,0,Bid-TakeProfit*Point,Text,0,0,Green);
         PlaySound("expert.wav");
         Sleep(10000);
      }
      if(GlobalVariableCheck("Closed")) GlobalVariableDel("Closed");
   }
   
   //Manage opened orders
   for (i=0;i<OrdersTotal();i++){
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      //close open position after 2 days
      if(OrderComment()==Text && CurTime()>=OrderOpenTime()+2*24*3600-300){
         if(OrderType()==OP_BUY){
            OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
            PlaySound("expert.wav");
            GlobalVariableSet("Closed",1);
            Sleep(10000);
         }
         if(OrderType()==OP_SELL){
            OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
            PlaySound("expert.wav");
            GlobalVariableSet("Closed",2);
            Sleep(10000);
         }
      }
   }
   
   return(0);
   }
//+------------------------------------------------------------------+

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
16 reports
GBP/USD Jul 2025 - Sep 2025
6.68
Total Trades 145
Won Trades 144
Lost trades 1
Win Rate 99.31 %
Expected payoff 11.82
Gross Profit 2016.00
Gross Loss -302.00
Total Net Profit 1714.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.80
Total Trades 128
Won Trades 126
Lost trades 2
Win Rate 98.44 %
Expected payoff 4.19
Gross Profit 1207.02
Gross Loss -670.48
Total Net Profit 536.54
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.70
Total Trades 130
Won Trades 127
Lost trades 3
Win Rate 97.69 %
Expected payoff 5.74
Gross Profit 1806.00
Gross Loss -1060.00
Total Net Profit 746.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.92
Total Trades 225
Won Trades 218
Lost trades 7
Win Rate 96.89 %
Expected payoff -1.29
Gross Profit 3122.00
Gross Loss -3412.00
Total Net Profit -290.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.91
Total Trades 144
Won Trades 139
Lost trades 5
Win Rate 96.53 %
Expected payoff -1.34
Gross Profit 1974.00
Gross Loss -2167.00
Total Net Profit -193.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.88
Total Trades 145
Won Trades 141
Lost trades 4
Win Rate 97.24 %
Expected payoff -2.48
Gross Profit 2537.36
Gross Loss -2897.36
Total Net Profit -360.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.78
Total Trades 157
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -4.01
Gross Profit 2170.00
Gross Loss -2799.00
Total Net Profit -629.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.67
Total Trades 180
Won Trades 172
Lost trades 8
Win Rate 95.56 %
Expected payoff -6.57
Gross Profit 2450.00
Gross Loss -3632.00
Total Net Profit -1182.00
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.44
Total Trades 139
Won Trades 131
Lost trades 8
Win Rate 94.24 %
Expected payoff -12.78
Gross Profit 1395.31
Gross Loss -3172.21
Total Net Profit -1776.90
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.44
Total Trades 216
Won Trades 210
Lost trades 6
Win Rate 97.22 %
Expected payoff -12.43
Gross Profit 2119.23
Gross Loss -4804.75
Total Net Profit -2685.52
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.28
Total Trades 165
Won Trades 154
Lost trades 11
Win Rate 93.33 %
Expected payoff -34.93
Gross Profit 2254.00
Gross Loss -8017.00
Total Net Profit -5763.00
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.27
Total Trades 214
Won Trades 202
Lost trades 12
Win Rate 94.39 %
Expected payoff -26.20
Gross Profit 2113.37
Gross Loss -7719.93
Total Net Profit -5606.56
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.26
Total Trades 160
Won Trades 149
Lost trades 11
Win Rate 93.13 %
Expected payoff -28.47
Gross Profit 1561.77
Gross Loss -6116.88
Total Net Profit -4555.11
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.19
Total Trades 88
Won Trades 81
Lost trades 7
Win Rate 92.05 %
Expected payoff -37.81
Gross Profit 774.44
Gross Loss -4101.97
Total Net Profit -3327.53
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.05
Total Trades 52
Won Trades 42
Lost trades 10
Win Rate 80.77 %
Expected payoff -163.51
Gross Profit 459.96
Gross Loss -8962.30
Total Net Profit -8502.34
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 20
Won Trades 19
Lost trades 1
Win Rate 95.00 %
Expected payoff -52698.30
Gross Profit 266.00
Gross Loss -1054232.00
Total Net Profit -1053966.00
-100%
-50%
0%
50%
100%

Comments