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

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

Andrew R. Young

Language: English

Pages: 212

ISBN: 0982645902

Format: PDF / Kindle (mobi) / ePub

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!

The Illustrated Hassle-Free Make Your Own Clothes Book

Data Mining Methods and Models

Everyday Life in Southeast Asia

Homer's Odyssey: A Fearless Feline Tale, or How I Learned about Love and Life with a Blind Wonder Cat


















minimum distance is not guaranteed. 45 EXPERT ADVISOR PROGRAMMING For these reasons, it is always necessary to verify that a stop loss, take profit or pending order price is valid, and not too close to the current market price. We verify this by checking the currency's stop level. Stop Levels The stop level is the number of pips away from the current Bid or Ask price that all stops and pending orders must be placed. For most brokers, the stop level is approximately 3-4 pips. ECN brokers

save you time in the long run, as you will more easily be able to prototype trading ideas and turn out working expert advisors in a short amount of time. 78 Working with Functions 79 EXPERT ADVISOR PROGRAMMING Chapter 5 Order Management You've already been introduced to the OrderSelect() function in chapter 2. In this section, we will use the OrderSelect() function, along with the cycle operators for and while, to loop through the order pool and retrieve order information. This method will

datetime value. • TimeMonth() – The month of the specified datetime value from 1 to 12. • TimeDay() – The day of the month of the specified datetime value from 1 to 31. • TimeDayOfWeek() – An integer representing the day of the week of the specified datetime value. Sunday is 0, Monday is 1, Friday is 5 and so on. • TimeHour() – The hour of the specified datetime value in 24 hour time, from 0 to 23. • TimeMinute() – The minute of the specified datetime value from 0 to 59. Here are a few

UpperStopLevel + MinStop; } // Place pending order if(IsTradeContextBusy()) Sleep(10); BuyTicket = OrderSend(Symbol(),OP_BUYSTOP,LotSize,PendingPrice,UseSlippage, BuyStopLoss,BuyTakeProfit,"Buy Stop Order",MagicNumber,0,Green); // Error handling if(BuyTicket == -1) { ErrorCode = GetLastError(); ErrDesc = ErrorDescription(ErrorCode); ErrAlert = StringConcatenate("Open Buy Stop Order - Error ",ErrorCode, ": ",ErrDesc); Alert(ErrAlert); ErrLog = StringConcatenate("Ask: ",Ask," Lots: ",LotSize,"

OP_BUYSTOP) { OrderCount++; } } return(OrderCount); } int SellStopCount(string argSymbol, int argMagicNumber) { int OrderCount; for(int Counter = 0; Counter <= OrdersTotal()-1; Counter++) { OrderSelect(Counter,SELECT_BY_POS); if(OrderMagicNumber() == argMagicNumber && OrderSymbol() == argSymbol && OrderType() == OP_SELLSTOP) { OrderCount++; } } return(OrderCount); } int BuyLimitCount(string argSymbol, int argMagicNumber) { int OrderCount; for(int Counter = 0; Counter <= OrdersTotal()-1;

Download sample