Expert Advisor Programming: Creating Automated Trading Systems in MQL for MetaTrader 4

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Finally, the first comprehensive guide to MQL programming is here! Expert Advisor Programming guides you through the process of developing robust automated forex trading systems for the popular MetaTrader 4 platform. In this book, the author draws on several years of experience coding hundreds of expert advisors for retail traders worldwide. You'll learn how to program these common trading tasks, and much more: - Place market, stop and limit orders. - Accurately calculate stop loss and take profit prices. - Calculate lot size based on risk. - Add flexible trailing stops to your orders. - Count, modify and close multiple orders at once. - Verify trading conditions using indicators and price data. - Create flexible and reusable source code functions. - Add advanced features such as timers, email alerts and Martingale lot sizing. - Avoid common trading errors and easily troubleshoot your programs. - Adjustments for fractional pip brokers and FIFO. - Plus, learn how to create your own custom indicators and scripts! Whether you're a beginner or an experienced programmer, Expert Advisor Programming can help you realize your automated trading ideas in the shortest amount of time. This book features dozens of code examples with detailed explanations, fully-functioning example programs, and reusable functions that you can use in your own expert advisors!

Author(s): Andrew R. Young
Publisher: Edgehill Publishing
Year: 2009

Language: English
Pages: 212

Introduction......Page 9
About This Book......Page 10
Conventions Used In This Book......Page 11
File Formats......Page 12
File Locations......Page 13
MetaEditor......Page 14
Syntax......Page 15
Identifiers......Page 16
Variables......Page 17
Functions......Page 18
Variable Scope......Page 21
Creating a New Expert Advisor......Page 22
Preprocessor Directives......Page 23
Parameters and External Variables......Page 24
Special Functions......Page 25
Other Functions......Page 26
Order Types......Page 28
The Order Placement Process......Page 29
OrderSend()......Page 30
Placing A Market Order......Page 31
Placing a Pending Limit Order......Page 32
Calculating in Pips......Page 33
Point......Page 34
Slippage and Point......Page 35
Slippage and Point as Global Variables......Page 36
MarketInfo()......Page 37
Alternate Stop Loss Methods......Page 38
OrderSelect()......Page 40
OrderClose()......Page 42
OrderDelete()......Page 43
A Simple Expert Advisor......Page 44
Using Pending Orders......Page 47
Order Modification......Page 50
Adding Stop Loss and Take Profit to an Existing Order......Page 51
Verifying Stops and Pending Order Prices......Page 53
Stop Levels......Page 54
Verifying Stop Loss and Take Profit Prices......Page 55
Money Management......Page 57
Verifying Lot Size......Page 59
Trade Context......Page 60
Error Handling......Page 61
Putting It All Together......Page 65
Lot Sizing Function......Page 72
Lot Verification Function......Page 73
Order Placement Function......Page 74
Pending Order Placement......Page 75
Order Closing Function......Page 77
Stop Loss & Take Profit Calculation Functions......Page 78
Stop Level Verification......Page 79
Add Stop Loss and Take Profit......Page 81
Using Libraries......Page 82
A Simple Expert Advisor (with Functions)......Page 83
The for Operator......Page 88
The Order Loop......Page 89
Order Counting......Page 90
Closing Multiple Orders......Page 92
Trailing Stops......Page 95
Minimum Profit......Page 97
Break Even Stop......Page 98
Updating the Expert Advisor......Page 100
Price Data......Page 102
Trend Indicators......Page 103
Oscillators......Page 105
Custom Indicators......Page 106
Applied Price......Page 110
Evaluating Trade Conditions......Page 111
Relation Operations......Page 112
Boolean Operations......Page 113
Turning An Indicator On and Off......Page 114
Comparing Indicator Values Across Bars......Page 116
Datetime Constants......Page 120
Date and Time Functions......Page 122
Creating A Simple Timer......Page 123
Execute On Bar Open......Page 125
Using Chart Comments......Page 130
Check Settings......Page 131
Demo or Account Limitations......Page 132
MessageBox()......Page 133
Button Flags......Page 134
Email Alerts......Page 135
Retry on Error......Page 136
Using Order Comments As an Identifier......Page 139
Spread Check......Page 140
Multiple Orders......Page 141
Global Variables......Page 144
Check Order Profit......Page 145
Martingale......Page 146
Debugging Your Expert Advisor......Page 149
Troubleshooting Intermittent Trading Errors......Page 151
Fixing Compilation Errors......Page 152
Creating A Custom Indicator......Page 154
Drawing Properties......Page 156
Using Descriptive Buffer Names......Page 157
The Indicator start() Function......Page 158
Scripts......Page 160
Simple Expert Advisor......Page 162
Simple Expert Advisor with Pending Orders......Page 164
Advanced Expert Advisor......Page 168
Advanced Expert Advisor with Pending Orders......Page 174
Expert Advisor with Functions......Page 180
Expert Advisor with Functions – Pending Orders......Page 183
Include File......Page 188
Custom Indicator......Page 206
Index......Page 209