Article

Easy Programming for MT4 Forex Trading

Topic: ForexBy Sng Chong HowPublished Recently added

Legacy signals

Legacy popularity: 2,412 legacy views

Programming is a common language used in software industry and with the release of MetaTrader trading platform, it introduce a programming language with is similar to C into the Forex Trading world.

With programming, Forex Trader can put their winning strategy into programming codes and run on MT4 trading platform to let the computer trades automatically. This is make possible using MQL or metaquotes languages to write and compile using metaeditor into executable ex files which are called expert advisor to run on MT4 trading account.

The programming is similar to C with declaration of variables, logic comparision and executing of files and functions.

Variables

MQL4 comes with various data types namely integer, Boolean, character, string, float, color and date & time. You can create local variable can using the standard declaration like int, double, string, etc. For global variables, you have to declare the variables before int start(). To have your variable available and value retained after program ended, use static variable declaration by static int, static double, etc

Standard Constants

It comes with many standard constant that you can use which is already predefine by the program. One of the most important standard constants are timeframe which comes with PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1 and PERIOD_MN1. This is useful in defining the currency chart to use for technical indicator trigger. Next is the OrderSend() function which uses trade operations constant OP_BUY, OP_SELL, OP_BUYLIMIT, OP_SELLLIMT, OP_BUTSTOP and OP_SELLSTOP which covers all the 6 different trade execution. The last importance standard constant is price related which is PRICE_CLOSE, PRICE_OPEN, PRICE_HIGH and PRICE_LOW which is often used in technical charting.

Predefined Variables

Ask, Bars, Bid, Close, Digits, High, Low, Open, Point and Time are widely use thru out the programming codes. When comparing currency price, Ask, Bid, Close, Open, High and Low are often called for operand operation. Bars is used when counting the number of bars in the selected currency chart. Point is the current symbol point value in the quote currency and Digits is the number after decimal point for the current symbol price. Both are used to compute stop loss, profit take, buy and sell price.

Account Information

This is a group of function which provided important information about your trading account and is used for computing trading lots and money management system including calculating of margin and balance. The often used function are AccountBalance, AccountFreeMargin, AccountLeverage, AccountMargin and AccountProfit. You need to input some margin requirement and usually I use minimum 200% margin requirement for max open lots using account leverage for maximum drawdown to avoid margin call.

Date and Time Functions

The widely used functions are DayOfWeek to get the Monday to Sunday of the date, Hour and minute for time and Seconds for looping. If your strategy is time constraint, meaning it only run during 2 to 4 am and only on Monday to Wednesday, this group of function is definitely the ones that you called to compare and execute codes.

Technical Indicators

This is the most important functions you be calling if you are using technical charting to execute trading rules. The common indicator that I used are iMA which is moving average simple/exponential/linear weighted calculation, iRSI which is Relative Strength Index, iMACD which is Moving Average Convergence/Diverage, iBands which is Bollinger Bands, iCCI which is Commodity Channel Index, iStochastic which is Stochastic Oscillator and iADX which is Movement Directional Index.

Trading Functions

This is required for any trading to be successful. The widely used trade function are OrderSend, OrderSelect, OrderClose and OrderModify. You may refer to MQL4 documentation for more information of the various functions. And refer to my website for more software offers with ready to use program codes.

Source: http://www.bestforexranking.com

Article author

About the Author

I am currently hosting http://www.bestforexranking.com which provides reviews, articles and strategies. Am giving away a free eBook (with 40+ Forex Trading strategies) by signing up to my email newsletter. Go get your free copy today.

Further reading

Further Reading

4 total

Article

Trading in the forex market once was the domain of banks and large banking institutions; nowadays though, it has become offered to the average individual, because of computers and the Internet. With the proliferation of a lot of Forex trading software systems, along with the simple fact that one can get started with a mere $100 (or even less) to open up a Forex trading account, it is no wonder that the average daily turnover of the global foreign exchange market has expanded to almost $4 trillion in April 2010 vs. $1.7 trillion in 1998.

Related piece

Article

The benefit of automation goes far beyond the capacity to stay away from the computer for lengthened periods of time. Automation allows for more trades than manual execution, and even more importantly, takes away the unsafe factor of non sense human emotion from trading. Automation is the New Traderrnr

Related piece

Article

In this article, we will discuss 3 of the finest online trading tactics for Forex strategy trading. There's no question that most technological advancements have occurred in the last decade, signaling a revolution in the online trading field, particularly Forex. Thus, if you want to get to the top and become a profitable trader, these include 3 essential things that you have to remember to become successful in Forex:r

Related piece

Article

When you go searching for a forex trading strategy that works, it can be tricky to determine what is a viable approach to take. Many tactics depend on very short-run targets which could produce big revenue for a short time and then a crash. Dishonest dealers produce these systems to market to beginners because they can direct attention to a good month which usually exhibits awesome outcomes. They never inform you of the negative effects.

Related piece