if (OrderType()==OP_BUY) OrderClose(Ti,OrderLots(),Bid,3,Red);
上句中Bid改成Ask
if (OrderType()==OP_SELL) OrderClose(Ti,OrderLots(),Ask,3,Green);
上句中Ask改成Bid
if (OrderType()==OP_BUY) OrderClose(Ti,OrderLots(),Bid,3,Red);
上句中Bid改成Ask
if (OrderType()==OP_SELL) OrderClose(Ti,OrderLots(),Ask,3,Green);
上句中Ask改成Bid
#property copyright "lf"
#property link ""
extern int MA1 = 3;
extern int MA2 = 21;
extern int i;
extern int Ti;
int init()
{
i=0;
return;
}
int start()
{
if (iMA(NULL,0,MA1,0,3,5,0)<iMA(NULL,0,MA2,0,3,5,0)) open_sell();
if (iMA(NULL,0,MA1,0,3,5,0)>iMA(NULL,0,MA2,0,3,5,0)) open_buy();
return;
}
int open_sell()
{
if (OrdersTotal()==0) OrderSend(Symbol(),1,0.01,Bid,3,0,0,"",0,0,Yellow);
if (OrdersTotal()!=0)
for (i=1;i==OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
Ti=OrderTicket();
if (OrderType()==OP_BUY) OrderClose(Ti,OrderLots(),Bid,3,Red);
// OrderSend(Symbol(),1,0.01,Bid,3,0,0,"",0,0,Yellow);
}
return;
}
int open_buy()
{
if (OrdersTotal()==0) OrderSend(Symbol(),0,0.01,Ask,3,0,0,"",0,0,Blue);
if (OrdersTotal()!=0)
for (i=1;i==OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
Ti=OrderTicket();
if (OrderType()==OP_SELL) OrderClose(Ti,OrderLots(),Ask,3,Green);
// OrderSend(Symbol(),0,0.01,Ask,3,0,0,"",0,0,Blue);
}
return;
}
//+------------------------------------------------------------------+