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

智能交易系统AC_AO_TREND



AC_AO_TREND这款EA名字是重新命名的,原名Chinese.mq4。出自国人之手,在编程方面可以借鉴。

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

//+------------------------------------------------------------------+
//|                                                   AC_AO_TREND.mq4|
//|                                     Copyright 2016, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com/"

extern double     MaximumRisk     =0.5;
extern double     DecreaseFactor  =2;
extern int        TrendSMA        =21;
extern bool       AddStopLoss     =false;
string            comment; 
static double     FPSMMA, myLips, myTheeth, myJaw,Lots;
int               mytext=0;
int init()    {   return(0);  }
int deinit()  {   return(0);  }
int start()
  {  int    ticket,AlSignal,TrSignal,FrSignal,AcSignal,AoSignal,ClSignal;
     comment ="ln";
     Lots    =LotsOptimized();
     AlSignal=FUNAlSignal();
     TrSignal=FUNTrSignal();
     FrSignal=FUNFrSignal();
     AcSignal=FUNAcSignal();
     AoSignal=FUNAoSignal();
     ClSignal=FUNClSignal();
     FPSMMA  =iMA(Symbol(),0,5,1,MODE_SMMA,PRICE_WEIGHTED,0);
     if(AlSignal==1 && FrSignal==1 && TrSignal==1 && AcSignal==1 && AoSignal==1 && OrdersTotal()<1)
       { ticket=OrderSend(Symbol(), OP_BUY,Lots,Ask,0,0,0,"trend"+Period()+"buy"+comment,0,0,Green); return(0);  }
     if(AlSignal==2 && FrSignal==2 && TrSignal==2 && AcSignal==2 && AoSignal==2 && OrdersTotal()<1)
       { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,0,0,"trend"+Period()+"sell"+comment,0,0,Red  ); return(0);  }
     if(OrdersTotal()>0 && AddStopLoss==true)  ModifyStopLoss();
     for(int num=0;num<OrdersTotal();num++)
       { bool cg = OrderSelect(num, SELECT_BY_POS, MODE_TRADES);
         if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) 
          { if(OrderType()==OP_BUY)
              { if(ClSignal==1) { cg = OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); return(0); } }
            else 
              { if(ClSignal==2) { cg = OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); return(0); } }
          }
       }
     return(0);
  }
void ModifyStopLoss()
  {  for(int c=0;c<OrdersTotal();c++)
        {  bool cg = OrderSelect(c,SELECT_BY_POS,MODE_TRADES);
           if(OrderSymbol()==Symbol())
             {  if( OrderType()==OP_BUY  && (OrderStopLoss()<myJaw || OrderStopLoss()==0))
                  { cg = OrderModify(OrderTicket(),OrderOpenPrice(),myJaw,0,0,Green); }
                if( OrderType()==OP_SELL && (OrderStopLoss()>myJaw || OrderStopLoss()==0))
                  { cg = OrderModify(OrderTicket(),OrderOpenPrice(),myJaw,0,0,Red);   }
             }
        }
  }
double LotsOptimized()  
  { double lot;
    int    orders=HistoryTotal();
    int    losses=0;
    lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
    if(DecreaseFactor>0) 
     {  for(int i=orders-1;i>=0;i--)  
           {  if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
              if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
              if(OrderProfit()>0) break;
              if(OrderProfit()<0) losses++; 
           }
    if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);   
     }
    if(lot<0.1) lot=0.1;
    return(lot);   
  }
int FUNClSignal()
   {  int myClSignal=0;
      if(FPSMMA<myLips-3*Point)        myClSignal=1;
      if(FPSMMA>myLips+3*Point)        myClSignal=2;
      return(myClSignal);
   }
int FUNAlSignal()
   {  int myAlSignal=0;
      FPSMMA=  iMA(Symbol(),0,5,1,MODE_SMMA,PRICE_WEIGHTED,0);
      myLips=  iAlligator(Symbol(),0,13,8,8,5,5,4,MODE_SMMA,PRICE_MEDIAN,MODE_GATORLIPS,0);
      myTheeth=iAlligator(Symbol(),0,13,8,8,5,5,4,MODE_SMMA,PRICE_MEDIAN,MODE_GATORTEETH,0);
      myJaw=   iAlligator(Symbol(),0,13,8,8,5,5,4,MODE_SMMA,PRICE_MEDIAN,MODE_GATORJAW,0);
      if( FPSMMA>myLips && myLips>myTheeth && myTheeth>myJaw && iClose(0,0,1)>myTheeth )    
        { myAlSignal=1;         }
      if( FPSMMA<myLips && myLips<myTheeth && myTheeth<myJaw && iClose(0,0,1)<myTheeth )    
        { myAlSignal=2;         }
      return(myAlSignal);
   }
int FUNTrSignal()
   {  int    myTrSignal=0;
      double TPSMMA=TrendSMA;
      double TrendSignal=iMA(Symbol(),0,TPSMMA,1,MODE_SMMA,PRICE_WEIGHTED,0);
      if ( iClose(Symbol(),0,1)>iOpen(Symbol(),0,1) &&  iLow(Symbol(),0,1)>TrendSignal ) 
         { myTrSignal=1;          }
      if ( iClose(Symbol(),0,1)<iOpen(Symbol(),0,1) && iHigh(Symbol(),0,1)<TrendSignal ) 
         { myTrSignal=2;          }
      return(myTrSignal);
   }
int FUNFrSignal()
   { double PreFrac_up,HLowest,HLower,                   PreFrac_down,LHighest,LHigher;
     int    i=0,PreFrac_upIndex,HLowestIndex,HLowerIndex,m=0,PreFrac_downIndex,LHighestIndex,LHigherIndex,myFrSignal;
     double FrSMMA=  iMA(Symbol(),0,5,1,MODE_SMMA,PRICE_WEIGHTED,0);
     while(PreFrac_up==0)                               
       {   PreFrac_up=iFractals(Symbol(),0,MODE_UPPER,i);
           PreFrac_upIndex=i;
           i++;
       }
     HLowestIndex=ArrayMinimum(High,PreFrac_upIndex,0);
     HLowest     =High[HLowestIndex]; 
     HLower      =High[HLowestIndex+1];
     HLowerIndex =HLowestIndex+1; 
     while(PreFrac_down==0) 
       {   PreFrac_down=iFractals(Symbol(),0,MODE_LOWER,m);
           PreFrac_downIndex=m;
           m++;
       }
     LHighestIndex=ArrayMaximum(Low,PreFrac_downIndex,0);
     LHighest     =Low[LHighestIndex];
     LHigher      =Low[LHighestIndex+1];
     LHigherIndex =LHighestIndex+1;
     if(PreFrac_up>myTheeth   && iClose(Symbol(),0,m-1)>myJaw && (iHigh(Symbol(),0,1)>HLower || iHigh(Symbol(),0,1)>PreFrac_up)  ) 
       { myFrSignal=1;        }
     if(PreFrac_down<myTheeth && iClose(Symbol(),0,i-1)<myJaw && (iLow(Symbol(),0,1)<LHigher || iLow(Symbol(),0,1)<PreFrac_down) ) 
       { myFrSignal=2;        }
     return(myFrSignal);
   }
int FUNAcSignal()
   { double AC1;
     int    myAcSignal;
     AC1=iAC(Symbol(),0,1);
     if(AC1>0)       {  myAcSignal=1;       }         
     if(AC1<0)       {  myAcSignal=2;       }
     return(myAcSignal);
   }
int FUNAoSignal()
   {  double AO1;
      int    myAoSignal;
      AO1=iAO(Symbol(),0,1);
      if(AO1>0)      {  myAoSignal=1;        }
      if(AO1<0)      {  myAoSignal=2;        }
      return(myAoSignal);
   }

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