//+-----------+
//| Spread |
//+-----------+
#property copyright "Copyright 2005 Ron Thompson"
#property link "http://www.forexmt4.com/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Green
#property indicator_color3 Red
//---- buffers
double ExtMapBuffer1[]; //Yellow
double ExtMapBuffer2[]; //Green
double ExtMapBuffer3[]; //Red
//specific to indicator
double spread;
double spreadtot;
int spreadticks;
double maxspread;
// bar open handling
int bartime;
//+-----------+
//| Init |
//+-----------+
int init()
{
// 233 up arrow
// 234 down arrow
// 158 little dot
// 159 big dot
// 168 open square
// 120 box with X
SetIndexBuffer(0,ExtMapBuffer1); //Yellow
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(1,ExtMapBuffer2); //Green
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(2,ExtMapBuffer3); //Red
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
Print("Init complete");
}
//+-----------+
//| DE-Init |
//+-----------+
int deinit()
{
Print("DE-Init complete");
}
//+-----------+
//| Each Tick |
//+-----------+
int start()
{
int pos;
// draw once at open of bar
if(bartime!=Time[0])
{
bartime=Time[0];
spreadtot=0;
spreadticks=0;
maxspread=0;
ExtMapBuffer1[0]=0;
//ExtMapBuffer2[0]=0;
}
spread=Ask-Bid;
if(spread>maxspread) maxspread=spread;
spreadtot=spreadtot+spread;
spreadticks++;
ExtMapBuffer1[0] = spreadtot/spreadticks;
//ExtMapBuffer2[0] = maxspread;
Comment("Spread="+spread+" MAXspread="+maxspread+" Total="+spreadtot+" Ticks="+spreadticks+" Average=" + spreadtot/spreadticks);
}//start
Comments