gaps





//+------------------------------------------------------------------+
//|                                                         gaps.mq4 |
//|                                                        SFK Corp. |
//+------------------------------------------------------------------+
#property copyright "SFK Corp."
#property link      ""
//---- input parameters
extern int    min_gapsize = 1;
extern double lotsize_gap = 0.1;
//----
datetime order_time = 0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
/* 
 Thing to be done in future in this program to make it more efficient
 and more powerful:
   1. Make the dicission of the quantity of lots used according to 
      the scillators;
   2. This program will catch the gaps.
 Things to ware of:
   1. the spread;
   2. excuting the order not on the gap ends a little bit less.
*/
// Defining the variables to decide.
   Print("order time", order_time);
   double current_openprice = iOpen(Symbol(), PERIOD_M15, 0);
   double previous_highprice = iHigh(Symbol(), PERIOD_M15, 1);
   double previous_lowprice = iLow(Symbol(), PERIOD_M15, 1);
   double point_gap = MarketInfo(Symbol(), MODE_POINT);
   int spread_gap = MarketInfo(Symbol(), MODE_SPREAD);
   datetime current_time = iTime(Symbol(), PERIOD_M15, 0);
// catching the gap on sell upper gap
   if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap &&
      current_time != order_time)
     {
       int ticket = OrderSend(Symbol(), OP_SELL, lotsize_gap, Bid, 0, 0, 
                              previous_highprice + spread_gap*point_gap, 
                              "", 4, 0, Red);
       order_time = iTime(Symbol(), PERIOD_M15, 0);
       Print("I am inside (sell) :-)", order_time);
       //----
       if(ticket < 0)
         {
           Print("OrderSend failed with error #", GetLastError());
         }
     }
//catching the gap on buy down gap
   if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap &&
      current_time != order_time)
     {
       ticket = OrderSend(Symbol(), OP_BUY, lotsize_gap, Ask, 0, 0, 
                          previous_lowprice - spread_gap*point_gap,
                          "", 5, 0, Green);
       order_time = iTime(Symbol(), PERIOD_M15, 0);
       Print("I am inside (buy) :-)", order_time);
       if(ticket < 0)
         {
           Print("OrderSend failed with error #", GetLastError());
         }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains open prices of each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features:

BackTest : EURUSD on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.00 Total Net Profit:63.35

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.00 Total Net Profit:701.32

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:224.71

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:69.21 Total Net Profit:95.50

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:58.74 Total Net Profit:214.80

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.00 Total Net Profit:20.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:2.56 Total Net Profit:61.18

BackTest : EURUSD on H1

From 2010-04-01 to 2010-04-30 Profit Factor:0.00 Total Net Profit:155.92

BackTest : EURUSD on H1

From 2010-05-01 to 2010-05-31 Profit Factor:0.00 Total Net Profit:213.63

BackTest : EURUSD on H1

From 2010-06-01 to 2010-06-30 Profit Factor:0.69 Total Net Profit:-22.55

Request Backtest for gaps


From : (yyyy/mm/dd) To: (yyyy/mm/dd)

Pair: Period: