How to open 2 oposite stop orders?

 
I am new to MQL and having a bit of difficulty understandig this. Lets asume i have some code that does some calculations and tells me whether it is ok to place pending orders and at what price.
Something like this:

if okToBuy=true
{
here i would like to have my long stop pending order
}
if okToSell=true
{
here i would like to have my short stop pending order
}
Also if a new candle opens and the orders have not been triggered i would like them to imediately get canceled because on this candle i might need to issue 2 new orders at a different price.

I would be very greatful if someone could show me an example of how the code should be structured in order for me to achieve that.
 
Use date expiration parameter in OrderSend().

Parameters:
symbol - Symbol for trading.
cmd - Operation type. It can be any of the Trade operation enumeration.
volume - Number of lots.
price - Preferred price of the trade.
slippage - Maximum price slippage for buy or sell orders.
stoploss - Stop loss level.
takeprofit - Take profit level.
comment - Order comment text. Last part of the comment may be changed by server.
magic - Order magic number. May be used as user defined identifier.
expiration - Order expiration time (for pending orders only).
arrow_color - Color of the opening arrow on the chart. If parameter is missing or has CLR_NONE value opening arrow is not drawn on the chart.
Reason: