Closing the open position

 
I have some real basic code here but I can't seem to get it to work because I do not know how to get the ticket number from current or open order.

int start(){

double buyhigh = High[iHighest(NULL, 0, MODE_HIGH, iBarShift(NULL, 0, OrderOpenTime()), 0)];


if (Close[PERIOD_M1] > Open[PERIOD_M5])
OrderSend(Symbol(),OP_BUY,100,Ask,3,NULL,NULL,NULL,0,0,Green);

if (buyhigh < (Bid * 0.75))
OrderClose(order_id,1,Ask,3,Red);

return(0);
}
 

if (Close[PERIOD_M1] > Open[PERIOD_M5])
order_id = OrderSend(Symbol(),OP_BUY,100,Ask,3,NULL,NULL,NULL,0,0,Green);

if (buyhigh < (Bid * 0.75))
OrderClose(order_id,1,Ask,3,Red);

 
phy:

if (Close[PERIOD_M1] > Open[PERIOD_M5])
order_id = OrderSend(Symbol(),OP_BUY,100,Ask,3,NULL,NULL,NULL,0,0,Green);

if (buyhigh < (Bid * 0.75))
OrderClose(order_id,1,Ask,3,Red);

Do I have to iniitialize order_id? And if so as what? A string?
 

You have to declare all your variables.

order_id should be declared to match the return type of the OrderSend() function.

Read the documentation.

In metaeditor, in your code, select OrderSend and press F1 key.