Author: Copyright � 2008 Grib
Profit factor:
30.71

This script is an automated trading tool designed to manage trades on the MetaTrader 4 platform using a randomized execution logic combined with specific time-based exit rules. It functions by constantly monitoring your account status to determine whether it should be looking for new opportunities or managing existing positions.

Core Operational Logic

1. Position Monitoring The script operates on a binary logic: if there are no open trades, it focuses on opening a new one; if there is already an active trade, it shifts its focus to monitoring that position for closure. This prevents the system from opening multiple simultaneous trades.

2. Randomized Entry Mechanism When the system is ready to open a trade, it uses a randomized "draw" process. Instead of relying on traditional technical indicators (like moving averages or RSI), it generates a series of random numbers. It specifically looks for a result within a certain statistical threshold:

  • Buy Order: If the random number exceeds a specific high value, the system executes a "Buy" order.
  • Sell Order: If the random number falls below that threshold, the system executes a "Sell" order.

This means the direction of the trade is determined by chance rather than market trends, making it a probabilistic trading tool.

3. Automated Exit Strategy Once a trade is successfully opened, the script switches to a monitoring mode. It tracks the duration of the open position based on the local time of your computer. The logic dictates a fixed timeframe for the trade:

  • The script checks if the elapsed time since the trade was opened has reached 14,400 seconds (which is exactly 4 hours).
  • Once this 4-hour duration is met, the script automatically triggers an order to close the position.

Summary for the User

In simple terms, this tool acts as a "set and forget" automated trader that makes a random decision on whether to buy or sell a position. Once that trade is active, the tool will hold it for exactly four hours before automatically closing it, regardless of market fluctuations or profit levels.

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Miscellaneous
It issuies visual alerts to the screen
14 Views
0 Downloads
0 Favorites
RndTrade
//+------------------------------------------------------------------+
//|                                                     RndTrade.mq4 |
//|                                            Copyright © 2008 Grib |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008 Grib"
#property link      ""

#define NUM_BUY  20050611
#define NUM_SELL  20050612
int ticket;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
if(OrdersTotal() == 0)
{
   checkForOpen();
}
else
{
   checkForClose();
}

//----
   return(0);
  }
  
//+------------------------------------------------------------------+
//| Ïðîâåðêà íà îòêðûòèå ïîçèöèè                                    |
//+------------------------------------------------------------------+
void checkForOpen()
{
int a = 0;
MathSrand(TimeLocal());
  // Îòîáðàæàåò 10 ÷èñåë.
  for(int i=0;i<10;i++ )
    if(i==5)
    {
      a = MathRand();
      if(a > 16383.5)
      {
      // Ñîâåðøàåì ïîêóïêó
        ticket = OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"TestDrawSell",NUM_BUY);
        if (ticket == -1) Alert("Îøèáêà ïðè ñîâåðøåíèè îïåðàöèè ïîêóïêè");
      }
      else
      {
      //Ñîâåðøàåì ïðîäàæó
        ticket = OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"TestDrawBuy",NUM_SELL);
        if (ticket == -1) Alert("Îøèáêà ïðè ñîâåðøåíèè îïåðàöèè ïðîäàæè");
      }
    }
    else
    {
      a = MathRand();
    } 
}
//+------------------------------------------------------------------+
//| Ïðîâåðêà íà çàêðûòèå ïîçèöèè                                     |
//+------------------------------------------------------------------+
void checkForClose()
{
  if(OrderSelect(0, SELECT_BY_POS)==true)
  {
    if( (OrderOpenTime()+14400) < TimeLocal() )
       if(OrderClose(OrderTicket(),1,Ask,3) == false)
          Print("Îøèáêà ïðè çàêðûòèè ïîçèöèè");
  }
  else
  {
    Print("OrderSelect() âåðíóë îøèáêó - ",GetLastError());
  }
}
//+------------------------------------------------------------------+

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
34 reports
NZD/USD Jan 2025 - Jul 2025
984.60
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 1639.33
Gross Profit 4923.00
Gross Loss -5.00
Total Net Profit 4918.00
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
23.90
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff 437.54
Gross Profit 1369.96
Gross Loss -57.33
Total Net Profit 1312.63
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
23.84
Total Trades 4
Won Trades 1
Lost trades 3
Win Rate 25.00 %
Expected payoff 1397.63
Gross Profit 5835.31
Gross Loss -244.79
Total Net Profit 5590.52
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
5.97
Total Trades 2
Won Trades 1
Lost trades 1
Win Rate 50.00 %
Expected payoff 149.00
Gross Profit 358.00
Gross Loss -60.00
Total Net Profit 298.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
3.43
Total Trades 5
Won Trades 4
Lost trades 1
Win Rate 80.00 %
Expected payoff 73.80
Gross Profit 521.00
Gross Loss -152.00
Total Net Profit 369.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.99
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff -0.40
Gross Profit 119.95
Gross Loss -121.14
Total Net Profit -1.19
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.88
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff -5.45
Gross Profit 114.89
Gross Loss -131.23
Total Net Profit -16.34
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.20
Total Trades 5
Won Trades 1
Lost trades 4
Win Rate 20.00 %
Expected payoff -84.00
Gross Profit 103.00
Gross Loss -523.00
Total Net Profit -420.00
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.19
Total Trades 5
Won Trades 1
Lost trades 4
Win Rate 20.00 %
Expected payoff -85.00
Gross Profit 102.00
Gross Loss -527.00
Total Net Profit -425.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.05
Total Trades 4
Won Trades 3
Lost trades 1
Win Rate 75.00 %
Expected payoff -1408.50
Gross Profit 287.00
Gross Loss -5921.00
Total Net Profit -5634.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.04
Total Trades 3
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2028.67
Gross Profit 221.00
Gross Loss -6307.00
Total Net Profit -6086.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.03
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff -2498.33
Gross Profit 194.00
Gross Loss -7689.00
Total Net Profit -7495.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.01
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff -3250.10
Gross Profit 127.56
Gross Loss -9877.85
Total Net Profit -9750.29
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 3887.00
Gross Profit 3887.00
Gross Loss 0.00
Total Net Profit 3887.00
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.00
Total Trades 3
Won Trades 3
Lost trades 0
Win Rate 100.00 %
Expected payoff 5055.33
Gross Profit 15166.00
Gross Loss 0.00
Total Net Profit 15166.00
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.00
Total Trades 3
Won Trades 3
Lost trades 0
Win Rate 100.00 %
Expected payoff 2207.53
Gross Profit 6622.59
Gross Loss 0.00
Total Net Profit 6622.59
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.00
Total Trades 3
Won Trades 3
Lost trades 0
Win Rate 100.00 %
Expected payoff 2029.28
Gross Profit 6087.83
Gross Loss 0.00
Total Net Profit 6087.83
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.00
Total Trades 3
Won Trades 3
Lost trades 0
Win Rate 100.00 %
Expected payoff 4719.67
Gross Profit 14159.00
Gross Loss 0.00
Total Net Profit 14159.00
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -2121.00
Gross Profit 0.00
Gross Loss -6362.99
Total Net Profit -6362.99
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.00
Total Trades 4
Won Trades 0
Lost trades 4
Win Rate 0.00 %
Expected payoff -2375.64
Gross Profit 0.00
Gross Loss -9502.55
Total Net Profit -9502.55
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 3
Lost trades 0
Win Rate 100.00 %
Expected payoff 137.67
Gross Profit 413.00
Gross Loss 0.00
Total Net Profit 413.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -1030.13
Gross Profit 0.00
Gross Loss -3090.38
Total Net Profit -3090.38
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 115.72
Gross Profit 115.72
Gross Loss 0.00
Total Net Profit 115.72
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -695.67
Gross Profit 0.00
Gross Loss -2087.00
Total Net Profit -2087.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff -717.33
Gross Profit 6.00
Gross Loss -2158.00
Total Net Profit -2152.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 2
Won Trades 2
Lost trades 0
Win Rate 100.00 %
Expected payoff 1630.89
Gross Profit 3261.79
Gross Loss 0.00
Total Net Profit 3261.79
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 2
Won Trades 0
Lost trades 2
Win Rate 0.00 %
Expected payoff -1472.90
Gross Profit 0.00
Gross Loss -2945.80
Total Net Profit -2945.80
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 43.57
Gross Profit 43.57
Gross Loss 0.00
Total Net Profit 43.57
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -692.67
Gross Profit 0.00
Gross Loss -2078.00
Total Net Profit -2078.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff -716.33
Gross Profit 7.00
Gross Loss -2156.00
Total Net Profit -2149.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 2
Won Trades 2
Lost trades 0
Win Rate 100.00 %
Expected payoff 1629.86
Gross Profit 3259.72
Gross Loss 0.00
Total Net Profit 3259.72
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.00
Total Trades 2
Won Trades 2
Lost trades 0
Win Rate 100.00 %
Expected payoff 2262.00
Gross Profit 4524.00
Gross Loss 0.00
Total Net Profit 4524.00
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.00
Total Trades 1
Won Trades 0
Lost trades 1
Win Rate 0.00 %
Expected payoff -8794.88
Gross Profit 0.00
Gross Loss -8794.88
Total Net Profit -8794.88
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -874.36
Gross Profit 0.00
Gross Loss -2623.08
Total Net Profit -2623.08
-100%
-50%
0%
50%
100%

Comments