下载MetaTrader 5
要添加评论,请登录注册
您想要学习MQL5吗?300篇文章将有助于您!
zgrxyuming
9
zgrxyuming 2009.04.13 13:38 

//+------------------------------------------------------------------+
//| ming.mq4 |
//| Copyright ?2009, Ming Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, Ming Software Corp."
#property link "http://www.metaquotes.net"

//---- input parameters
extern double lot;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double ma5,ma12;
int rs,x=0;
lot=NormalizeDouble(AccountFreeMargin()/20000.0,1);
if(lot<0.1)lot=0.1;
ma5=iMA(Symbol(),0,5,0,MODE_EMA,PRICE_CLOSE,0);
ma12=iMA(Symbol(),0,12,0,MODE_EMA,PRICE_CLOSE,0);
//----
if( ma5>ma12 )
{
x=1;
}
if(ma5<m12)
{
x=-1;
}

for(int i=0;i<OrdersTotal();i++)
{
rs=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol()==Symbol()
{
if( x=1)
{
if (OrderType()==OP_SELL)
OrderClose(i,OrderLots(),Ask,3,White);
}
if (x=-1)
{
if(OrderType()=OP_BUY)
OrderClose(i,OrderLots(),Bid,3,White);
}
}
}
if (OrdersTotal()<1)
{
if(x=1)OrderSend(Symbol(),OP_BUY,lot,Ask,3,Ask-20*Point,0,"",16384,0,Red);
if(x=-1)OrderSend(Symbol(),OP_SELL,lot,Bid,3,Bid+20*Point,0,"",16383,0,Green);
}
//

//----
return(0);
}
//+------------------------------------------------------------------+

cyberfox2002
26
cyberfox2002 2009.05.09 10:46  

错误比较多。都是小问题。

if(ma5<m12) m12在哪里?


if( x=1) 应该是==,还有几个地方是这种情况。

/
要添加评论,请登录注册