文档介绍:MQL4 COURSE
By Coders’ guru
(Appendix 2)
Trading Functions
--------------------
In this appendix you will find the description of the 25 MQL4 trading functions.
I decided to write this appendix before writing the third part of “Your First Expert
Advisor” lesson because you have to know these important functions before cracking
the remaining of the code.
OrderSend:
Syntax:
int OrderSend( string symbol, int cmd, double volume, double price, int slippage,
double stoploss, double takeprofit, ment=NULL, int magic=0, datetime
expiration=0, color arrow_color=CLR_NONE)
Description:
The OrderSend function used to open a sell/buy order or to set a pending order.
It returns the ticket number of the order if eeded and -1 in failure.
Use GetLastError function to get more details about the error.
Note: The ticket number is a unique number returned by OrderSend function which
you can use later as a reference of the opened or pending order (for example you can
use the ticket number with OrderClose function to close that specific order).
Note: GetLastError function returns a predefined number of the last error occurred
after an operation (for example when you call GetLastError after OrderSend
operation you will get the error number occurred while executing OrderSend).
Calling GetLastError will reset the last error number to 0.
You can find a full list of MQL4 errors numbers in file.
And you can get the error description for a specific error number by using
ErrorDescription function which defined at file.
Parameters:
This function takes 11 parameters:
string symbol:
The symbol name of the currency pair you trading (Ex: EURUSD and USDJPY).
Note: Use Symbol() function to get currently used symbol and OrderSymbol function
to get the symbol of current selected order.
int cmd:
An integer number indicates the type of the operation you want to