aaaea-gubi





//+------------------------------------------------------------------+
//|                           Designed by OKwh, China               |
//|                   Copyright 2007, OKwh Dxdcn                    |
//|                                 http://blog.sina.com.cn/FXTrade |
//|     Õâ¸öeaÊÇÓÃdxdchµÄÄ£°å¸Ä±àµÄ£¬²¢Çҵõ½ÁËdxdch±¾È˵ÄÇ××ÔÖ¸µ¼  |
//|                                 ËùÒÔ±£ÁôÔ­×÷ÕßµÄÐÅÏ¢            |
//|                AAA  ¸Ä±à http://hi.baidu.com/shangwuju          |
//+------------------------------------------------------------------+
#property  copyright "Copyright 2007 , Dxd, China."
#property  link      "http://blog.sina.com.cn/FXTrade ,  http://www.mql4.com/users/DxdCn"
#define MAGICMA 200610011231
//+------------------------------------------------------------------+
//| ×¢ÒâûÓÐÖ¸±êÎļþÄÇЩproperty                   |
//+------------------------------------------------------------------+
//
extern double TakeProfit = 400;   //Ö¹Ó®µãÊý
extern   double StopLoss = 40;    //Ö¹ËðµãÊý
extern double TrailingStop =50;     //¸ú×ÙÖ¹Ó®µãÊýÉèÖÃ
extern   int maxOpen = 3;   //×î¶à¿ª²Ö´ÎÊýÏÞÖÆ 
extern int bb = 1;       //·ÇÁã¾ÍÔÊÐí¸ú×ÙÖ¹Ó®
extern double lots=0.2;   //Ò»´Îϵ¥ÊÖÊý
 
int i,   res;  //ʱ¼ä¿ØÖÆ, ½öµ±Ò»¸öʱ¼äÖÜÆÚÍê³É²Å¼ì²éÌõ¼þ
int init()   //³õʼ»¯
{ 

return(0); 
}
int deinit() { return(0); } //·´³õʼ»¯
//Ö÷³ÌÐò
int start()
{
CheckForOpen();    //¿ª²Ö ƽ²Ö Ìõ¼þ¼ì²é ºÍ²Ù×÷
if (bb>0)   CTP();   //¸ú×ÙÖ¹Ó®
return(0);
}
//+------ÏÂÃæÊǸ÷×Ó³ÌÐò--------------------------------------------+
//
//
//ƽ²Ö³ÖÓеÄÂòµ¥
void CloseBuy()
{
if (OrdersTotal( ) > 0 )   
{
  for(i=OrdersTotal()-1;i>=0;i--)
  {
  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)     break;
  if(OrderType()==OP_BUY) 
  {
    OrderClose(OrderTicket(),OrderLots(),Bid,4,White);
    Sleep(5000); 
  }
  }
}
}
//ƽ²Ö³ÖÓеÄÂôµ¥
void CloseSell()
{
if (OrdersTotal( ) > 0 )   
{
  for(i=OrdersTotal()-1;i>=0;i--)
  {
  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)     break;
  if(OrderType()==OP_SELL) 
    {
    OrderClose(OrderTicket(),OrderLots(),Ask,4,White);
    Sleep(5000); 
    }
  }
}
}
//ÅжÏÊÇ·ñÂò»òÂô»òƽ²Ö
int buyorsell()   //ÔÚÕâ¸öº¯Êý¼ÆËãÉèÖÃÄãµÄ½»Ò×ÐźŠ 
{
  
  double aaaslow10 ,aaaslow20,aaaslow30,aaafast10,aaafast20,aaafast30;
  double aaaslow40 ,aaaslow50,aaaslow60,aaafast40,aaafast50,aaafast60;
   double aaaslow11 ,aaaslow21,aaaslow31,aaafast11,aaafast21,aaafast31;
  double aaaslow41 ,aaaslow51,aaaslow61,aaafast41,aaafast51,aaafast61;
   double aaaslow12 ,aaaslow22,aaaslow32,aaafast12,aaafast22,aaafast32;
  double aaaslow42 ,aaaslow52,aaaslow62,aaafast42,aaafast52,aaafast62;
 //
  //GMMAShort6   GMMALong6 
  aaafast10=iCustom(NULL, 0, "GMMAShort6", 0 , 0, 0) ; 
  // µ÷ÓÃgubi¶ÌÏßÖ¸±ê (NULLµ±Ç°, 0µ±Ç°, "GMMAShort6"Ö¸±êÃû³Æ, 0ûÓвÎÊý , 0µÚÒ»¸öÖ¸±ê, 0µ±Ç°Î»ÖÃ)
  aaaslow10=iCustom(NULL, 0, "GMMALong6", 0 , 0, 0) ;
  aaafast20=iCustom(NULL, 0, "GMMAShort6", 0 , 1, 0) ;
  aaaslow20=iCustom(NULL, 0, "GMMALong6", 0 , 1, 0) ;
  aaafast30=iCustom(NULL, 0, "GMMAShort6", 0 , 2, 0) ;
  aaaslow30=iCustom(NULL, 0, "GMMALong6", 0 , 2, 0) ;
  aaafast40=iCustom(NULL, 0, "GMMAShort6", 0 , 3, 0) ;
  aaaslow40=iCustom(NULL, 0, "GMMALong6", 0 , 3, 0) ;
  aaafast50=iCustom(NULL, 0, "GMMAShort6", 0 , 4, 0) ;
  aaaslow50=iCustom(NULL, 0, "GMMALong6", 0 , 4, 0) ;
  aaafast60=iCustom(NULL, 0, "GMMAShort6", 0 , 5, 0) ;
  aaaslow60=iCustom(NULL, 0, "GMMALong6", 0 , 5, 0) ;
  //
  aaafast11=iCustom(NULL, 0, "GMMAShort6", 0 , 0, 1) ;
  aaaslow11=iCustom(NULL, 0, "GMMALong6", 0 , 0, 1) ;
  aaafast21=iCustom(NULL, 0, "GMMAShort6", 0 , 1, 1) ;
  aaaslow21=iCustom(NULL, 0, "GMMALong6", 0 , 1, 1) ;
  aaafast31=iCustom(NULL, 0, "GMMAShort6", 0 , 2, 1) ;
  aaaslow31=iCustom(NULL, 0, "GMMALong6", 0 , 2, 1) ;
  aaafast41=iCustom(NULL, 0, "GMMAShort6", 0 , 3, 1) ;
  aaaslow41=iCustom(NULL, 0, "GMMALong6", 0 , 3, 1) ;
  aaafast51=iCustom(NULL, 0, "GMMAShort6",0 , 4, 1) ;
  aaaslow51=iCustom(NULL, 0, "GMMALong6", 0 , 4, 1) ;
  aaafast61=iCustom(NULL, 0, "GMMAShort6", 0 , 5, 1) ;
  aaaslow61=iCustom(NULL, 0, "GMMALong6", 0 , 5, 1) ;
  //
  aaafast12=iCustom(NULL, 0, "GMMAShort6",0 , 0, 2) ;
  aaaslow12=iCustom(NULL, 0, "GMMALong6", 0 , 0, 2) ;
  aaafast22=iCustom(NULL, 0, "GMMAShort6",0 , 1, 2) ;
  aaaslow22=iCustom(NULL, 0, "GMMALong6", 0 , 1, 2) ;
  aaafast32=iCustom(NULL, 0, "GMMAShort6", 0 , 2, 2) ;
  aaaslow32=iCustom(NULL, 0, "GMMALong6", 0 , 2, 2) ;
  aaafast42=iCustom(NULL, 0, "GMMAShort6", 0 , 3, 2) ;
  aaaslow42=iCustom(NULL, 0, "GMMALong6", 0 , 3, 2) ;
  aaafast52=iCustom(NULL, 0, "GMMAShort6",0, 4, 2) ;
  aaaslow52=iCustom(NULL, 0, "GMMALong6", 0 , 4, 2) ;
  aaafast62=iCustom(NULL, 0, "GMMAShort6", 0 , 5, 2) ;
  aaaslow62=iCustom(NULL, 0, "GMMALong6", 0 , 5, 2) ;
  
//
if(aaaslow10>aaaslow20    && aaaslow20>aaaslow30 && aaaslow30>aaaslow40 && aaaslow40>aaaslow50 && aaaslow50>aaaslow60 && aaafast60>aaaslow10 && aaafast10>aaafast20 && aaafast20>aaafast30 &&  aaafast30>aaafast40 &&  aaafast40>aaafast50  &&  aaafast50>aaafast60 &&  aaafast30>=Bid )
  return (1); // Âò 
 if(aaaslow10>aaaslow20    && aaaslow20>aaaslow30 && aaaslow30>aaaslow40 && aaaslow40>aaaslow50 && aaaslow50>aaaslow60 && aaafast60>aaaslow10 && aaafast10>aaafast20 && aaafast11<aaafast21 && aaafast20>aaafast30 &&  aaafast30>aaafast40 &&  aaafast40>aaafast50  &&  aaafast50>aaafast60   )
  return (1); // Âò  
  if(aaaslow10>aaaslow20    && aaaslow20>aaaslow30 && aaaslow30>aaaslow40 && aaaslow40>aaaslow50 && aaaslow50>aaaslow60 && aaafast60>aaaslow10 && aaafast10>aaafast20 && aaafast11==aaafast21 && aaafast12<aaafast22 && aaafast20>aaafast30 &&  aaafast30>aaafast40 &&  aaafast40>aaafast50  &&  aaafast50>aaafast60   )
  return (1); // Âò  
if(aaaslow10<aaaslow20    && aaaslow20<aaaslow30 && aaaslow30<aaaslow40 && aaaslow40<aaaslow50 && aaaslow50<aaaslow60 && aaafast60<aaaslow10 && aaafast10<aaafast20 && aaafast20<aaafast30 &&  aaafast30<aaafast40 &&  aaafast40<aaafast50  &&  aaafast50<aaafast60 &&  aaafast30<=Ask )
  return (-1); // Âô
 if(aaaslow10<aaaslow20    && aaaslow20<aaaslow30 && aaaslow30<aaaslow40 && aaaslow40<aaaslow50 && aaaslow50<aaaslow60 && aaafast60<aaaslow10 && aaafast10<aaafast20 && aaafast11>aaafast21 && aaafast20<aaafast30 &&  aaafast30<aaafast40 &&  aaafast40<aaafast50  &&  aaafast50<aaafast60   )
  return (-1); //Âô
  if(aaaslow10<aaaslow20    && aaaslow20<aaaslow30 && aaaslow30<aaaslow40 && aaaslow40<aaaslow50 && aaaslow50<aaaslow60 && aaafast60<aaaslow10 && aaafast10<aaafast20 && aaafast11==aaafast21 && aaafast12>aaafast22 && aaafast20<aaafast30 &&  aaafast30<aaafast40 &&  aaafast40<aaafast50  &&  aaafast50<aaafast60   )
  return (-1); // Âô 
//
return (0); //²»½»Ò×
}
int nowbuyorsell = 0;
void CheckForOpen()
{
//if (Time[0] == lasttime ) return; //ÿʱ¼äÖÜÆÚ¼ì²éÒ»´Î  ʱ¼ä¿ØÖÆ
//lasttime = Time[0];
nowbuyorsell = buyorsell(); //»ñÈ¡ÂòÂôÐźÅ
 double aaafast10,aaaslow10,aaaslow60 ;
 aaafast10=iCustom(NULL, 0, "GMMAShort6", 0 , 0, 0) ;
 aaaslow10=iCustom(NULL, 0, "GMMALong6", 0 , 0, 0) ;
 aaaslow60=iCustom(NULL, 0, "GMMALong6", 0 , 5, 0) ;
if (nowbuyorsell == 1) //Âò¡¡ÏȽáÊøÒÑÂôµÄ
 CloseSell();
if ( aaafast10>=aaaslow60  )
  CloseSell();
  
if (nowbuyorsell == -1) //Âô¡¡ÏȽáÊøÒÑÂòµÄ
    CloseBuy();
if ( aaafast10<=aaaslow10  ) //Âô¡¡ÏȽáÊøÒÑÂòµÄ
    CloseBuy();
 
if (OrdersTotal( ) >= maxOpen) return ;   
if   (OrdersTotal( ) >=1)
{
if(TimeCurrent()-OrderOpenTime()<1800) return ;  //¼Ó²Ö¼ä¸ô30·ÖÖÓ
}
//Èç¹ûÒѳÖÓпª²Ö´ÎÊý´ïµ½×î´ó£¬²»×ö
if (nowbuyorsell==0) return;   //²»½»Ò×
TradeOK();   //ȥϵ¥½»Ò×
}
void TradeOK()   //ȥϵ¥½»Ò×
{
int error ;
if (nowbuyorsell == 1) //Âò 
  {
    res=OrderSend(Symbol(),OP_BUY,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA,0,Blue);
Sleep(5000); 
    return ;   
  }
if (nowbuyorsell == -1) //Âô
  {
   res=OrderSend(Symbol(),OP_SELL,lots,Bid,4,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",MAGICMA,0,Red); 
Sleep(5000); 
}
    return ;  
}
 void CTP()  //¸ú×ÙÖ¹Ó®
{
bool bs = false;
for (int i = 0; i < OrdersTotal(); i++)
{
  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)     break;
  if (OrderType() == OP_BUY) 
  {
    if ((Bid - OrderOpenPrice()) > (TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)))    //¿ª²Ö¼Û¸ñ µ±Ç°Ö¹ËðºÍµ±Ç°¼Û¸ñ±È½ÏÅжÏÊÇ·ñÒªÐ޸ĸú×ÙÖ¹Ó®ÉèÖÃ
    {
    if (OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) 
    {
      bs = OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Green);
    }
    }
  } 
  else if (OrderType() == OP_SELL) 
  {
    if ((OrderOpenPrice() - Ask) > (TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)))  //¿ª²Ö¼Û¸ñ µ±Ç°Ö¹ËðºÍµ±Ç°¼Û¸ñ±È½ÏÅжÏÊÇ·ñÒªÐ޸ĸú×ÙÖ¹Ó®ÉèÖÃ
 
    {
    if ((OrderStopLoss()) > (Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)))
    {     
      bs = OrderModify(OrderTicket(), OrderOpenPrice(),
        Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Tan);
}
    }
  }
}
}







Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:




Custom Indicators Used:
GMMAShort6
GMMALong6

Order Management characteristics:
Checks for the total of open orders

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

Other Features:

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 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 : EURUSD on H1

From 2009-08-01 to 2009-10-01 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:0.00

BackTest : USDCAD on H1

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

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

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

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

Request Backtest for aaaea-gubi


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

Pair: Period: