BigP2





#property copyright "@2009 Desynced Tech"
#property link      "http://desynced.no-ip.org/fx"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

datetime lastOrder;

extern int takeProfit = 60;

extern int       FastEMA=8;
extern int       FFastEMA=7;
extern int       FFFastEMA=6;
extern int       SlowEMA=17;
extern int       SSlowEMA=16;
extern int       SSSlowEMA=15;
extern int       SignalSMA=9;
extern int       SSignalSMA=8;
extern int       SSSignalSMA=7;


int ticket ;

int MAGIC = 12;
int orderType ;
int decision () {


   double macd_M1=iMACD(NULL,PERIOD_M1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); 
    double macd_MM1=iMACD(NULL,PERIOD_M1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); 
    double macd_M5=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); 
    double macd_MM5=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
    double macd_M15=iMACD(NULL,PERIOD_M15,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); 
    double macd_MM15=iMACD(NULL,PERIOD_M15,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
    double macd_M30=iMACD(NULL,PERIOD_M30,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); 
    double macd_MM30=iMACD(NULL,PERIOD_M30,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); 
    double macd_H1=iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); 
    double macd_HH1=iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
    double macd_H4=iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); 
    double macd_HH4=iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); 

    string  trend_signal = "", trend_main = "", trend_level = "";
    color   color_m1, color_m5, color_m15, color_m30, color_h1, color_h4, color_d1, color_w1, color_mn,
            color_signal, color_main, color_level;
           
    // UP Data
    if ((macd_M5 > macd_MM5) && (macd_M1 > macd_MM1)) { trend_signal = "TREND/UP"; color_signal = Lime;}
     //Down Data   
    if ((macd_M5 < macd_MM5) && (macd_M1 < macd_MM1)) { trend_signal = "TREND/DN"; color_signal = Red; }
    
    //Consolidation Data
    if ((macd_M5 < macd_MM5) && (macd_M1 > macd_MM1)) { trend_signal = "SIDEWAY"; color_signal = Orange; }
    if ((macd_M5 > macd_MM5) && (macd_M1 < macd_MM1)) { trend_signal = "SIDEWAY"; color_signal = Orange; }
    
    if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 > macd_HH1)&& (macd_H4 < macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; }
    if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 < macd_HH1)&& (macd_H4 > macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; }
     
    if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1) && (macd_H4 < macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; }
    if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1) && (macd_H4 > macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; }
    
    
    if ((macd_M5 > macd_MM5) && (macd_M15 > macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1) && (macd_H4 > macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; }
    if ((macd_M5 < macd_MM5) && (macd_M15 < macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 >macd_HH1) && (macd_H4 < macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; }
    
    if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 > macd_HH1)) { trend_main = "TREND/UP"; color_main = YellowGreen; }
    if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 < macd_HH1)) { trend_main = "TREND/DN"; color_main = Tomato; }
    
    if ((macd_M15 < macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1)) { trend_main = "TREND/DN"; color_main = Tomato; }
    if ((macd_M15 > macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1)) { trend_main = "TREND/UP"; color_main = YellowGreen; }
    
    if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1)) { trend_main = "TREND/DN"; color_main = Red; }
    if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1)) { trend_main = "TREND/UP"; color_main = Lime; }
    
    if ((macd_M5 < macd_MM5) && (macd_M15 < macd_MM15) && (macd_H1 > macd_HH1) && (macd_H4 > macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; }
    if ((macd_M5 > macd_MM5) && (macd_M15 > macd_MM15) && (macd_H1 < macd_HH1) && (macd_H4 < macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; }
    
    if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 < macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; }
    if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 > macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; }
    
    if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 > macd_HH4)) { trend_level = "STRONG"; color_level = Yellow; }
    if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 < macd_HH4)) { trend_level = "STRONG"; color_level = Yellow; }
    
    if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 > macd_HH4)) { trend_main = "TREND/UP"; color_main = Lime; }
    if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 < macd_HH4)) { trend_main = "TREND/DN"; color_main = Red; }
    
     
    if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 < macd_HH4)) { trend_main = "TREND/UP"; color_main = Lime; }
    if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 > macd_HH4)) { trend_main = "TREND/DN"; color_main = Red; }              



     double incolor = iCustom(NULL,0,"lswpr_in_color",4,0);
     
      double incolorx = iCustom(NULL,0,"lswpr_in_color",4,1);
      
      
      string adap = "";
      
      int adaptrend = 0 ;
      if ( incolor > incolorx )  {
         adap = "going up";
         
         adaptrend = 1;
      }
      else if ( incolor < incolorx ) {
       adap = "going down";
       adaptrend = -1;
      }
   
  
     
     double incolor0 = iCustom(NULL,0,"lswpr_in_color",0,0);
     double incolor1 = iCustom(NULL,0,"lswpr_in_color",1,0);
     double incolor2 = iCustom(NULL,0,"lswpr_in_color",2,0);


   
   double ad=(iCustom(NULL,0,"adaptive rsi",0,0)*10000-iCustom(NULL,0,"adaptive rsi",0,1)*10000);
   Comment ( "current Value = " , ad , " trendlevel " , trend_level , " trend_main" , trend_main ,  " " , trend_signal , " adap " , adap );
   if (ad>9  ) {
   
       if ( trend_level == "STRONG" && trend_main == "TREND/UP" && trend_signal == "TREND/UP" && adaptrend == 1 )  return(1);
       
   }
   
   
   if (  ad<-9) {
   
       if ( trend_level == "STRONG" && trend_main == "TREND/DN" && trend_signal == "TREND/DN" && adaptrend == -1 )  return(-1);  
   }
   
   
   

}
int init()
  {
//----
   
//----
   return(0);
  }


bool canTrade() {

   if ( Minute() == 0 ) return(false);

   if ( Hour() >= 1 && Hour() < 2 ) return (false);
   
   if ( Hour() >= 9 && Hour() < 10 ) return (false);
   
   if ( Hour() >= 13 && Hour() < 14 ) return (false);
   
   return (true);

}


//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
  int decision = decision();
  
  /*
  if ( OrdersTotal() > 0 ) {
      
      if ( (TimeCurrent() - lastOrder ) > 60*60*2 && orderType == OP_BUY) {
      
            OrderClose(ticket,0.1,Bid,3,Red);
      
      }
      if ( (TimeCurrent() - lastOrder ) > 60*60*2 && orderType == OP_SELL ) {
         OrderClose(ticket,0.1,Ask,3,Red);
      
      }
  
   return(0);
  }
  */
  
  double lots = 0.1;
  
  
  //if ( Hour()   == 17 || Hour() == 15 ) lots = 0.2;
  
   if ( !canTrade() ) return(0);
   if ( decision == 1 && (TimeCurrent() - lastOrder ) > (60*60*3 ) ) {
   
              
              
               if ( OrdersTotal() == 0 ) {
               //
                  //   Print("buy " , y0 , " " , y1);
              //       Print("buy ", (x0 - y0)*1000 , " ==>" , l0, " =>", val);
                      ticket = OrderSend(Symbol(),OP_BUY, lots, Ask, 3,0/* Ask-70*Point*/,Ask+takeProfit*Point,"", MAGIC, 0, Red); 
                      lastOrder = TimeCurrent();
                      orderType  = OP_BUY;
                      
               }
  
   
   }
   
    else if ( decision == -1 && (TimeCurrent() - lastOrder ) > (60*60*3 ) ) {
   
   if ( OrdersTotal() == 0 ) {
   
         
         ticket =  OrderSend(Symbol(),OP_SELL, lots, Bid, 3, 0/*Bid+70*Point*/,Bid-takeProfit*Point,"", MAGIC, 0, Red); 
         lastOrder = TimeCurrent();
         orderType = OP_SELL;
   }
  
  }

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



Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:

MACD Histogram



Custom Indicators Used:
adaptive rsi
lswpr_in_color

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.00 Total Net Profit:0.00

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:6.35 Total Net Profit:79.67

BackTest : EURUSD on H1

From 2010-04-01 to 2010-04-30 Profit Factor:0.65 Total Net Profit:-45.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.00 Total Net Profit:17.76

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.05 Total Net Profit:-647.26

BackTest : USDCAD on H1

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

BackTest : USDCAD on H1

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

BackTest : USDCHF on H1

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

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.12 Total Net Profit:-50.35

Request Backtest for BigP2


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

Pair: Period: