下载MetaTrader 5
要添加评论,请登录注册
使用口袋粘贴您的内容。非常方便!
wangjh2004
40
wangjh2004 2007.05.30 11:09 

extern int MagicNumber=123456;

extern int K1 = 19;
extern int D1 = 7;
extern int S1 = 9;
extern double a = 30;

extern int TakeProfit = 10;

extern double Lots = 0.1;
extern int maxopen = 5;
extern int maxlots = 20;

int myBars;
double k0, d0, k1, d1;
string text="EA10#, M1";
//=============================================================================================================
int start()
{
k0 =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_MAIN,1);
d0 =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_SIGNAL, 1);
k1 =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_MAIN,2);
d1 =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_SIGNAL, 2);
//==================================================================================================
int res =0;
int buyNumber =0;
int sellNumber=0;
for (int i=OrdersTotal()-1;i>=0;i--)
{
if (MagicNumber==0 || (OrderMagicNumber()==MagicNumber && MagicNumber!=0))
{
switch(OrderType())
{
case OP_BUY: buyNumber++;break;
case OP_SELL: sellNumber++;break;
}
}
}
res=buyNumber-sellNumber || sellNumber-buyNumber;
return(res);

//==================================================================================================
if(Bars!=myBars)
{
myBars=Bars;
if( res>maxopen && OrdersTotal()>maxlots) return(0);

if( k1<a && d1<a && k1<d1 && k0>d0 )
{ OrderSend(Symbol(), OP_BUY, Lots,Ask, 3, 0,Ask+TakeProfit*Point, text,2006, 3, Red);
PlaySound("alert. wav");
}

if( k1>100-a && d1>100-a && k1>d1 && k0<d0 )
{ OrderSend(Symbol(), OP_SELL, Lots, Bid,3, 0,Bid-TakeProfit*Point, text, 2006, 3,Blue);
PlaySound("alert. wav");
}
return(0);
}
}

Rashid Umarov
管理员
6598
Rashid Umarov 2007.05.30 11:36  
Please, use MQL4 button.
extern int MagicNumber=123456;
 
extern int       K1        = 19;
extern int       D1        = 7;
extern int       S1        = 9;
extern double    a         = 30;
 
extern int   TakeProfit    = 10;
 
extern double  Lots        = 0.1;
extern int    maxopen      = 5;
extern int    maxlots      = 20;
 
int myBars;
double k0, d0, k1, d1;
string text="EA10#, M1";
//============================================================================================================= 
int start()  
{
   k0   =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_MAIN,1);
   d0   =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_SIGNAL,1);
   k1   =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_MAIN,2);
   d1   =iStochastic(NULL,0,K1,D1,S1,MODE_SMA,0,MODE_SIGNAL,2);
//==================================================================================================
int res =0;
int buyNumber =0;
int sellNumber=0;
   for (int i=OrdersTotal()-1;i>=0;i--)
         {
         if (MagicNumber==0 || (OrderMagicNumber()==MagicNumber && MagicNumber!=0))
             {
               switch(OrderType())
                {
                 case OP_BUY: buyNumber++;break;
                 case OP_SELL: sellNumber++;break;
                }
             }
         }
   res=buyNumber-sellNumber || sellNumber-buyNumber;
   return(res);
 
//==================================================================================================
   if(Bars!=myBars)
      {
      myBars=Bars;
      if(  res>maxopen &&  OrdersTotal()>maxlots) return(0);
     
      if(  k1<a && d1<a && k1<d1 && k0>d0  )
            {  OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,text,2006,3,Red);
               PlaySound("alert.wav");
            }
 
      if(  k1>100-a && d1>100-a && k1>d1 && k0<d0   )
            {  OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,text,2006,3,Blue);
               PlaySound("alert.wav");
            }
      return(0);
      }
}
Rashid Umarov
管理员
6598
Rashid Umarov 2007.05.30 11:44  
Use
res=MathAbs(buyNumber-sellNumber);
See https://docs.mql4.com/cn/math/MathAbs
/
要添加评论,请登录注册