Download MetaTrader 5
To add comments, please log in or register
Having questions? Ask them on the Forum - traders will help you!
Minh
140
Minh 2014.03.23 05:14 
Hi guys. Can you guys teach me how to properly write a EA? From my understanding, EA similar to an indicator but it can automatically do the trading for you.
What I got so far from https://docs.mql4.com/trading and from google is:

To open a new order we do:

if(condition1)
{
   int ticket=OrderSend(Symbol(),OP_BUY,vol,pri,slippage,stoploss,takeprofit,"comment",magicnumber,0,CLR_NONE);
}

This command mean that the system will automatically buy volume "vol" for the current symbol at
price "pri" right?
So what is the slippage (5th parameter) used for?

What happen when the price hit "stoploss"/"takeprofit", is the system going to automatically close the order when it hit this price?
or do I have to use the OrderSelect() and then OrderClose() to manually close them all?

Please give me some insight.


Keith Watford
Moderator
7958
Keith Watford 2014.03.23 06:15  

From the book

https://book.mql4.com/trading/ordersend

it allows a bit of leeway as the price may have changed slightly since you received the price

/
To add comments, please log in or register