Forex SKY





//+------------------------------------------------------------------+
//|                                                    Forex Sky.mq4 |
//|                          Copyright © 2009, Sivakumar Paulsuyambu |
//|                                 http://softinfolife.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

datetime Time0 = 0;

extern int TakeProfit = 100;
extern int StopLoss = 3000;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
           
          if(
             (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)>0 && iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)>0.00009
             && (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1)<=0 || iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,2)<=0
                 || iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,3)<=0
                  )                  
                  )                 
            )
          { 
           if(OrdersTotal()==0)
           {
              if (Time0 != Time[0] && CheckTodaysOrders()==0)
               {

                OrderSend(Symbol(),OP_BUY,0.1,Ask,2,Ask-StopLoss*Point,Ask+TakeProfit*Point,"My order #2",16384,0,Green);
                Time0 = Time[0];
              
                } 
           }
          } 
           else if(
             (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)<0 && iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)<-0.0004
              && (iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1)>=0 || iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,2)>=0
                 || iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,3)>=0
                  )
              &&    iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,4)>=0.001  )
              || iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,4)>=0.003 
            )
          { 
           if(OrdersTotal()==0)
           {
              if (Time0 != Time[0] && CheckTodaysOrders()==0)
               {

               OrderSend(Symbol(),OP_SELL,0.1,Bid,2,Bid+StopLoss*Point,Bid-TakeProfit*Point,"My order #2",16384,0,Green);
               
                Time0 = Time[0];
              
                } 
           }
          } 
          

//----
   return(0);
  }
//+------------------------------------------------------------------+


int CheckTodaysOrders(){

int TodaysOrders = 0;

for(int i = OrdersTotal()-1; i >=0; i--){

OrderSelect(i, SELECT_BY_POS,MODE_TRADES);

if(TimeDayOfYear(OrderOpenTime()) == TimeDayOfYear(TimeCurrent())){

TodaysOrders += 1;

}

}

for(i = OrdersHistoryTotal()-1; i >=0; i--){

OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);

if(TimeDayOfYear(OrderOpenTime()) == TimeDayOfYear(TimeCurrent())){

TodaysOrders += 1;

}

}

return(TodaysOrders);

}



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:


Indicators Used:

MACD Histogram


Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders
It automatically opens orders when conditions are reached

Checks for the total of closed orders

Other Features:

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.40 Total Net Profit:-179.92

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.44 Total Net Profit:-87.73

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.50 Total Net Profit:-150.61

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.31 Total Net Profit:-523.56

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.53 Total Net Profit:-1016.51

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.25 Total Net Profit:-260.34

BackTest : USDCHF on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.17 Total Net Profit:-239.50

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.26 Total Net Profit:-257.57

Request Backtest for Forex SKY


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

Pair: Period: