3MA01EXP





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

//+------------------------------------------------------------------+
//| 3MA Bunny Cross Expert                               |
//+------------------------------------------------------------------+
#property copyright "Ron Thompson"
#property link      "http://www.lightpatch.com/forex"

// User Input
extern double Lots = 0.1;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {
   return(0);
  }


//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
   double   cMAfst=0, pMAfst=0;
   double   cMAslo=0, pMAslo=0;
   double    MA100=0;

      
   int    total=0;
   bool   found=false;
   int    otype=0;
   double otime=0;

   int      cnt=0;
   
   //
   // Error checking
   //
   
   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);
     }
   
   if(AccountFreeMargin()<(1000*Lots))
     {
      Print("We have no money");
      return(0);
     }

   //
   // only one order at a time/per symbol 
   // so see if our symbol has an order open
   //

   Comment(" ");
   
   cMAfst=iMA(Symbol(),0,5 ,0,MODE_LWMA,PRICE_CLOSE, 1);
   pMAfst=iMA(Symbol(),0,5 ,0,MODE_LWMA,PRICE_CLOSE, 2);
      
   cMAslo=iMA(Symbol(),0,20,0,MODE_LWMA,PRICE_CLOSE, 1);
   pMAslo=iMA(Symbol(),0,20,0,MODE_LWMA,PRICE_CLOSE, 2);

   // rising or falling
   if ((pMAfst<=cMAslo && cMAfst>=cMAslo) || (pMAfst>=cMAslo && cMAfst<=cMAslo))
     {
      // check for existing order
      found=false;
      otype=-1;
      
      total=OrdersTotal();
      for(cnt=0;cnt<OrdersTotal();cnt++)
        {
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
         if(OrderSymbol()==Symbol())
           {
            if(OrderOpenTime()>Time[3])
              { 
               found=true;
               otype=OrderType();
               break;
              }
           }
        }
     }

   if (found==true)
     {
      if (pMAfst<=cMAslo && cMAfst>=cMAslo && otype==1)  //exist sell
        {
         OrderClose(OrderTicket(),Lots,Bid,0,Red);
         Print("BUY  Order started  ",Ask);
         OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"BC Buy ",16123,0,White);
         if(GetLastError()==0)Comment("BC_BUY  Order opened : ",Ask);
        }
      if (pMAfst>=cMAslo && cMAfst<=cMAslo && otype==0)  // exist buy
        {
         OrderClose(OrderTicket(),Lots,Ask,0,White);
         Print("SELL Order started  ",Bid);
         OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"BC Sell",16321,0,Red);
         if(GetLastError()==0)Comment("BC_SELL Order opened : ",Bid );
        }
     }


      else // not found, so create
     {
      if (pMAfst<=cMAslo && cMAfst>=cMAslo)  //rising
        {
         Print("BUY  Order started  ",Ask);
         OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"BC Buy ",16123,0,White);
         if(GetLastError()==0)Comment("BC_BUY  Order opened : ",Ask);
        }
      if (pMAfst>=cMAslo && cMAfst<=cMAslo)  //falling
        {
         Print("SELL Order started  ",Bid);
         OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"BC Sell",16321,0,Red);
         if(GetLastError()==0)Comment("BC_SELL Order opened : ",Bid );
        }
     }

   return(0);
  }





Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders
It Closes Orders by itself
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.54 Total Net Profit:-9682.76

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.05 Total Net Profit:-9451.59

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.17 Total Net Profit:-9719.56

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.17 Total Net Profit:-9808.07

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.67 Total Net Profit:-12077.73

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.63 Total Net Profit:-5826.13

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:32.76 Total Net Profit:59920.20

Request Backtest for 3MA01EXP


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

Pair: Period: