25.10.2016 Views

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

EXPERT ADVISOR PROGRAMMING<br />

Appendix C<br />

<strong>Expert</strong> <strong>Advisor</strong> with Functions<br />

This is the expert advisor using the functions introduced in chapter 4. We've added the "close all<br />

orders" functions and trailing stop function from chapter 5, and the "execute once per bar" features<br />

from chapter 7.<br />

The functions are defined in IncludeExample.mqh, the contents of which are listed in Appendix D.<br />

// Preprocessor<br />

#property copyright "<strong>Andrew</strong> <strong>Young</strong>"<br />

#include <br />

// External variables<br />

extern bool DynamicLotSize = true;<br />

extern double EquityPercent = 2;<br />

extern double FixedLotSize = 0.1;<br />

extern double StopLoss = 50;<br />

extern double TakeProfit = 100;<br />

extern int TrailingStop = 50;<br />

extern int MinimumProfit = 50;<br />

extern int Slippage = 5;<br />

extern int MagicNumber = 123;<br />

extern int FastMAPeriod = 10;<br />

extern int SlowMAPeriod = 20;<br />

extern bool CheckOncePerBar = true;<br />

// Global variables<br />

int BuyTicket;<br />

int SellTicket;<br />

double UsePoint;<br />

int UseSlippage;<br />

datetime CurrentTimeStamp;<br />

172

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!