有您的持续关注
我们会做得更好

智能交易系统DUMMYEA-混沌操作法1



DUMMYEA-混沌操作法1 EA是根据指标Fractals、Alligator、AO、AC信号在进行交易。策略方法称之为混沌操作法。

本网收集整理智能交易EA仅为MQL4编程爱好者提供语法及相关编程技巧的学习研究之用,智能交易存在极高的风险测试请用模拟盘,请勿用于实盘。DUMMYEA-混沌操作法1 EA源码:

//+------------------------------------------------------------------+
//|                                          DUMMYEA-混沌操作法1.mq4 |
//|                       Copyright @2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright @2010, MetaQuotes Software Corp."
#property link      "http://www.125808047.com"

extern double 下单手数 = 0.1;
extern int Slippage = 3;
extern int MagicNumber = 88888888;

int ticket;
int HoldingOrderType;

bool fxbuyorder=false;//最后上分型是否有买单
double fxbuyplice;
bool fxsellorder=false;//最后下分型是否有卖单
double fxsellplice;
bool action = false;
bool cg = false;

double stopbuyplice; //买单平仓价格
double stopsellplice;//卖单平仓价格

int init()
  {
   ObjectCreate("comment_label", OBJ_LABEL, 0, 0, 0);
   ObjectSet("comment_label", OBJPROP_XDISTANCE, 50);
   ObjectSet("comment_label", OBJPROP_YDISTANCE, 20);
   ObjectSetText("comment_label", "DUMMYEA-混沌操作法1", 10, "Arial", Yellow);
   return(0);
  }
int deinit()
  {
   ObjectDelete("comment_label");
   Comment("www.125808047.com");
   return(0);
  }
  
  
int start()
  {
//----
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++获取最后一个上下分型价格
   double fenxinguper=0;//最后一个上分型价格
   double fenxinglower=0;//最后一个下分型价格
   int i=2;
   while(fenxinguper == 0 || fenxinglower==0){
         i++;
         if(iFractals(NULL, 0, MODE_UPPER, i)!=0)fenxinguper=iFractals(NULL, 0, MODE_UPPER, i);
         if(iFractals(NULL, 0, MODE_LOWER, i)!=0)fenxinglower=iFractals(NULL, 0, MODE_LOWER, i);
     }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     
     
     double limeline = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, 0);//鳄鱼绿线
     double redline = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 0);//鳄鱼红线
     double blueline = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 0);//鳄鱼蓝线
     
     if(Close[1]<redline && Close[0]>=redline)fxbuyorder=false;
     if(Close[1]>redline && Close[0]<=redline)fxsellorder=false;
     
     double buyline=limeline;
     if(redline>buyline)buyline=redline;
     if(blueline>buyline)buyline=blueline;
     double sellline=limeline;
     if(redline<buyline)sellline=redline;
     if(blueline<buyline)sellline=blueline;
     
     if(Close[0]>fenxinguper && fenxinguper>buyline && AOAC(OP_BUY)==true && fxbuyorder==false && OrdersTotal()==0){
         CloseAllSell();
         ticket=OrderSend(Symbol(),OP_BUY,下单手数,NormalizeDouble(Ask, Digits),Slippage,0,0,"dummy-buy",MagicNumber,0,Red);
           if(ticket>0)
           {
              if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
              {
                 fxbuyorder=true;
                 fxbuyplice=fenxinguper;
                 stopbuyplice=fenxinglower;
                 HoldingOrderType = OrderType();
                 
                 Print("Pivot dummy-buy order opened : ",OrderOpenPrice());
              }
              else
              {
                 Print("Error opening Pivot dummy-buy order : ",GetLastError());
                 return(0);
              }
           }
     }else
     if(Close[0]<fenxinglower && fenxinglower<sellline && AOAC(OP_SELL)==true && fxsellorder==false  && OrdersTotal()==0){
         CloseAllBuy();
         ticket=OrderSend(Symbol(),OP_SELL,下单手数,NormalizeDouble(Bid, Digits),Slippage,0,0,"dummy-sell",MagicNumber,0,Blue);
           if(ticket>0)
           {
              if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
              {
                 fxsellorder=true;
                 fxsellplice=fenxinglower;
                 stopsellplice=fenxinguper;
                 HoldingOrderType = OrderType();
                 
                 Print("Pivot dummy-sell order opened : ",OrderOpenPrice());
              }
              else
              {
                 Print("Error opening Pivot dummy-sell order : ",GetLastError());
                 return(0);
              }
           }
     }
     
     if(iFractals(NULL, 0, MODE_UPPER, 3)!=0 && stopbuyplice<fenxinglower)stopbuyplice=fenxinglower;//新的上分型形成后把买单平仓价格上移一次
     if(iFractals(NULL, 0, MODE_LOWER, 3)!=0 && stopsellplice>fenxinguper)stopsellplice=fenxinguper;//新的下分型形成后把卖单平仓价格上移一次
     if(Close[0]>stopsellplice )CloseAllSell();
     if(Close[0]<stopbuyplice )CloseAllBuy();
//     if(AOAC(OP_BUY)==true)CloseAllWinSell();//绿色区域平盈利卖单
//     if(AOAC(OP_SELL)==true)CloseAllWinBuy();//红色区域平盈利买单
     if(AccountEquity()-AccountBalance()>15.0){CloseAllSell();CloseAllBuy();}
//     if(AccountEquity()-AccountBalance()<-20.0){CloseAllSell();CloseAllBuy();}
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


bool AOAC(int type)//AOAC组成区域返回信号子函数
{
   double AO0=iAO(NULL, 0, 0);
   double AO1=iAO(NULL, 0, 1);
   double AC0=iAC(NULL, 0, 0);
   double AC1=iAC(NULL, 0, 1);
  
   switch(type)
   {
   case OP_BUY:
     if(AO0>AO1 && AC0>AC1)
    {
     return (true);
    }else return(false);
    break;
    
   case OP_SELL:
     if(AO0<AO1 && AC0<AC1)
    {
     return (true);
    }else return(false);
    break;
   }
return(0);
}


void CloseAllSell()
{
   bool CAS = FALSE;
   for (int t=0; t<OrdersTotal(); t++)
   {
      cg = OrderSelect(t, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber )
      CAS = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), Digits), Slippage, Yellow);
   }
}


void CloseAllBuy() 
{
   bool CAB = FALSE;
   for (int t=0; t<OrdersTotal(); t++) 
   {
      cg = OrderSelect(t, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber)
      CAB = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), Digits), Slippage, Yellow);
   }
}


void CloseAllWinSell() 
{
   bool CAWS = FALSE;
   for (int t=0; t<OrdersTotal(); t++) 
   {
      cg = OrderSelect(t, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber && OrderProfit() > OrderLots()*20.0 )
      CAWS = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), Digits), Slippage, Yellow);
   }
}

void CloseAllWinBuy() 
{
   bool CAWB = FALSE;
   for (int t=0; t<OrdersTotal(); t++)
   {
      cg = OrderSelect(t, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber && OrderProfit() > OrderLots()*20.0)
      CAWB = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), Digits), Slippage, Yellow);
   }
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 智能交易系统DUMMYEA-混沌操作法1
上一篇:
下一篇:
分享到:更多 ()