How to differentiate an Open Market Order and a Pending Order?

 

How to differentiate an Open Market Order and a Pending Order? Here I have tried a test code. I'm placing orders using code and checking some parameters. Please tell me which parameter should be checked whether the order is open or pending.

//////////Placing a Pending Order//////////////////////
  int Trial2 = OrderSend("USDJPY", 2, 1, Ask - 2, 5, 0, 0, NULL, 0, TimeCurrent()+60*60*24,Yellow);
  /////////Placing an Instant Order/////////////////////////
  int trial = OrderSend("USDJPY", 0, 0.1, Ask, 5, 0, 0,NULL,0,TimeCurrent()+60*60*24,Blue);
  //////////////////////////////////////////////////////////
  int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t");
  if(handle<0) return(0);
  // write header
  FileWrite(handle,"Close Time"+","+"Expiration time"+","+"symbol"+","+"lots");
  int total=OrdersTotal();
  // write open orders
  for(int pos=0;pos<total;pos++)
    {
     if(OrderSelect(pos,SELECT_BY_POS)==false) continue;
     FileWrite(handle,TimeToString(OrderCloseTime())+","+TimeToString(OrderExpiration())+","+OrderSymbol()+","+OrderLots());
    }
  FileClose(handle);

Thanks in advance.

-Krishna.

 
krishna_gopal_2:

How to differentiate an Open Market Order and a Pending Order? Here I have tried a test code. I'm placing orders using code and checking some parameters. Please tell me which parameter should be checked whether the order is open or pending.

Thanks in advance.

-Krishna.

Check the OrderType() . . .

Also, your code will be easier to read if instead of doing this . . .

  int Trial2 = OrderSend("USDJPY", 2, 1, Ask - 2, 5, 0, 0, NULL, 0, TimeCurrent()+60*60*24,Yellow);
  /////////Placing an Instant Order/////////////////////////
  int trial = OrderSend("USDJPY", 0, 0.1, Ask, 5, 0, 0,NULL,0,TimeCurrent()+60*60*24,Blue);

. . . you do this . . .

  int Trial2 = OrderSend("USDJPY", OP_BUYLIMIT, 1, Ask - 2, 5, 0, 0, NULL, 0, TimeCurrent()+60*60*24,Yellow);
  /////////Placing an Instant Order/////////////////////////
  int trial = OrderSend("USDJPY", OP_BUY, 0.1, Ask, 5, 0, 0,NULL,0,TimeCurrent()+60*60*24,Blue);
 
// For your reference
double Lots = 1.0;
double PriceBid = SymbolInfoDouble("USDJPY",SYMBOL_BID);
double Space = 100.0; // Points 
double Price = PriceBid - Space*SymbolInfoDouble("USDJPY",SYMBOL_POINT);
       
int Trial2 = OrderSend("USDJPY", OP_BUYLIMIT, Lots, Price, 5, 0, 0, NULL, 0, TimeCurrent()+60*60*24,Yellow);
int trial = OrderSend("USDJPY", OP_BUY, 0.1, SymbolInfoDouble("USDJPY",SYMBOL_ASK), 5, 0, 0,NULL,0,0,Blue);
 
// for the current symbol
double Lots = 1.0;
double Space = 100.0; // Points 
int Trial2 = OrderSend(Symbol(), OP_BUYLIMIT, Lots, Bid - Space*Point, 5, 0, 0, NULL, 0, TimeCurrent()+60*60*24,Yellow);
int trial = OrderSend(Symbol(), OP_BUY, 0.1, Ask, 5, 0, 0,NULL,0,0,Blue);
 
fxmeter:

How does that help "differentiate an Open Market Order and a Pending Order?"
 
RaptorUK:
How does that help "differentiate an Open Market Order and a Pending Order?"

I think my example is helpful to Krishna to understand how to code pending order.

I give the correct example, He may compare his codes with my codes,then he would know what the difference is .

 
fxmeter:

I think my example is helpful to Krishna to understand how to code pending order.

I give the correct example, He may compare his codes with my codes,then he would know what the difference is .

That isn't what the OP wanted help with though . . .
 
krishna_gopal_2:

How to differentiate an Open Market Order and a Pending Order? Here I have tried a test code. I'm placing orders using code and checking some parameters. Please tell me which parameter should be checked whether the order is open or pending.

Thanks in advance.

-Krishna.


Hi krishna_gopal_2,

It's the second parameter value that you need to check, right after the Symbol.

//OP_BUY = 0 / OP_SELL = 1 /OP_BUYLIMIT = 2 /OP_SELLLIMIT = 3  
//OP_BUYSTOP = 4 /OP_SELLSTOP = 5 

So in your example :

 int Trial2 = OrderSend("USDJPY", 2, 1, Ask - 2, 5, 0, 0, NULL, 0, TimeCurrent()+60*60*24,Yellow);

you have the value of 2 after the "USDJPY" (symbol) so it's an OP_BUYLIMIT order (pending).

The other one has a value of 0 so it isn't a pending order, it's a OP_BUY (buy at market).

Hope it helps

 
RaptorUK:

Check the OrderType() . . .

Also, your code will be easier to read if instead of doing this . . .

. . . you do this . . .



Thanks friend. OrderType() works. After execution of a BUYLIMIT or BUYSTOP order, its type changes into 0, ie. OP_BUY. So I can differentiate the orders.

Thanks again.

Reason: