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

Place orders in market in MetaTrader

HOW TO PLACE ORDERS IN MARKET

1.      Symbol() – tells the currency in which we are trading presently

2.      Lots – volume of the trade that we are going to trade

3.      StopLoss – value chosen by the user. If trade goes against our prediction, then we can set a value at which we want to stop loss and delete the trade.

4.      TakeProfit – value at which we want to start gaining profits.

5.      Magic number

Types of order:

1.      Buy

2.      Sell

3.      Buy stop

4.      Sell stop

5.      Buy limit

6.      Sell limit

Functions used

1.      OrderSend() – Place the orders

2.      OrderClose() – closes a market order

3.      OrderDelete() – deletes a pending order

4.      OrderModify() – to modify market and pending orders

 

Attachment:None


Example of placing the orders in market: 

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- get minimum stop level
   double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
   Print("Minimum Stop Level=",minstoplevel," points");
   double price=Ask;
//--- calculated SL and TP prices must be normalized
   double stoploss=NormalizeDouble(Bid-minstoplevel*Point,Digits);
   double takeprofit=NormalizeDouble(Bid+minstoplevel*Point,Digits);
//--- place market order to buy 1 lot
   int ticket=OrderSend(Symbol(),OP_BUY,1,price,3,stoploss,takeprofit,"My order",16384,0,clrGreen);
   if(ticket<0)
     {
      Print("OrderSend failed with error #",GetLastError());
     }
   else
      Print("OrderSend placed successfully");
//---
  }
Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud