20160321-1分钟连续更新止损

思想:货币对为欧元/美元,根据一分钟K线的柱体长短来作为开仓的条件,遇大阴线做空,遇大阳线做多。附加了邮件监控EA有效性。

问题分析:模拟测试中,盈利不错,但是在实战中却连续亏损。包括实战中亏损了,回过头来再进行同一时间段的模拟测试,却又盈利了,可能是存在滑点问题。

代码:

extern double Lots = 0.2;
extern string Currency = "EURUSDpro";
extern int period = PERIOD_M1;
extern double gaodu_max = 0.0002;
extern double chajia_max = 0.00097;
extern double weiyi = 0.00005;
bool email_switch=0;
int start()
{
//printf (MarketInfo(Currency,MODE_SPREAD));
double HIGH = iHigh(Currency, period, 1);
double LOW = iLow(Currency, period, 1);
double CLOSE = iClose(Currency, period, 1);
double OPEN = iOpen(Currency, period, 1);
double gaodu = MathAbs(CLOSE - OPEN);
double chajia = MathAbs(HIGH - LOW);
int cnt, total;

if (OrdersTotal()>0 && CLOSE>OPEN && iLow(Currency, period, 0)>LOW)
{

total=OrdersTotal();
for(cnt=total-1;cnt>=0;cnt--)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{
OrderModify(OrderTicket(),OrderOpenPrice(),iLow(Currency, period, 0)+weiyi,0,0);
}
}
}
if (OrdersTotal()>0 && CLOSE<OPEN && iHigh(Currency, period, 0)<HIGH)

{
total=OrdersTotal();
for(cnt=total-1;cnt>=0;cnt--)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{
OrderModify(OrderTicket(),OrderOpenPrice(),iHigh(Currency, period, 0)-weiyi,0,0);
}

}

}
if (gaodu > gaodu_max && chajia >chajia_max && OrdersTotal()==0)
{
if (CLOSE>OPEN && MarketInfo(Currency,MODE_BID)>HIGH)
{
OrderSend(Currency,OP_BUY,Lots,Ask,3,OPEN+weiyi,0,NULL,0,0,Red);
}

else if (CLOSE<OPEN && MarketInfo(Currency,MODE_ASK)<LOW)
{
OrderSend(Currency,OP_SELL,Lots,Bid,3,OPEN-weiyi,0,NULL,0,0,Red);
}

}

if (email_switch==0 && TimeMinute(TimeCurrent())<30)
{
//SendMail("I am alive", "主人,我运行正常!");
email_switch=1;
}

if (email_switch==1 && TimeMinute(TimeCurrent())>30) email_switch=0;

}