下载MetaTrader 5
要添加评论,请登录注册
理解代码有困难?文章 会帮助您!
yingweijiang
10
yingweijiang 2012.02.25 14:05 

请EA编写高手帮看下问题出在哪?

测试不了,也加载不了. 且我改写过的策略都显示成灰色(如图)

本人做股指期货自动交易的,用的是文华平台,有好的策略,现在做MT4,但不懂MQL语言,\

寻求EA编写高手

//+------------------------------------------------------------------+
//| TTT.mq4 |
//| yingweijiang |
//| 20012-02-24 |
//+------------------------------------------------------------------+
#property copyright "yingweijiang"
#property link "20012-02-24"

//---- input parameters
extern int MovingPeriod=20;
extern int MovingShift=0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
SetComment("MA_Miror");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+

int Signal(int oldSignal)
{
return (SignalMA(oldSignal));
}

int SignalMA(int oldSignal)
{

int i=1;
int signal = oldSignal;
double ma1, ma2;
ma1=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,i)-iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_OPEN,i);
ma2=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_OPEN,i)-iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,i);

if (ma1 > ma2) signal = OP_BUY;
if (ma1 < ma2) signal = OP_SELL;

return (signal);
}

int SignalRandom(int oldSignal)
{
int signal = oldSignal;
if (GetNumTickets() == 0)
{
int rnd = MathRand();
if (rnd > 16358)
signal = OP_BUY;
else
signal = OP_SELL;
}
return (signal);
}

int start()
{
//----

int signal,oldSignal;

oldSignal = -1;
FindOrders(true);
if (GetNumTickets() != 0)
{

oldSignal = GetCommand(0);
}
else
oldSignal = 1;

signal = Signal(oldSignal);

if (signal != oldSignal)
{
if (GetNumTickets() != 0)
CloseOrder(GetTicket(0));
if (signal == OP_BUY)
Buy(GetLots());
if (signal == OP_SELL)
Sell(GetLots());

}


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

JUN HU
209
JUN HU 2012.03.20 12:51  
QQ249974322我可以帮你编写
laokevin
5
laokevin 2012.03.25 02:05  

我也做股指期货的自动交易,也是基于文华平台,但是不是用平台本身的自动交易,更加稳定,EA编写也可以找我

qq:1030341013

laokevin
5
laokevin 2012.03.25 02:08  

我也做股指期货的自动交易,也是基于文华平台,但是不是用平台本身的自动交易,更加稳定,EA编写也可以找我

qq:1030341013

laokevin
5
laokevin 2012.03.25 02:08  

我也做股指期货的自动交易,也是基于文华平台,但是不是用平台本身的自动交易,更加稳定,EA编写也可以找我

qq:1030341013

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