Posted By:
30 Jul, 2014 10:19 pm PDT

Placing pending orders in MetaTrader

Pending orders :

A pending order allows traders to buy and sell securities at a pre-defined price in the future. This type of order is used to execute a trade if price reaches the pre-defined level; the order will not be filled if price does not reach this level. There are four types of pending orders available in MT4:

  • Buy Limit - an order to purchase a security at or below a specified price. Limit orders must be placed on the correct side of the market to ensure they will accomplish the task of improving price. For a buy limit order, this means placing the order at or below the current market bid. 

  • Sell Limit - an order to sell a security at or above a specified price. To ensure improved price, the order must be placed at or above the current market ask.

  • Buy Stop - an order to buy a security at a price above the current market bid. A stop order to buy becomes active only after a specified price level has been reached (known as the stop level). Stop orders work in the opposite direction of a limit order, with buy stop orders placed above the market and sell stop orders placed below the market. Once a stop level has been reached, the order will be immediately converted into a market or limit order. 

  • Sell Stop - an order to sell a security at a price below the current market ask. A stop order to sell becomes active only after a specified price level has been reached.
Attachment:None


Example of plaing a pending order: 

//+------------------------------------------------------------------+
//| placeorders.mq4 |
//| Copyright 2014, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
extern double lot=0.01;
extern int stoploss=40;
extern int takeprofit=40;
extern int magic=38578;

int OnInit()
{
//---

//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---

}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---

}
//+------------------------------------------------------------------+



void buystop(double price, double stop){

OrderSend(Symbol(),OP_BUYSTOP,lot,price,3,stop,price-takeprofit*Point,"Buy stop trade",magic,Pink);
}

void sellstop(double price, double stop){
OrderSend(Symbol(),OP_SELLSTOP,lot,price,3,stop,price-takeprofit*Point,"Sell stop trade",magic,White);
}
 
Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud