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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

EXPERT ADVISOR PROGRAMMING<br />

Appendix E<br />

Custom Indicator<br />

Here is the code for the custom indicator from chapter 9:<br />

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

#property indicator_chart_window<br />

#property indicator_buffers 3<br />

#property indicator_color1 DeepSkyBlue<br />

#property indicator_color2 DeepSkyBlue<br />

#property indicator_color3 DeepSkyBlue<br />

// External variables<br />

extern int BandsPeriod = 20;<br />

extern int BandsShift = 0;<br />

extern int BandsMethod = 1;<br />

extern int BandsPrice = 0;<br />

extern int Deviations = 1;<br />

// Buffers<br />

double EMA[];<br />

double UpperBand[];<br />

double LowerBand[];<br />

// Init<br />

int init()<br />

{<br />

SetIndexStyle(0,DRAW_LINE);<br />

SetIndexBuffer(0,EMA);<br />

SetIndexLabel(0,"EMA");<br />

SetIndexStyle(1,DRAW_LINE);<br />

SetIndexBuffer(1,UpperBand);<br />

SetIndexLabel(1,"UpperBand");<br />

SetIndexStyle(2,DRAW_LINE);<br />

SetIndexBuffer(2,LowerBand);<br />

SetIndexLabel(2,"LowerBand");<br />

}<br />

return(0);<br />

198

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

Saved successfully!

Ooh no, something went wrong!