Article

Easy Programming for MT4 Forex Trading

Topic: ForexBy Sng Chong HowPublished Recently added

Legacy signals

Archived popularity: 2,412 legacy viewsImported historical SelfGrowth signal; not blended with current reader activity.

Reader rating

Not enough ratings yet

Aggregate average appears after enough eligible reader ratings.

Rate this resource

Sign in to rate this resource.

Sign in to rate this resource

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

Nvidia StrategyrnNvidia Strategy and Nvidia Corporation is an American multinational technology company incorporated in Delaware and based in Santa Clara, California.rnIt is a software and fabless company that designs graphics processing units, application programming interfaces for data science and high-performance computing as well as system on chip units for the mobile computing and automotive market.rnStock Strategy rnNvidia is a dominant supplier of artificial intelligen

June 9, 2024

Article

Understanding the Investment Risk LadderrnHere are the major asset classes, in ascending order of risk, on the investment risk ladder. CashrnA cash bank deposit is the simplest, most easily understandable investment asset—and the safest. It not only gives investors precise knowledge of the interest that they’ll earn but also guarantees that they’ll get their capital back. On the downside, the interest earned from cash socked away in a savings account seldom beats inflat

October 24, 2023

Article

How Should We Celebrate the Anniversary of the Birth of Prophet Muhammad (PBUH)? For Muslims, Prophet Muhammad (PBUH) is the best creature ever. He is the last messenger and prophet sent by the Almighty Allah to guide people from the darkness of ignorance to light of Divine guidance. At any human scale, he (PBUH) is a man of extraordinary achievements. This is a fact admitted not only by Muslims, but by non-Muslim thinkers and philosophers also. Having put Prophet Muhammad (P

August 25, 2023

Article

This is Jesus, Son of Mary, the Word of Truth rn Festivals and celebrations are considered one of the distinctive characteristics and key features of societies around the world as they constitute a major part of cultural fabric for people. This means that there is hardly any human society without festivals, whether they are related to religious occasions or non-religious ones. While there are some Islamic festivals like, Eid al-Fiá¹­r and Eid al-Adha, there are also various c

August 14, 2023