Author: Bernard Citra
Profit factor:
0.49
Price Data Components
Series array that contains the highest prices of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
3 Views
0 Downloads
0 Favorites
RealHour
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//| RealHour.mq4                                                     |
//| Bernard Citra                                                    |
//|                                                                  |
//| Matthew 6:33                                                     |
//| "But seek ye first The Kingdom of God, and His righteousness;    |
//|  and all these things shall be added unto you."                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Bernard Citra"

//--->Input Parameter
extern int     Start = 10; //FXDD server GMT+3
extern int     Finish = 18;
extern double  Lot = 0.1;
extern int     Trigger = 15;
extern int     Limit = 150;
extern int     StopLoss = 80;
extern int     BreakEven = 30;

//+------------------------------------------------------------------+
//| Main Program                                                     |
//|                                                                  |
//+------------------------------------------------------------------+
int start()
{
  int Ticket;
  int TicketBuy = 0;
  int TicketSell = 0;
  int MN=1;
   
  string Text="RealHour"+Symbol();
  
  //set the order
  if (Hour()==Start && Minute()==1)
  { 
    setOrder(Text,MN);  
  }
  
  //Delete the opposite pending order once the 1st order is hit
  for (int i=0; i<OrdersTotal(); i++)
  {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if (OrderType() == OP_BUY)
      TicketBuy = 1;
    if (OrderType() == OP_SELL)
      TicketSell = 1;
  }
  
  for (int n=0; n<OrdersTotal(); n++)
  {
    OrderSelect(n,SELECT_BY_POS,MODE_TRADES);
    if (OrderType() == OP_SELLSTOP && TicketBuy == 1)
      OrderDelete(OrderTicket());
    if (OrderType() == OP_BUYSTOP && TicketSell == 1)
      OrderDelete(OrderTicket());
  }    
  
  //Manage Open Order
  for (int l=0; l<OrdersTotal(); l++)
  {
    OrderSelect(l,SELECT_BY_POS,MODE_TRADES);
    if(OrderComment()==Text)
    {
      //close open position at EOD
      if (Hour() == Finish)
      {
        switch (OrderType())
        {
          case OP_BUY: OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
          break;
          case OP_SELL: OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
          break;
          default: OrderDelete(OrderTicket());
          break;
        }
      }
      //BreakEven -> move stoploss to open price
      else
      {
        if (OrderType()==OP_BUY)
        {
          if(High[0]-OrderOpenPrice()>=BreakEven*Point && OrderStopLoss()<OrderOpenPrice())
          {
            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green);
          }
        }
        if (OrderType()==OP_SELL)
        {
          if(OrderOpenPrice()-Low[0]>=BreakEven*Point && OrderStopLoss()>OrderOpenPrice())
          {
            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green);  
          }
        }
      }
    }
  }
  return (0);
}

//+------------------------------------------------------------------+
//| Set Order Function                                               |
//|                                                                  |
//+------------------------------------------------------------------+

void setOrder (string Text, int MN)
{
  double EntryLong, EntryShort, SLLong, SLShort, TPLong, TPShort;
  int Ticket;
  int Bought = 0;
  int Sold = 0;
    
  //Determine Price Range
  EntryLong   = iHigh(NULL,60,Highest(NULL,60,MODE_HIGH,3,1))+(Trigger+MarketInfo(Symbol(),MODE_SPREAD))*Point;
  EntryShort  = iLow (NULL,60,Lowest(NULL,60,MODE_LOW,3,1))-Trigger*Point;
  SLLong      = EntryLong-StopLoss*Point;
  SLShort     = EntryShort+StopLoss*Point;
  TPLong      = EntryLong+Limit*Point;
  TPShort     = EntryShort-Limit*Point;

  //send order
  for (int j=0;j<OrdersTotal();j++)
  {
     OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
     if(OrderComment()==Text && OrderMagicNumber()==MN)
     {
       if(OrderType()==OP_BUYSTOP || OrderType()==OP_BUY) Bought++;
       if(OrderType()==OP_SELLSTOP || OrderType()==OP_SELL) Sold++;
     }
  }    

  //no buy order then place the pending buy order
  if(Bought==0)
  { 
    Ticket=OrderSend(Symbol(),OP_BUYSTOP,Lot,EntryLong,5,SLLong,TPLong,Text,MN,0,Blue);
  }
  
  //no sell order then place the pending sell order
  if(Sold==0)
  {
    Ticket=OrderSend(Symbol(),OP_SELLSTOP,Lot,EntryShort,5,SLShort,TPShort,Text,MN,0,Magenta);
  }
}

Profitability Reports

NZD/USD Jul 2025 - Sep 2025
0.60
Total Trades 58
Won Trades 36
Lost trades 22
Win Rate 62.07 %
Expected payoff -1.22
Gross Profit 105.00
Gross Loss -176.00
Total Net Profit -71.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.79
Total Trades 57
Won Trades 38
Lost trades 19
Win Rate 66.67 %
Expected payoff -0.56
Gross Profit 120.00
Gross Loss -152.00
Total Net Profit -32.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 66
Won Trades 0
Lost trades 66
Win Rate 0.00 %
Expected payoff -5.71
Gross Profit 0.00
Gross Loss -377.12
Total Net Profit -377.12
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.36
Total Trades 57
Won Trades 26
Lost trades 31
Win Rate 45.61 %
Expected payoff -1.81
Gross Profit 58.60
Gross Loss -161.50
Total Net Profit -102.90
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.80
Total Trades 58
Won Trades 44
Lost trades 14
Win Rate 75.86 %
Expected payoff -0.38
Gross Profit 90.00
Gross Loss -112.00
Total Net Profit -22.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.49
Total Trades 57
Won Trades 38
Lost trades 19
Win Rate 66.67 %
Expected payoff -1.35
Gross Profit 75.00
Gross Loss -152.00
Total Net Profit -77.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.40
Total Trades 67
Won Trades 44
Lost trades 23
Win Rate 65.67 %
Expected payoff -1.17
Gross Profit 53.20
Gross Loss -131.54
Total Net Profit -78.34
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.11
Total Trades 67
Won Trades 32
Lost trades 35
Win Rate 47.76 %
Expected payoff -3.73
Gross Profit 30.00
Gross Loss -280.00
Total Net Profit -250.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.99
Total Trades 66
Won Trades 47
Lost trades 19
Win Rate 71.21 %
Expected payoff -0.03
Gross Profit 150.00
Gross Loss -152.00
Total Net Profit -2.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.39
Total Trades 66
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.77
Gross Profit 75.00
Gross Loss -192.00
Total Net Profit -117.00
-100%
-50%
0%
50%
100%

Comments