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

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

上一主题 下一主题
离线zwg121
 

发帖
5
金钱
18
威望
5
贡献
45
交易币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2010-12-12
SAG` ^t  
均线交叉513源码,求教 如何把慢线13设置成简单平均线(SMA)? A?IZ( Zx(`  
BnaU)E h  
513源码: xa{<R+LR  
//+----------------------------------------------------------------------------------------+ w~$c= JO#  
//|                                                EMA Cross                               | juCG?}di;  
//|                                                Clay - Copyright 2006                   |               fEj9R@u+h  
//| v 1.1 fixed emas                                                                       | S0N2rU  
//+----------------------------------------------------------------------------------------+ dgco*TIGO  
-OrY{^F  
     B0)`wsb_  
a IpPL8a  
//---- input parameters A,m4WO_q3  
extern double    StopLoss = 30; 1m>^{u  
extern double    TakeProfit = 1000; aJ :A%+1  
extern double    Lots = 0.1; y@o9~?M  
extern double    TrailingStop = 200; \}$*}gW[}  
ZjU=~)O}H  
extern int ShortEma = 5; ${hyNt  
extern int LongEma = 13;  r=fE8[,  
e7@li<3>d  
|}_gA  
//+------------------------------------------------------------------+ +w "XNl  
//| expert initialization function                                   | R{*_1cyW  
//+------------------------------------------------------------------+ KHvIN}V5?3  
int init() {bN Y  
  { z>6.[Z(T  
//---- %VzYqj_P"  
   !0`lu_ZN  
//---- I?^aCnU  
   return(0); LyIKP$t  
  } iBucT"d]  
//+------------------------------------------------------------------+ vyE{WkZxR  
//| expert deinitialization function                                 | Ddb-@YD&+0  
//+------------------------------------------------------------------+ {t&*>ma6)  
int deinit() Y.7}  
  { sMP:sCRC  
//---- n,CD  
   " CM ucK  
//---- ?IILt=)<  
   return(0); `%Q&</X  
  } 1eHe~p ,  
~cIl$b  
//+------------------------------------------------------------------+ z3W3=@  
//| expert start function                                            + Cc Y7$D  
//| This is where we initialize internal variables for program use   +                                   s9i|mVtm8  
//+------------------------------------------------------------------+ B$?^wo  
int start() {~_ Y _-  
  { &iBNO,v  
//---- DkdL#sV  
DZk1ZLz  
//LotCalc Declarations id?E)Jy  
   int cnt, ticket, total; ;&S;%W>|  
//MAs ?:uNN  
   double FEMAnow,FEMAprevious,FEMA2previous,SEMAnow,SEMAprevious,SEMA2previous; `*_CElpP"  
   Ee)xnY%(  
   4TZ cc|B5  
   if(Bars<100) v0LGdX)/Y  
     { 9 <\`nm  
      Print("bars less than 100"); Fe!9y2Mg  
      return(0);   BJy;-(JP  
     } U>Gg0`>  
   if(TakeProfit<10) f~ U.a.Fb  
     { #ekM"p  
      Print("TakeProfit less than 10"); DQ80B)<O  
      return(0);  // check TakeProfit AK@L32-S  
     } mYv(R!37'  
     {y-^~Q"z  
   //MA and Filter Variable Definition   .F2 :!h$  
   FEMAnow = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,0); $B .Qc!m  
   FEMAprevious = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1); T@ YGB]*Y  
   FEMA2previous = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,2); ~Xv=9@,h  
   SEMAnow = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_OPEN,0); 55DE\<r  
   SEMAprevious = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_OPEN,1); l#qv 5f  
   SEMA2previous = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_OPEN,2); I 3$dVls}  
   (6gK4__}]  
   int isCrossed  = 0; 0C$vS`s&  
     Jjm|9|C,  
    if (FEMAnow > SEMAnow && FEMAprevious > SEMAprevious && FEMA2previous < SEMAprevious) nt :N!suP3  
    {isCrossed = 1; h2q/mi5{  
    } [2c{k  
UQ?%|y*Kc  
    if (FEMAnow < SEMAnow && FEMAprevious < SEMAprevious && FEMAprevious > SEMAprevious) t ?eH'*>  
    {isCrossed = 2; 6g:|*w  
    } {S.>BXX  
^A_;#vK  
     zw@'vncc  
   //We check the trading terminal to see if it is empty X` YwP/D  
   total  = OrdersTotal(); $.E6S<(h  
   if(total < 1) //If trading terminal is empty... E /<lGm:.  
     { G;iEo4\?  
      if(isCrossed == 1) //if cross indicates LONG swing... ){;02^tX  
       LV{Q,DrP  
?}QH=&=^  
         { ^%T7.1'x  
            ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,2,Ask-StopLoss*Point,Ask+TakeProfit*Point,"EMa cross",12345,0,Yellow); kLSrj\6I[  
            if(ticket>0) mu]as: ~  
              { >h~IfZU1  
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); si4-3eC  
              } }ut]\]b  
            else Print("Error opening BUY order : ",GetLastError()); *~XA'Vw!  
            return(0); _o3e]{  
         } PyC0Q\$%  
        if(isCrossed == 2) //if cross indicates SHORT swing... jyS=!ydn+  
       <i?a0  
         { lJ;J~>  
.1 )RW5|c  
            ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,2,Bid+StopLoss*Point,Bid-TakeProfit*Point,"EMA cross",12345,0,Red); SUCU P<G  
            if(ticket>0) F t&+vS  
              { V)M1YZV{  
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());  ,*id'=S  
              } b}!3;:iD  
            else Print("Error opening SELL order : ",GetLastError()); >u +q1j.  
            return(0); or*HC&c7  
         } 9-1#( Y6S  
         return(0); i%Z2wP.o  
     } rZ1Hf11C  
   H!IshZfktn  
   //Position exit function... n| O [a6G  
   for(cnt=0;cnt<total;cnt++) \u OdALZ  
     { :\~+#/=:  
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); Y(VJbm`  
      OrderPrint(); ?kw&=T !  
      if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) gIEl.  
        { ,3DXFV'uxb  
         if(OrderType()==OP_BUY)   // long position is opened 7Du1RuxP  
           { f3*?MXxb16  
            // Check if we have a SHORT cross condition... C.  MoKa3  
           if(isCrossed == 2) oT95^y\9  
                { 36m5bYMd)  
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position ~q0*"\Ff  
                 return(0); // exit #b0{#^S:  
                } vm23U^VJ  
            // Check our trailing stop to see if it needs to be adjusted eBN)g^  
            if(TrailingStop>0)   1[nG}  
              {                 CE NVp"C/`  
               if(Bid-OrderOpenPrice()>Point*TrailingStop) or ;f&![w  
                 { <pLT'Y=  
                  if(OrderStopLoss()<Bid-Point*TrailingStop) U$&hZ_A  
                    { Q'apG)0I  
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); i?;r7>  
                     return(0); y k161\  
                    } L7Dh(y=;7  
                 } sE(HZR1  
              } PnT)LqEF  
           } Y[ reD  
         else // go to short position 7;`o( [N  
           { yWPIIWHx!  
            // Check if we have a LONG cross condition... % u{W7  
            if(isCrossed == 1) +y+"Fyl  
              { Y+%sBqo @  
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position N8cAqr  
               return(0); // exit G>qZxy`c  
              } G%p~m%zIK  
            // Check our trailing stop to see if it needs to be adjuste >r/rc`Q  
            if(TrailingStop>0)   +KGZ HO!  
              {                 _GQz!YA  
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) TjK{9A  
                 { B DY}*cX  
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) v;#=e$%}MO  
                    { 9&%fq)gS  
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); {MAQ/5  
                     return(0); ,''cNV  
                    } XALI<ZY  
                 } Z{IUy  
              } D*5hrkV9  
           } Mkp/0|Q*  
        } - N>MBn  
     } A \rt6/  
IJOvnZ("A  
   return(0); wo2@hav  
  } r90+,aLM#?  
//+------------------------------------------------------------------+
 
离线zwg121

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

  • 在线咨询
  • 400-881-0680