Trending and Reversal

Author: Copyright � 2008, Henky Mailis
Profit factor:
0.65
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
Indicators Used
MACD Histogram
11 Views
0 Downloads
0 Favorites
Trending and Reversal
//+------------------------------------------------------------------+
//|                                        Trending and Reversal.mq4 |
//|                                   Copyright © 2008, Henky Mailis |
//|                                         http://www.h3nkymcnv.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Henky Mailis"
#property link      "http://www.h3nkymcnv.com"
//----
extern double Lots=1.0;
extern double Bands=100.0;
extern double TakeProfit=150.0;
extern double InitialStop=50.0;
extern double TrailingStop=50.0;
//----
int jmlorder=0;
int itung=0;
int  slip=0;
double slnyo=0.0;
double buka=0;
double stop=0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//---- 
   jmlorder=0;
   for(itung=0;itung<OrdersTotal();itung++)
    {
     OrderSelect(itung,SELECT_BY_POS,MODE_TRADES);
     //----
     if(OrderSymbol()==Symbol())
     jmlorder++;
    }
//----
   if(jmlorder==0)
    {
     if(iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)<iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) 
      {
       OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Ask+InitialStop*Point,Ask-TakeProfit*Point,NULL,0,0,Blue);
       return(0);
      }
     if(iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) 
      { 
       OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Bid-InitialStop*Point,Bid+TakeProfit*Point,NULL,0,0,Red);
       return(0);
      }
    }
//----
   buka=0; stop=0;
   if(jmlorder==1)
    {
     for(itung=OrdersTotal();itung>=0;itung--)
      {
       OrderSelect(itung,SELECT_BY_POS,MODE_TRADES);
       if(OrderSymbol()==Symbol())
        {	
         if(OrderType()==OP_SELL)
          {
           buka=OrderStopLoss(); stop=OrderOpenPrice();
           OrderSend(Symbol(),OP_BUYSTOP,Lots,buka,slip,stop,buka+TakeProfit*Point,NULL,0,0,Orange);
           return(0);
          }
         if(OrderType()==OP_BUY)
          {
           buka=OrderStopLoss(); stop=OrderOpenPrice();
           OrderSend(Symbol(),OP_SELLSTOP,Lots,buka,slip,stop,buka-TakeProfit*Point,NULL,0,0,Indigo);
           return(0);
          }
        }
      } 
    }
//---- if we have opened positions we take care of them
   slnyo=0;
   for(itung=OrdersTotal();itung>=0;itung--)
    {
     OrderSelect(itung,SELECT_BY_POS,MODE_TRADES);
     if(OrderSymbol()==Symbol())
      {
       if(OrderType()==OP_SELL)
        {
         slnyo=OrderStopLoss();
         if(TrailingStop>0)
          if(OrderOpenPrice()-Ask>=TrailingStop*Point)
           if(OrderStopLoss()>(Ask+Point*TrailingStop))
            {
             OrderModify(OrderTicket(),OrderOpenPrice(),OrderClosePrice()+Point*TrailingStop,OrderClosePrice()-TakeProfit*Point,0,Aqua);
             return(0);
            }
        }
       if(OrderType()==OP_BUY)
        {
         slnyo=OrderStopLoss();
         if(TrailingStop>0)
          if(Bid-OrderOpenPrice()>=TrailingStop*Point)
           if(OrderStopLoss()<Bid-Point*TrailingStop)
            {
             OrderModify(OrderTicket(),OrderOpenPrice(),OrderClosePrice()-Point*TrailingStop,OrderClosePrice()+TakeProfit*Point,0,DeepPink);
             return(0);
            }
        }
      }
    }
//----
   for(itung=OrdersTotal();itung>=0;itung--)
    {
     OrderSelect(itung,SELECT_BY_POS,MODE_TRADES);
     //----
     if(OrderSymbol()==Symbol())
      {
       if(OrderType()==OP_BUYSTOP)
        {
         if(OrderOpenPrice()!=slnyo)
          {
           OrderModify(OrderTicket(),slnyo,slnyo-Point*InitialStop,slnyo+TakeProfit*Point,0,Orange);
           return(0);
          }
        }
       if(OrderType()==OP_SELLSTOP)
        {
         if(OrderOpenPrice()!=slnyo)
          {
           OrderModify(OrderTicket(),slnyo,slnyo+Point*InitialStop,slnyo-TakeProfit*Point,0,Indigo);
           return(0);
          }
        }
      }
    } 
//----
   return(0);
  } 
//+------------------------------------------------------------------+

Profitability Reports

GBP/USD Jul 2025 - Sep 2025
1.36
Total Trades 3119
Won Trades 1544
Lost trades 1575
Win Rate 49.50 %
Expected payoff 9.15
Gross Profit 107292.00
Gross Loss -78750.00
Total Net Profit 28542.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.25
Total Trades 240
Won Trades 110
Lost trades 130
Win Rate 45.83 %
Expected payoff 4.71
Gross Profit 5695.61
Gross Loss -4565.63
Total Net Profit 1129.98
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
1.08
Total Trades 1313
Won Trades 566
Lost trades 747
Win Rate 43.11 %
Expected payoff 2.25
Gross Profit 40310.00
Gross Loss -37362.00
Total Net Profit 2948.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.84
Total Trades 1397
Won Trades 607
Lost trades 790
Win Rate 43.45 %
Expected payoff -4.53
Gross Profit 33117.00
Gross Loss -39451.00
Total Net Profit -6334.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.75
Total Trades 1018
Won Trades 409
Lost trades 609
Win Rate 40.18 %
Expected payoff -9.33
Gross Profit 28585.47
Gross Loss -38086.33
Total Net Profit -9500.86
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.71
Total Trades 1115
Won Trades 444
Lost trades 671
Win Rate 39.82 %
Expected payoff -8.81
Gross Profit 23722.00
Gross Loss -33548.00
Total Net Profit -9826.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.70
Total Trades 1052
Won Trades 403
Lost trades 649
Win Rate 38.31 %
Expected payoff -9.15
Gross Profit 22898.00
Gross Loss -32528.00
Total Net Profit -9630.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.58
Total Trades 303
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -13.22
Gross Profit 5594.00
Gross Loss -9600.00
Total Net Profit -4006.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.55
Total Trades 293
Won Trades 96
Lost trades 197
Win Rate 32.76 %
Expected payoff -11.16
Gross Profit 3989.17
Gross Loss -7259.18
Total Net Profit -3270.01
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.41
Total Trades 448
Won Trades 115
Lost trades 333
Win Rate 25.67 %
Expected payoff -21.88
Gross Profit 6913.00
Gross Loss -16716.00
Total Net Profit -9803.00
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.16
Total Trades 252
Won Trades 29
Lost trades 223
Win Rate 11.51 %
Expected payoff -38.45
Gross Profit 1778.00
Gross Loss -11467.00
Total Net Profit -9689.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.07
Total Trades 121
Won Trades 22
Lost trades 99
Win Rate 18.18 %
Expected payoff -76.52
Gross Profit 649.17
Gross Loss -9908.29
Total Net Profit -9259.12
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.03
Total Trades 91
Won Trades 11
Lost trades 80
Win Rate 12.09 %
Expected payoff -106.78
Gross Profit 251.37
Gross Loss -9968.25
Total Net Profit -9716.88
-100%
-50%
0%
50%
100%

Comments