20160321-1分钟智能测试交易系统

思想:做1分钟K线的欧元/美元货币对,遇大阴线做空,遇大阳线做多,只做后边一根k线。

问题分析:没有大问题,但是获利效率比较低。

代码:

extern double Lots = 0.1;
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.00015;
int opentime = 59;

int start()
{
//printf (MarketInfo(Currency,MODE_SPREAD));
if (TimeMinute(TimeCurrent()) > opentime && OrdersTotal()>0)
{
int total=OrdersTotal();
int cnt;
for(cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_SELL)
{
bool test1=OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
}
if(OrderType()==OP_BUY)
{
bool test2=OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
}
}
if (test1 == 1 || test2 ==1) opentime=59;
}
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);

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

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

}

}