理念:赔小钱挣大钱
方法:3日线上穿26日线买入,26日线上穿3日线平仓;26日线上穿3日线买入,3日线上穿26日线平仓
如图:
#property copyright "Copyright 2013, MetaQuotes
Software Corp."
int ticket;
double cw=0.1;
int m=0,n=0;
double Ma3, Ma26;
//+---------------------------------------------
---------------------+
//| expert initialization function |
//+---------------------------------------------
---------------------+
int init()
{
//----
//----
return(0);
}
//+---------------------------------------------
---------------------+
//| expert deinitialization function |
//+---------------------------------------------
---------------------+
int deinit()
{
//----
//----
return(0);
}
//+---------------------------------------------
---------------------+
//| expert start function |
//+---------------------------------------------
---------------------+
int start()
{
int i=0;
int j=0;
//----
Ma3=iMA(NULL,0,3,0,MODE_SMA,PRICE_CLOSE,0);
Ma26=iMA(NULL,0,26,0,MODE_SMA,PRICE_CLOSE,0);
if(Ma3>Ma26)
{
i=i+1;
}
else
i=0;
if(Ma3i)
{
pc();
OrderSend(Symbol(),OP_SELL,cw,Bid,3,0*Point,0,"lbs-buy",197658,0,Green);
m=0;
Sleep(100000);
}
if(n>j)
{
pc();
OrderSend(Symbol(),OP_BUY,cw,Ask,3,0*Point,0,"lbs-buy",197658,0,Red);
n=0;
Sleep(100000);
}
//+---------------------------------------------
---------------------+
m=i+0;
n=j+0;
//----
return(m);
return(n);
}
//+---------------------------------------------
---------------------+
void pc()
{
while(OrdersTotal()!=0)
{
int total=OrdersTotal();
for(int i=0;i<total;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots
(),Bid,30,Blue);
}
if(OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots
(),Ask,30,Blue);
}
if((OrderType()==OP_BUYLIMIT)||(OrderType()==OP_BUYSTOP)||(OrderType()==OP_SELLLIMIT)||(OrderType()==OP_SELLSTOP))
{
OrderDelete(OrderTicket());
}
}
}
}
}
结果:在同一根K线上多次买卖。加了Sleep(100000)也不管
问题:同一根K线上交易一次
|