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 B<br />

Advanced <strong>Expert</strong> <strong>Advisor</strong><br />

This is the expert advisor with advanced features from chapter 3.<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 Slippage = 5;<br />

extern int MagicNumber = 123;<br />

extern int FastMAPeriod = 10;<br />

extern int SlowMAPeriod = 20;<br />

// Global variables<br />

int BuyTicket;<br />

int SellTicket;<br />

double UsePoint;<br />

int UseSlippage;<br />

int ErrorCode;<br />

// Init function<br />

int init()<br />

{<br />

UsePoint = PipPoint(Symbol());<br />

UseSlippage = GetSlippage(Symbol(),Slippage);<br />

}<br />

// Start function<br />

int start()<br />

{<br />

// Moving averages<br />

double FastMA = iMA(NULL,0,FastMAPeriod,0,0,0,1);<br />

double SlowMA = iMA(NULL,0,SlowMAPeriod,0,0,0,1);<br />

160

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

Saved successfully!

Ooh no, something went wrong!