You are on page 1of 29

Program trading with MT4

Use of MT4 platform


Building blocks

Alerting Regular
Data fetching Data processing
Reporting

Order Trading
Data analysis Charting strategies
management

Database Account VPS


Backtesting
Management management setup
Agenda
• Overview
• Setup of MT4 platform and create demo accounts
• Terminologies used in FX trading
• Charts
• Useful features
• Placing orders
• Deploy standard indicators in MT4 platform
• Overview of MQL
Why MT4
• Most popular forex trading platform for algo trading
• Lots of competitive brokers (for Forex/CFD/stocks etc) are available with MT4 platform
(https://www.daytrading.com/forex-brokers)
• MT4 is available on Windows PC, Android, iPhone, and web browsers.
• Different types of automatic order execution supported
• One of the most powerful innovations for the MT4 platform was the introduction of
expert advisors (EAs). These are small pieces of software code that can be written by a
trader and used on the MT4 platform to automate their trading strategy. Since Forex is a
24-hour market, this is great for traders to increase their trading opportunities or allow
a trader to continue to trade while doing another job
• Many EAs are available in the market
• EA/indicators/scripts are complied to binary codes by MT4 system in order to speed up
the execution time
• MQL developer could develop and sell EAs as additional revenue source
• MT4 users could subscribe and follow EA signals for automated order execution
Feature enhancement of MT4 platform
with Python
• Customized data visualization and analysis (e.g.
statistical analysis with other data sources)
• Customized alerting (e.g. charts/attached excel files)
with email and telegram
• Create chat bot to facilitate data analysis/order
execution
• Use of machine learning (e.g. deep learning) for FX
forecasting model
MT4/MQL + Python
Why Python is so popular in the market
• Open source
• Easy to use
• Top 2 popular programming languages in the world
• Lots of users and developers with big user community
• Lots of useful packages
• Numpy
• Pandas
• Matplotlib
• Tensorflow
• Beatifulsoup
• Selenium
• Scikit learn
• And more…
• Good support on data analytics tasks (use of different ML
algorithms)
Overall setup of program trading system
Basic Automatic
charting Basic Alerting
Monitoring

Automatic Order
execution
Brokers MT4 platform

Back testing

Customized
Alerting Data analytics (ML
algorithms)
Customized Python
charting Automatic data
collection and DB
storage
Chat bot
Program Trading
• Program trading refers to automated monitoring/analysis
and order execution by investors using computer
programs.
• Benefits:
• Become more systematic and disciplined when performing trading
• To collect stock data and perform monitoring automatically
• To perform back testing with the collected data
• To send alerts (email/telegram/sms etc) from system when the trigger happens
• To execute the orders automatically
Why automate your trading
• Time savings
• Could support forex trading on 5x24 basis
• Let the robot trades for you automatically based on your strategies
• More discipline and less human mistakes on trading execution
• Need to define the whole strategy (enter/exit/stoploss etc) beforehand
• Opportunity to scale
• Run the robots on different currency pairs/markets at the same time
• Higher profit potential
• Run multiple strategies at the same times on different currency pairs
• Learn to program
• Learn the programming logic and apply it to other domains
Link to download MT4 platform
• Note: You could go to your favorite broker and download the MT4
platform and get the demo account.
• However for practicing purpose during the course we will share one
of the brokers and setup the demo account.
Terminologies used in FX trading
• Currency pair (e.g. GBPUSD)
• Bid price
• Ask price
• Spread
• Pips
Currency pair
• A currency pair is the quotation of two different currencies, with the
value of one currency being quoted against the other. The first listed
currency of a currency pair is called the base currency, and the
second currency is called the quote currency.
• Currency pairs compare the value of one currency to another—the
base currency (or the first one) versus the second or the quote
currency. It indicates how much of the quote currency is needed to
purchase one unit of the base currency.
Bid/Ask/Spread
• The bid represents the price at which the forex market maker or
broker is willing to buy the base currency in exchange for the counter
currency. Conversely, the ask price is the price at which the forex
broker is willing to sell the base currency in exchange for the counter
currency.

• The bid-ask spread is the difference between the price a broker buys
and sells a currency. So, if a customer initiates a sell trade with the
broker, the bid price would be quoted. If the customer wants to
initiate a buy trade, the ask price would be quoted.
Example
PIPS
A pip is a standardized unit and is the smallest amount by which a
currency quote can change. It is usually $0.0001 for U.S.-dollar related
currency pairs, which is more commonly referred to as 1/100th of 1%,
or one basis point. This standardized size helps to protect investors
from huge losses.
Remark
• For currency pairs displayed to 4 decimal places, one pip = 0.0001
• Yen-based currency pairs are an exception, and are displayed to only
two decimal places (0.01)
Lot size
Example: PIP value calculation
• EURO/USD=1.19823
• Contract value for one lot=100000*1.19823=119823 USD
• Now if the currency moves up by one PIP:
• Contract value for one lot=100000*1.19833=119833 USD
• Gain for one lot=119833-119823 USD=10 USD
Leverage

• Funds loaned to you by broker

Leverage Margin requirement 1 lot requirement


1:1 100% $100,000
20:1 5% $5000
100:1 1% $1000
400:1 0.25% $250
MT4 terminal
Strategy tester Meta Editor
Enable/disable auto trading Charts

Indicators/
Scripts/EA

Orders
What MT4 provides

• Expert advisors (EA)


• Scripts
• Indicators
• Library

• MQL is the programming language used by MT4 platform


Chart
Useful features
• Auto-scroll
• Chat zoom and compression
• Changing chart timeframe
• Crosshair
• Data window
• Chart Template
• Profile
Placing orders

• One click trading


• Open an order
• Close an order
• Setting a stoploss
• Setting a take profit
• Pending order
• Trailing stop
One click trading
Trailing stop
• A trailing stop is a modification of a typical stop order that can be set at a defined
percentage or dollar amount away from a security's current market price. For a
long position, an investor places a trailing stop loss below the current market
price. For a short position, an investor places the trailing stop above the current
market price
• A trailing stop is designed to protect gains by enabling a trade to remain open and
continue to profit as long as the price is moving in the investor’s favour. The order
closes the trade if the price changes direction by a specified percentage or dollar
amount

Reference
https://www.investopedia.com/terms/t/trailingstop.asp#:~:text=Using%20a%2010
%25%20trailing%20stop,which%20is%2010%25%20below%20%241%2C010.
Deploy indicators in MT4 platform
• EMA
• RSI
• MACD
• KD
Demo
Install EA in MT4 and perform simple backtesting
Use case of using MT4 platform

• How to install EA into MT4 platform


• EA (mql/ex4)
• Insert standard indicators into the chart
• Navigator (file explore)
• History center (download/export new data)
Overview of MQL
Good reference
https://docs.mql4.com/

You might also like