simple ea but not working

 

can anybody tell me why this code doesnt work ? as i can see i followed all the rules to create an ea.

double   prerange2 = iHigh(Symbol(),PERIOD_M5,2) - iClose(Symbol(),PERIOD_M5,2);
double   prerange1 = iHigh(Symbol(),PERIOD_M5,1) - iClose(Symbol(),PERIOD_M5,1); 
double   currange = iHigh(Symbol(),PERIOD_M5,0) - iClose(Symbol(),PERIOD_M5,0);
double   prerangetotal = prerange2 + prerange1;
int cnt,total,ticket;
total = OrdersTotal();

   if(total < 1) 
     {
       if (currange > prerangetotal /* && iClose(Symbol(),PERIOD_M5,0)> iOpen(Symbol(),PERIOD_M5,0)*/) 
         {
            ticket=OrderSend(Symbol(),OP_BUY,lot,Bid,3,0,0);
            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);
         }
         return(0);
         }
 
ddock:

can anybody tell me why this code doesnt work ? as i can see i followed all the rules to create an ea.

Replace:

ticket=OrderSend(Symbol(),OP_BUY,lot,Bid,3,0,0);

To:

ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0);
Cheers
 

Replace:

ticket=OrderSend(Symbol(),OP_BUY,lot,Bid,3,0,0);

To:

ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0);
Cheers

if i replace bid to ask then there only 1 trade open for the last 3 years which is impossible, also if i didnt read it wrong bid is the price to buy and ask is the price to sell ?

 
ddock:

if i replace bid to ask then there only 1 trade open for the last 3 years which is impossible, also if i didnt read it wrong bid is the price to buy and ask is the price to sell ?

You can BUY at ASK price, and SELL at BID price.

I think that it is not a syntax problem if there is only 1 trade.

Reason: