论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:1688回复:3
草龙
注册时间2004-12-17
[MT4-EA]2EMA的EA系统 system
楼主发表于:2014-01-03 07:23只看该作者倒序浏览
1楼 电梯直达
电梯直达
双EMA均线的EA系统 拿去做下研究
//+------------------------------------------------------------------+
//|                                              2EMA system-v03.mq4 |
//|                                                     Gerry Sutton |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Greybeard_xlx - Conversion of MQL-II"
#property link      "http://groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/"
//+------------------------------------------------------------------+
//|  External Variables                                              |
//+------------------------------------------------------------------+
extern double mm = -1;
extern double lp = 300;
extern double sp = 30;	 
extern double slip = 5;
extern double Risk = 40;
extern double Lots = 1.0;
extern double TakeProfit = 360;
extern double Stoploss = 50;
extern double TrailingStop = 15;	
double Points;
//----

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init ()
  {
   Points = MarketInfo (Symbol(), MODE_POINT);
//----
   return(0);
  }
//+------------------------------------------------------------------+ 
   if(Bars<301)
     {
      Print("Not enough Bars");
      return(0);  
     }
   if(TakeProfit<10)
     {
      Print("TakeProfit less than 10");
      return(0);  
     }
//+------------------------------------------------------------------+
//| Setting internal variables for quick access to data              |
//+------------------------------------------------------------------+
int start()
  {
   double b=0; 
   double balance=0;
   double Ilo=0;
   
   balance=AccountBalance();
   b=(5*Points+iATR(NULL,0,4,1)*5.5);

//+------------------------------------------------------------------+
//| Money Management mm=0(lots) mm=-1(Mini) mm=1(full compounding)   |
//+------------------------------------------------------------------+   
   
   if (mm < 0) {
   Ilo = MathCeil(balance*Risk/10000)/10;
        if (Ilo > 100)  {		
        Ilo = 100;		
        }
   } else {
   Ilo = Lots;
   };
   if (mm > 0)
    {
   Ilo = MathCeil(balance*Risk/10000)/10;
    if (Ilo > 1) 
    {
    Ilo = MathCeil(Ilo);
    }
    if (Ilo < 1)
    {
    Ilo = 1;
    }
    if (Ilo > 100) 
    {		
        Ilo = 100;		
        }
};

//----
Comment("   Account  :   ",AccountNumber(),"---",AccountName(), 
"\n","   StopLoss   :   ",b,
"\n","   Lots  :   ",Ilo,);
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   if(OrdersTotal()<1) 
   {
   if(AccountFreeMargin()<(100*Lots))
        {
         Print("We have no money");
         return(0); 
         }
   
   if((iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,3)<
      iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,3)*0.998 &&
         iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,0)>
         iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,0)*0.998)&&
         iSAR(NULL,0,0.02,0.2,6)Open[0]) 	 
        {
         OrderSend(
         OP_SELL,
         Ilo,
         Bid,
         slip,
         Bid+Stoploss*Points,
         Bid-TakeProfit*Points,
         0,0,
         HotPink); 
         if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
         return(0);
      }   
   if((iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,3)>
      iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,3)*1.002 &&
      iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,0)<
      iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,0)*1.002) && 
      iSAR(NULL,0,0.02,0.2,6)>Open[6] && 
      iSAR(NULL,0,0.02,0.2,0)OrderStopLoss()&&
            (Bid-OrderOpenPrice()>(Bid-OrderOpenPrice()*0.004)) &&
             iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,3)<
             iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,3)*0.998 &&
             iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,0)>
             iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,0)*0.9978)
                {
                 OrderClose(
                 OrderTicket(),
                 OrderLots(),
                 Bid,
                 slip,
                 Red); 
                 return(0);
              };
            if(TrailingStop>0) 
              {                
               if(Bid-OrderOpenPrice()>b)
                 {
                  if(OrderStopLoss()(OrderOpenPrice()*0.004)) &&
             iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,3)>
             iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,3)*0.998 &&
             iMA(NULL,0,lp,0,MODE_SMA,PRICE_CLOSE,0)<
             iMA(NULL,0,sp,0,MODE_EMA,PRICE_CLOSE,0)*0.9978)
                {
               OrderClose(
               OrderTicket(),
               OrderLots(),
               Ask,
               slip,
               Red); 
               return(0); 
              }
            
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(b))
                 {
                  if(OrderStopLoss()==0.0 || 
                     OrderStopLoss()>(Ask+b))
                    {
                     OrderModify(
                     OrderTicket(),
                     OrderOpenPrice(),
                     Ask+b,OrderTakeProfit(),
                     0,
                     HotPink);
                     return(0);
                    }
                 }
              }
           }
        }
      }
   return(0);
  // }
   
  
 

TK29帖子1楼右侧xm竖版广告90-240
个性签名

阅尽天下指标
搬砖开始,始于2014

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
PANLV
注册时间2018-02-19
发表于:2018-07-11 13:50只看该作者
2楼
//compile// //+------------------------------------------------------------------+ //| EMA_58_Crossover_Alert.mq4 | //| Copyright 2006, Robert Hill | //| | //| Written Robert Hill for use with AIME for the EMA 5/8 cross to | //| draw arrows and popup alert or send email | //+------------------------------------------------------------------+ #property copyright "Copyright 2006, Robert Hill" #property indicator_chart_window #property indicator_buffers 5 #property indicator_color1 LawnGreen #property indicator_color2 Red #property indicator_color3 Red #property indicator_color4 Aqua #property indicator_color5 Yellow #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 #property indicator_width5 2 extern bool SoundON=true; extern bool EmailON=false; double CrossUp; double CrossDown; double Ema5; double Ema8; double Ema20; int flagval1 = 0; int flagval2 = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY); SetIndexArrow(0, 233); SetIndexBuffer(0, CrossUp); SetIndexStyle(1, DRAW_ARROW, EMPTY); SetIndexArrow(1, 234); SetIndexBuffer(1, CrossDown); SetIndexStyle(2, DRAW_LINE, STYLE_SOLID); SetIndexBuffer(2, Ema5); SetIndexStyle(3, DRAW_LINE, STYLE_SOLID); SetIndexBuffer(3, Ema8); SetIndexStyle(4, DRAW_LINE, STYLE_SOLID); SetIndexBuffer(4, Ema20); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double tmp=0; double fastMAnow, slowMAnow, fastMAprevious, slowMAprevious; double Range, AvgRange; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i = 1; i <= limit; i++) { counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; fastMAnow = iMA(NULL, 0, 5, -1, MODE_EMA, PRICE_CLOSE, i); fastMAprevious = iMA(NULL, 0, 5, -1, MODE_EMA, PRICE_CLOSE, i+1); slowMAnow = iMA(NULL, 0, 8, 0, MODE_EMA, PRICE_OPEN, i); slowMAprevious = iMA(NULL, 0, 8, 0, MODE_EMA, PRICE_OPEN, i+1); Ema20 = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, i); Ema5 = fastMAnow; Ema8 = slowMAnow; CrossUp = 0; CrossDown = 0; if ((fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious)) { if (i == 1 && flagval1==0) { flagval1=1; flagval2=0; if (SoundON) Alert("BUY signal at Ask=",Ask,"\\n Bid=",Bid,"\\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\\n Symbol=",Symbol()," Period=",Period()); if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); } CrossUp = Low - Range*0.75; } else if ((fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious)) { if (i == 1 && flagval2==0) { flagval2=1; flagval1=0; if (SoundON) Alert("SELL signal at Ask=",Ask,"\\n Bid=",Bid,"\\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\\n Symbol=",Symbol()," Period=",Period()); if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); } CrossDown = High + Range*0.75; } } return(0); }
zhapeng
注册时间2020-12-12
Juns
注册时间2020-06-03
发表于:2021-04-01 09:26只看该作者
4楼
感谢分享
个性签名

韬客社区www.talkfx.co

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]