StopOrder turns into a MarketOrder ??

 

Hi, I use this code to send a limit order (for some unknown reason I have to use a stop order to get it to work as I expected a limit order would do, dunno why....). 

But the problem is that even though I've hardwired Type=4 it sends one stop order, and then one market order. Why?? It appares in Results like this:

-----------

1 2009.12.08 00:00 buy stop 1 0.33 1.48400 0.00000 0.00000 0.00 10000.00
2 2009.12.08 00:30 buy 1 0.33 1.48400 0.00000 0.00000 0.00 10000.00
3 2009.12.08 03:56 close at stop 1 0.33 1.48388 0.00000 0.00000 -3.96 9996.04
----------

Ticket = OpenOrder(OP_BUYSTOP, lots, Ask+0.001, 50, 50, 0, Blue);



//--------------------OpenOrder---------------------
int OpenOrder(int Type, double LotSize, double EntryPrice, int Stoploss, int Takeprofit, datetime Expiration, color Color) {
//Comment("Type: ",Dir);
   int LotDigits;
   int RetrySend = 10;//If order is rejected retry 100 times
   int ErrorCode = 0;
   int Ticket = 0;
   if (Type == OP_BUY || Dir == OP_BUYSTOP || Type == OP_BUYLIMIT)//Any Long type of orders
      {      
      double OrderSL = EntryPrice - Stoploss * OnePip;
      double OrderTP = EntryPrice + Takeprofit * OnePip;     
      }
      //
   if (Type == OP_SELL || Dir == OP_SELLSTOP || Type == OP_SELLLIMIT)//Any Short type of orders
      {
      //OrderSL = (Bid + SL * Point);//EntryPrice + Stoploss * OnePip;
      //OrderTP = (Ask + TP * Point);//EntryPrice - Takeprofit * OnePip;     
      }
   OrderSL = 0;//NormalizeDouble(OrderSL, Digits);
   OrderTP = 0;//NormalizeDouble(OrderTP, Digits);         
   for (int i = 0; i < RetrySend; i++)//Try to send the order:
      {
      Ticket = OrderSend(Symbol(), 4, LotSize, EntryPrice, Slippage * DigitMul, OrderSL, OrderTP, "", MagicNumber, Expiration, Color);
      //Comment("Type: ", Type,"   Price: ",EntryPrice,"   SL: ",OrderSL,"   TP: ",OrderTP);
      ErrorCode = GetLastError();
      if (ErrorCode == 0/* NO_ERROR */) break;
      if (!((ErrorCode == 4/* SERVER_BUSY */ || ErrorCode == 137/* BROKER_BUSY */ || ErrorCode == 146/* TRADE_CONTEXT_BUSY */ || ErrorCode == 136/* OFF_QUOTES */))) break;
      Sleep(1000);//Wait a little before next try
      }
      Comment("Type: ", Type,"   Price: ",EntryPrice,"   SL: ",OrderSL,"   TP: ",OrderTP);
   return (Ticket);
}
//--------------------------------------------------
 

As usual when I've posted a Q I find the A. Nothing wrong with the number/type of orders... Its only one BuyStop as it should be.

I am aware that there are other 'issues' with the code so no need to comment on that.

Reason: