Need Help again...

 

My EA didn't send Buy order and can't run on Demo, but backtesting is okay...

Why? Please help

Here is code

//+------------------------------------------------------------------+
//| MACDSingle order.mq4 |
//| Copyright ฉ 2010, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright ฉ 2010, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net//"

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
int ticket;
int total;
int TP=10,SL=10;
double macd;

macd=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
total=OrdersTotal();


//buyorder
if(total<1)
{
if(macd>0.0002)
{
ticket=OrderSend(Symbol(),OP_BUY,0.1,Bid,3,Ask-SL*Point,Ask+TP*Point,"MAC",0,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}

}

// sell OrderClose
if(total<1)
{
if(macd<-0.0002)
{
ticket=OrderSend(Symbol(),OP_SELL,0.1,Ask,3,Ask+SL*Point,Bid-TP*Point,"MAC",0,0,Blue);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
}


//----
return(0);
}
//+------------------------------------------------------------------+

 

L

You are buying at the Bid, selling at the Ask - should be other way round

If this is a subpip account, then TP, SL and Slippage are all too tight

-BB-