PIPQuest





/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                     PIPQuest.mq4 |
//|                                                         emsjoflo |
//|                                  automaticforex.invisionzone.com |
//+------------------------------------------------------------------+
#property copyright "emsjoflo"
#property link      "automaticforex.invisionzone.com"

//---- input parameters
extern int       nPips=65;
extern int       UseTrStopLevelAsTrailingStop=1;
extern double    lots=0.01;
extern int       StopLoss=0;
extern int       Slippage=4;
extern double ATRmultiplier= 0.45;

double   atr,stop,atrstop,TrStopLevel,SL;
datetime LastOrderTime;
int      i, buys, sells;
int       BarsBackToGetTrStopLevel=1;  //don't change this, gives unreliable results
int       ExitOnBarAfterArrow=1; // don't change this either.  
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
TrStopLevel=iCustom(NULL,0,"PIPQind",nPips,4,BarsBackToGetTrStopLevel); 
//check for open orders first 
if (OrdersTotal()>0)
   {
   buys=0;
   sells=0;
   for (i=0;i<OrdersTotal();i++)
      {
      OrderSelect(i,SELECT_BY_POS);
      if (OrderSymbol()==Symbol())
         {
         if (OrderType()== OP_BUY)
            {
            if (iCustom(NULL,0,"PIPQind",nPips,1,ExitOnBarAfterArrow)>0) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Orange);
            else 
               {
               buys++;
               if (UseTrStopLevelAsTrailingStop==1 && TrStopLevel > OrderStopLoss())OrderModify(OrderTicket(),OrderOpenPrice(),TrStopLevel,OrderTakeProfit(),0,Khaki);
               }
            }
         if (OrderType()== OP_SELL) 
            {
            if (iCustom(NULL,0,"PIPQind",nPips,0,ExitOnBarAfterArrow)>0) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Yellow);
            else sells++;
               {
               if (UseTrStopLevelAsTrailingStop==1 && TrStopLevel < OrderStopLoss())OrderModify(OrderTicket(),OrderOpenPrice(),TrStopLevel,OrderTakeProfit(),0,Khaki);
               }
            }
         }
      }
   }
 
if (iCustom(NULL,0,"PIPQind",nPips,0,1)>0 && buys ==0 && (CurTime()-LastOrderTime)/60 > Period())
   {
   //Print("Buy condition");
   atr=iATR(NULL,0,14,1);
   stop=Low[Lowest(NULL,0,MODE_LOW,3,1)];
   atrstop =NormalizeDouble(TrStopLevel-atr*ATRmultiplier,MarketInfo(Symbol(),MODE_DIGITS));
   if (atrstop > stop) stop = atrstop;
   if (StopLoss >1) SL=Ask-StopLoss*Point;
   else SL = stop;
   OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,SL,0,"sr",123,0,Green);
   LastOrderTime=CurTime();
   }
 if (iCustom(NULL,0,"PIPQind",nPips,1,1)>0 && sells ==0 && (CurTime()-LastOrderTime)/60 > Period())
   {
   //Print ("Sell condition");
   atr=iATR(NULL,0,14,1);
   stop=High[Highest(NULL,0,MODE_HIGH,3,1)];
   atrstop = NormalizeDouble(TrStopLevel+atr*ATRmultiplier,MarketInfo(Symbol(),MODE_DIGITS));
   if (atrstop < stop) stop =atrstop;
   if (StopLoss>1) SL=Bid+StopLoss*Point;
   else SL = stop;
   OrderSend(Symbol(),OP_SELL,lots,Bid,Slippage,SL,0,"sr",123,0,Red);
   LastOrderTime=CurTime();
   }   
   
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

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


Indicator Curves created:


Indicators Used:


Indicator of the average true range


Custom Indicators Used:
PIPQind

Order Management characteristics:
Checks for the total of open orders

It Closes Orders by itself
It can change open orders parameters, due to possible stepping strategy
It automatically opens orders when conditions are reached

Other Features:

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:1.04 Total Net Profit:5.00

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.86 Total Net Profit:-12.46

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.41 Total Net Profit:-182.90

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.00 Total Net Profit:-154.60

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:1.27 Total Net Profit:278.61

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.41 Total Net Profit:-85.40

BackTest : USDCHF on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.10 Total Net Profit:-114.18

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.44 Total Net Profit:-55.95

Request Backtest for PIPQuest


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

Pair: Period: