//+------------------------------------------------------------------+
//| test aaa.mq4 |
//| Copyright ฉ 2010, MetaQuotes Software Corp. |
//|
http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ฉ 2010, MetaQuotes Software Corp."
#property link "
http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double ma1,ma2,pod;
int total,ticket;
total=OrdersTotal();
pod=OrderOpenPrice();
ma1 = iMA(NULL,0,14,1,MODE_EMA,PRICE_CLOSE,0);
ma2 = iMA(NULL,0,14,2,MODE_EMA,PRICE_CLOSE,0);
if (total < 1) {
if (ma1>ma2) {
ticket = OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"test",0,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
if (Ask < ma2) {
OrderClose(ticket,0.01,Ask,3,Orange);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
ปัญหาคือมันไม่ยอมทำตามเงื่อนไขอะครับ คือ ปิด order เมื่อ ask ต่ำกว่า ma2