Forex Traders who are proficient in programming can convert their winning strategies into codes that run on mt4 forex Malaysia to automate trading. The MQL language or metaquotes is used for writing and compiling using Metaeditor to executable ex files that are known as expert advisor to be run on MT4 accounts.
This programming language is similar in many ways to C. Variables are declared, logic is compared and files and functions executed.
MQL4 provides a number of different data types such as integer, Boolean (character), string, date and time, color, and float. Standard declarations, such as double, character, and int can be used to create local variables. Global variables must be declared before starting int. You can use static variables declarations by static int (static double), static double (static triple), etc. to keep your variable and its value after program end.
You can make use of the standard constants which are already defined by the software. Timeframes is one of most important constants. There are many options, including PERIOD_H1, PERSIOD_H4, METHOD_M1, PERSIOD_M5, and METHOD_M30. You can use this to define the currency chart that will be used for technical indicator trigger. Following is the OrderSend() which utilizes the six different trade execution constants: OP_BUY, OP_SELL, OP_BUYLIMIT, OP_SELLLIMT, OP_BUTSTOP, and SELLSTOP. This last standard constant is related to price and is called PRICE_CLOSE.
The programming codes Ask, bars, bid, close, Digits, high, low, open, point and time are all used. To compare the currency price Ask, close, open, high and low are frequently used for operation. When you count how many bars are on the chart of the chosen currency, Bars will be used. Point is the present symbol value for the selected currency. Digits is, after decimal points, the current symbol rate. Stop loss, gain take and the buy/sell price are all calculated using both.
AccountBalance, AccountFreeMargin,AccountLeverage and AccountMargin are the most commonly used functions. AccountBalance (often used), AccountFreeMargin(often not used), AccountLeverage (often not used), AccountMarginand AccountProfit are some of the frequently-used functions. Input the margin required. I normally use 200% minimum margin for open lots and account leverage maximum drawdown in order to avoid margin call.