RobotPowerM5_meta4V1





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

//+------------------------------------------------------------------+
//|                                                      RobotBB.mq4 |
//|                               Copyright © 2005,          Company |
//|                                          http://                 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005"
#property link      "http://www.funds.com"

// A reliable expert, use it on 5 min charts (GBP is best) with 150/pips profit limit. 
// . No worries, check the results 
extern int BullBearPeriod=5;
extern double lots         = 1.0;           // 
extern double trailingStop = 15;            // trail stop in points
extern double takeProfit   = 150;            // recomended  no more than 150
extern double stopLoss     = 45;             // do not use s/l
extern double slippage     = 3;

extern string nameEA       = "DayTrading";  // EA identifier. Allows for several co-existing EA with different values

double bull,bear;
//double stochHistCurrent, stochHistPrevious, stochSignalCurrent, stochSignalPrevious;
//double sarCurrent, sarPrevious, momCurrent, momPrevious;
double realTP, realSL,b,s,sl,tp;
bool isBuying = false, isSelling = false, isClosing = false;
int cnt, ticket;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
   return(0);
}

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

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   // Check for invalid bars and takeprofit
   if(Bars < 200) {
      Print("Not enough bars for this strategy - ", nameEA);
      return(-1);
   }
   calculateIndicators();                      // Calculate indicators' value   
   
   // Control open trades
   int totalOrders = OrdersTotal();
   int numPos = 0;
   for(cnt=0; cnt<totalOrders; cnt++) {        // scan all orders and positions...
      OrderSelect(cnt, SELECT_BY_POS);         // the next line will check for ONLY market trades, not entry orders
      if(OrderSymbol() == Symbol() && OrderType() <= OP_SELL ) {   // only look for this symbol, and only orders from this EA      
         numPos++;
         if(OrderType() == OP_BUY) {           // Check for close signal for bought trade
               
            if(trailingStop > 0) {             // Check trailing stop
               if(Bid-OrderOpenPrice() > trailingStop*Point) {
                  if(OrderStopLoss() < (Bid - trailingStop*Point))
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-trailingStop*Point,OrderTakeProfit(),0,Blue);
               }
            }
         } else {                              // Check sold trade for close signal
            
            if(trailingStop > 0) {             // Control trailing stop
               if(OrderOpenPrice() - Ask > trailingStop*Point)
                {
                  if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + trailingStop*Point)
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+trailingStop*Point,OrderTakeProfit(),0,Red);
               }           
            } 
         }
      }
   }
   
   // If there is no open trade for this pair and this EA
   if(numPos < 1) {   
      if(AccountFreeMargin() < 1000*lots) {
         Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA);
         return(0);
      }
      if(isBuying && !isSelling && !isClosing) {  // Check for BUY entry signal
         sl = Ask - stopLoss * Point;
         tp = Bid + takeProfit * Point;
         
        // ticket = OrderSend(OP_BUY,lots,Ask,slippage,realSL,realTP,nameEA,16384,0,Red);  // Buy
         //OrderSend(OP_BUY,lots,Ask,slippage,realSL,realTP,0,0,Red);
         OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,sl,tp,nameEA+CurTime(),0,0,Green);
         Comment(sl);
         if(ticket < 0)
            Print("OrderSend (",nameEA,") failed with error #", GetLastError());
         prtAlert("Day Trading: Buying"); 
      }
      if(isSelling && !isBuying && !isClosing) {  // Check for SELL entry signal
          sl = Bid + stopLoss * Point;
          tp = Ask - takeProfit * Point;
        // ticket = OrderSend(NULL,OP_SELL,lots,Bid,slippage,realSL,realTP,nameEA,16384,0,Red); // Sell
         OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,sl,tp,nameEA+CurTime(),0,0,Red);
         if(ticket < 0)
            Print("OrderSend (",nameEA,") failed with error #", GetLastError());
         prtAlert("Day Trading: Selling"); 
      }
   }
   return(0);
}

void calculateIndicators() {    // Calculate indicators' value   
 

   bull = iBullsPower(NULL,0,BullBearPeriod,PRICE_CLOSE,1);
   bear = iBearsPower(NULL,0,BullBearPeriod,PRICE_CLOSE,1);
Comment("bull+bear= ",bull + bear);
   //sarCurrent          = iSAR(NULL,0,0.02,0.2,0);           // Parabolic Sar Current
   //sarPrevious         = iSAR(NULL,0,0.02,0.2,1);           // Parabolic Sar Previuos
   //momCurrent          = iMomentum(NULL,0,14,PRICE_OPEN,0); // Momentum Current
  // momPrevious         = iMomentum(NULL,0,14,PRICE_OPEN,1); // Momentum Previous
   
  
   b = 1 * Point + iATR(NULL,0,5,1) * 1.5;
   s = 1 * Point + iATR(NULL,0,5,1) * 1.5;
   // Check for BUY, SELL, and CLOSE signal
  // isBuying  = (sarCurrent<=Ask && sarPrevious>sarCurrent && momCurrent<100 && macdHistCurrent<macdSignalCurrent && stochHistCurrent<35);
  // isSelling = (sarCurrent>=Bid && sarPrevious<sarCurrent && momCurrent>100 && macdHistCurrent>macdSignalCurrent && stochHistCurrent>60);
    isBuying  = (bull+bear>0);
    isSelling = (bull+bear<0);

   isClosing = false;
}

void prtAlert(string str = "") {
   Print(str);
   //Alert(str);
   //SpeechText(str,SPEECH_ENGLISH);
   // SendMail("Subject EA",str);
}

//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:

Bulls Power indicator
Bears Power indicator
Indicator of the average true range


Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders

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

Other Features:

It issuies visual alerts to the screen

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:1.08 Total Net Profit:7072.50

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.82 Total Net Profit:-9036.90

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:1.17 Total Net Profit:24356.10

BackTest : GBPUSD on H1

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

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 : USDJPY on H1

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

Request Backtest for RobotPowerM5_meta4V1


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

Pair: Period: