下载MetaTrader 5
要添加评论,请登录注册
阅读论坛并提高您的等级
摸金一族
9
摸金一族 2010.06.07 16:35 

extern double Lots = 1; #define MagicNumber 55555 extern double MATrendPeriod60=60; extern double MATrendPeriod240=240; extern int SlipPage = 3; int start() { double Ma60_15, Ma60_15ref,Ma240_15, Ma240_15ref; int cnt, ticket, total; Ma60_15=iMA(NULL,PERIOD_M15,MATrendPeriod60,0,MODE_SMA,PRICE_CLOSE,1); Ma60_15ref=iMA(NULL,PERIOD_M15,MATrendPeriod60,0,MODE_SMA,PRICE_CLOSE,2); Ma240_15=iMA(NULL,PERIOD_M15,MATrendPeriod240,0,MODE_SMA,PRICE_CLOSE,1); Ma240_15ref=iMA(NULL,PERIOD_M15,MATrendPeriod240,0,MODE_SMA,PRICE_CLOSE,2); total=OrdersTotal(); if(total Ma240_15 &&Ma60_15>Ma60_15ref &&Close[1]>Ma60_15) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,SlipPage,0,0,"My auto buy order ",MagicNumber,0,0); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); return(0); } if(Close[1] Ma60_15 &&Close[1] 0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); return(0); } return(0); } for(cnt=0;cnt Ma60_15 &&Ma60_15>Ma60_15ref) { OrderClose(OrderTicket(),OrderLots(),Ask,SlipPage,0); return(0); } } } }

这个EA测试结果只开多单不开空单,开仓点位也不太对,期待高手修改;谢谢
摸金一族
9
摸金一族 2010.06.07 16:36  


extern double Lots = 1;
#define MagicNumber 55555

extern double MATrendPeriod60=60;
extern double MATrendPeriod240=240;
extern int SlipPage = 3;

int start()
{
double Ma60_15, Ma60_15ref,Ma240_15, Ma240_15ref;

int cnt, ticket, total;


Ma60_15=iMA(NULL,PERIOD_M15,MATrendPeriod60,0,MODE_SMA,PRICE_CLOSE,1);
Ma60_15ref=iMA(NULL,PERIOD_M15,MATrendPeriod60,0,MODE_SMA,PRICE_CLOSE,2);
Ma240_15=iMA(NULL,PERIOD_M15,MATrendPeriod240,0,MODE_SMA,PRICE_CLOSE,1);
Ma240_15ref=iMA(NULL,PERIOD_M15,MATrendPeriod240,0,MODE_SMA,PRICE_CLOSE,2);

total=OrdersTotal();
if(total<1)
{
if(Close[1]>Ma240_15 && Ma60_15>Ma60_15ref && Close[1]>Ma60_15)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,SlipPage,0,0,"My auto buy order ",MagicNumber,0,0);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}

if(Close[1]<Ma240_15 && Ma60_15ref>Ma60_15 && Close[1]<Ma60_15)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,SlipPage,0,0,MagicNumber,0,0);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if(Close[1]<Ma60_15 && Ma60_15<Ma60_15ref)
{
OrderClose(OrderTicket(),OrderLots(),Bid,SlipPage,0);
return(0);
}
}
}
else
{
if(Close[1]>Ma60_15 && Ma60_15>Ma60_15ref)
{
OrderClose(OrderTicket(),OrderLots(),Ask,SlipPage,0);
return(0);
}
}
}
}

摸金一族
9
摸金一族 2010.06.08 05:38  
q100200:


extern double Lots = 1;
#define MagicNumber 55555

extern double MATrendPeriod60=60;
extern double MATrendPeriod240=240;
extern int SlipPage = 3;

int start()
{
double Ma60_15, Ma60_15ref,Ma240_15, Ma240_15ref;

int cnt, ticket, total;


Ma60_15=iMA(NULL,PERIOD_M15,MATrendPeriod60,0,MODE_SMA,PRICE_CLOSE,1);
Ma60_15ref=iMA(NULL,PERIOD_M15,MATrendPeriod60,0,MODE_SMA,PRICE_CLOSE,2);
Ma240_15=iMA(NULL,PERIOD_M15,MATrendPeriod240,0,MODE_SMA,PRICE_CLOSE,1);
Ma240_15ref=iMA(NULL,PERIOD_M15,MATrendPeriod240,0,MODE_SMA,PRICE_CLOSE,2);

total=OrdersTotal();
if(total<1)
{
if(Close[1]>Ma240_15 && Ma60_15>Ma60_15ref && Close[1]>Ma60_15)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,SlipPage,0,0,"My auto buy order ",MagicNumber,0,0);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}

if(Close[1]<Ma240_15 && Ma60_15ref>Ma60_15 && Close[1]<Ma60_15)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,SlipPage,0,0,MagicNumber,0,0);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if(Close[1]<Ma60_15 && Ma60_15<Ma60_15ref)
{
OrderClose(OrderTicket(),OrderLots(),Bid,SlipPage,0);
return(0);
}
}
}
else
{
if(Close[1]>Ma60_15 && Ma60_15>Ma60_15ref)
{
OrderClose(OrderTicket(),OrderLots(),Ask,SlipPage,0);
return(0);
}
}
}
}


顶起来等好心人帮忙
/
要添加评论,请登录注册