Expert Advisor Programming by Andrew R. Young
Expert Advisor Programming by Andrew R. Young
Expert Advisor Programming by Andrew R. Young
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Custom Indicators and Scripts<br />
We start <strong>by</strong> using the wizard to create our indicator file. Select New from the File menu or the toolbar<br />
to open the wizard, and create a custom indicator. Fill out the indicator name, and add parameters if<br />
you wish. On the final page, we added three indicator lines of the same color. Here is the result of<br />
the wizard. We've left out the start() function for now:<br />
//+------------------------------------------------------------------+<br />
//| EMA Bollinger.mq4 |<br />
//| <strong>Andrew</strong> <strong>Young</strong> |<br />
//| http://www.easyexpertforex.com |<br />
//+------------------------------------------------------------------+<br />
#property copyright "<strong>Andrew</strong> <strong>Young</strong>"<br />
#property link "http://www.easyexpertforex.com"<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 />
//---- buffers<br />
double ExtMapBuffer1[];<br />
double ExtMapBuffer2[];<br />
double ExtMapBuffer3[];<br />
//+------------------------------------------------------------------+<br />
//| Custom indicator initialization function |<br />
//+------------------------------------------------------------------+<br />
int init()<br />
{<br />
//---- indicators<br />
SetIndexStyle(0,DRAW_LINE);<br />
SetIndexBuffer(0,ExtMapBuffer1);<br />
SetIndexStyle(1,DRAW_LINE);<br />
SetIndexBuffer(1,ExtMapBuffer2);<br />
SetIndexStyle(2,DRAW_LINE);<br />
SetIndexBuffer(2,ExtMapBuffer3);<br />
//----<br />
return(0);<br />
}<br />
Let's turn our attention to the elements listed in bold. The #property declarations set the parameters<br />
for our indicator buffers. The indicator_chart_window property draws our indicator in the main<br />
chart window. If we were creating an oscillator, and wanted to draw the indicator in a separate<br />
window, we'd use the indicator_separate_window property instead.<br />
The indicator_buffers property set the number of buffers for our indicator. In this case we are<br />
using three buffers. The indicator_color properties set the color of all three lines to DeepSkyBlue.<br />
147