论坛风格切换切换到宽版
  • 1927阅读
  • 1回复

均线交叉513源码 修改问题 [复制链接]

上一主题 下一主题
离线zwg121
 

发帖
5
金钱
18
威望
5
贡献
45
交易币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2010-12-12
kO\aNtK  
均线交叉513源码,求教 如何把慢线13设置成简单平均线(SMA)? nz]+G2 h  
|P]>[}mD  
513源码: F\;G'dm  
//+----------------------------------------------------------------------------------------+ WY%'ps _]<  
//|                                                EMA Cross                               | mMvt#+O  
//|                                                Clay - Copyright 2006                   |               w+~s}ta2^  
//| v 1.1 fixed emas                                                                       | .5zqpm  
//+----------------------------------------------------------------------------------------+ N?h=Zl|  
y-93 >Y  
     /K"koV;  
@<tkwu  
//---- input parameters MGd 7Ont  
extern double    StopLoss = 30; ^6 F-H(  
extern double    TakeProfit = 1000; ;5A  
extern double    Lots = 0.1; 8M;VX3X  
extern double    TrailingStop = 200; {(i>$RG_  
WUSkN;idVG  
extern int ShortEma = 5; NuKktQd  
extern int LongEma = 13; n5X0Gi9  
-ckk2D?  
Q<.84 7 )  
//+------------------------------------------------------------------+ BD+V{x}P  
//| expert initialization function                                   | >L F y:a  
//+------------------------------------------------------------------+ p.kJNPO\@  
int init() 8{ aS$V"  
  { =l?F_  
//---- 4viP lO  
   dYdZt<6W<(  
//---- 4<b=;8  
   return(0); =~M%zdIXv  
  } $xRZU9+  
//+------------------------------------------------------------------+ YY~BNQn6d  
//| expert deinitialization function                                 | d4OWnPHv&}  
//+------------------------------------------------------------------+ FV>j !>Y  
int deinit() P70\ |M0~y  
  { KUs\7Sb  
//---- kkfwICBI  
   gG;d+s1  
//---- Z]-C,8MM  
   return(0); uMW5F-~-+  
  } mQ#E{{:H+  
Of| e]GR  
//+------------------------------------------------------------------+ XAN{uD^3\%  
//| expert start function                                            + 0:K4,  
//| This is where we initialize internal variables for program use   +                                   6*@\Qsp615  
//+------------------------------------------------------------------+ w3j51v` 0'  
int start() VKa-  
  { ~i)O^CKq  
//---- D}Jhg`9  
*|c*/7]<  
//LotCalc Declarations >-0b@ +j  
   int cnt, ticket, total; 5[WhjTo  
//MAs &JoMrcEZ  
   double FEMAnow,FEMAprevious,FEMA2previous,SEMAnow,SEMAprevious,SEMA2previous; amI$0  
   1m-"v:fT5D  
   !=#230Y  
   if(Bars<100) [P*3ld,,G%  
     { NEQcEUd?  
      Print("bars less than 100"); ~Z5?\a2Ld  
      return(0);   3mn0  
     } N}\Da: _  
   if(TakeProfit<10) ,eRl Z3T  
     { )61CrQiY  
      Print("TakeProfit less than 10"); 1W;3pN  
      return(0);  // check TakeProfit ^ j@Q2>&?  
     } h~elF1dG  
     vnz.81OR  
   //MA and Filter Variable Definition   8{Y ?;~G  
   FEMAnow = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,0); p'k stiB  
   FEMAprevious = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1); uYL6g:]+ZC  
   FEMA2previous = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2); L5yxaF{]  
   SEMAnow = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_OPEN,0); ,-CDF)~G=3  
   SEMAprevious = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_OPEN,1); = k3O4gE7  
   SEMA2previous = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_OPEN,2); V-=$:J"J'\  
   o9wg<LP  
   int isCrossed  = 0; p w>A Q  
     `8FC&%X_  
    if (FEMAnow > SEMAnow && FEMAprevious > SEMAprevious && FEMA2previous < SEMAprevious) [=U7V;5($  
    {isCrossed = 1; tEN]0`  
    } Y sr{1!K  
tB_V%qH  
    if (FEMAnow < SEMAnow && FEMAprevious < SEMAprevious && FEMAprevious > SEMAprevious) 0[v:^H  
    {isCrossed = 2; {t=Nnc15K  
    } e-e{-pB6  
y5Pw*?kn  
     tjd"05"@:  
   //We check the trading terminal to see if it is empty rqF PUp  
   total  = OrdersTotal(); %eV`};9  
   if(total < 1) //If trading terminal is empty... ^m+W  
     { l?R_wu,Q  
      if(isCrossed == 1) //if cross indicates LONG swing... ky~x4_y5  
       U3V<ITZI8t  
<Z__Q  
         { K%gFD?{^q  
            ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,2,Ask-StopLoss*Point,Ask+TakeProfit*Point,"EMa cross",12345,0,Yellow); q@sH@-z4]  
            if(ticket>0)  \1MDCP9:  
              { [T%blaSX  
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); C\; 8l}t  
              } 64vSJx>u  
            else Print("Error opening BUY order : ",GetLastError()); KCT8Q!\  
            return(0); :A'!u r=\  
         } o{he) r6)_  
        if(isCrossed == 2) //if cross indicates SHORT swing... aOHCr>po,  
       oB\Xl)A<  
         { TUaK:*x*  
t0>{0 5  
            ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,2,Bid+StopLoss*Point,Bid-TakeProfit*Point,"EMA cross",12345,0,Red); ' XF`&3 i  
            if(ticket>0) wuzz%9;@B  
              { !Ia"pNDf  
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); )sf~l6  
              } 8zC k9&  
            else Print("Error opening SELL order : ",GetLastError()); mx9/K+:  
            return(0); `t1$Ew<  
         } Qs9U&*L  
         return(0); pq3  A%|  
     } F2$bUY  
   s[q4K  
   //Position exit function... E`fssd~  
   for(cnt=0;cnt<total;cnt++) aNC,ccm  
     { 3DAGW"F  
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); *ZR@ z80i  
      OrderPrint(); Om2X>/V%C  
      if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) bmVgTm&  
        { 1m`tqlFU9  
         if(OrderType()==OP_BUY)   // long position is opened A>t!/_"  
           { H='9zqYZ<W  
            // Check if we have a SHORT cross condition... ,(0XsBL  
           if(isCrossed == 2) '<D`:srV  
                { mu6xL QdA  
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position gLaO#cQ%  
                 return(0); // exit S`c]Fc  
                } (Cl`+ V  
            // Check our trailing stop to see if it needs to be adjusted ]PzTl {]  
            if(TrailingStop>0)   )YnI !v2T  
              {                 K_&c5(-(_  
               if(Bid-OrderOpenPrice()>Point*TrailingStop) 38U5^`  
                 { [)H,zpl  
                  if(OrderStopLoss()<Bid-Point*TrailingStop) y/@;c)1b9  
                    { r%TLv  
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); AU\xNF3  
                     return(0); ~Q_)>|R2  
                    } ) ]/i  
                 } ^ J#?hHz  
              } A;fB6  
           } jU]]:S4xD/  
         else // go to short position @tr&R==([  
           { 4i_spF-3  
            // Check if we have a LONG cross condition... }g>dn  
            if(isCrossed == 1) Bmx(qE  
              { !dfS|BA]  
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position g(-;_j!=  
               return(0); // exit =oo[ Eyr  
              } &u+yM D  
            // Check our trailing stop to see if it needs to be adjuste E|HSwTHe  
            if(TrailingStop>0)   8O~0RYk  
              {                 zWy ,Om8P  
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) lbQ6 a  
                 { 8 ne/=N|,  
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) S-isL4D.Z  
                    { LMAmpVo  
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); qOW#Q:T  
                     return(0); uc'p]WhQ  
                    } 24/ /21m  
                 } *~c qr  
              } G@9u:\[l  
           } xZX`%f-  
        } @|BD|{k  
     } ?{eY\I  
S`=n&'  
   return(0); |=O1Hn  
  } J_PH7Z*=,  
//+------------------------------------------------------------------+
 
离线zwg121

发帖
5
金钱
18
威望
5
贡献
45
交易币
0
只看该作者 沙发  发表于: 2010-12-12
求一个EA, HCj> ,^<h  
EMA指数均线交叉SMA简单平均线开仓,设止盈止损,开仓手数。
 

  • 在线咨询
  • 400-881-0680