void OnTick()
{
double ma = iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0);
if (Bid > ma) {
int ticket = OrderSend(NULL,OP_BUY,0.1,Ask,3,Ask-50*Point,Ask+50*Point,"My order",0,0,Green);
if (ticket > 0) {
Print("Order opened, ticket = ",ticket);
} else {
Print("Failed to open order, error code = ",GetLastError());
}
} else if (Bid < ma) {
int ticket = OrderSend(NULL,OP_SELL,0.1,Bid,3,Bid+50*Point,Bid-50*Point,"My order",0,0,Red);
if (ticket > 0) {
Print("Order opened, ticket = ",ticket);
} else {
Print("Failed to open order, error code = ",GetLastError());
}
}
}
把里面的ima换成调用自定义指标 |