//------------------------------------------------------------------ #property copyright "www.forex-tsd.com" #property link "www.forex-tsd.com" //------------------------------------------------------------------ #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DarkGray #property indicator_color2 PaleVioletRed #property indicator_width2 2 // // // // // extern int VolPeriod = 14; extern int VolPrice = PRICE_CLOSE; extern double VolLevel = 2; extern int Smooth = 3; extern int SmoothMethod = MODE_LWMA; extern bool alertsOn = false; extern bool alertsOnSmoothed = true; extern bool alertsOnCurrent = true; extern bool alertsMessage = true; extern bool alertsSound = false; extern bool alertsEmail = false; double vol[]; double volavg[]; double cross[]; //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int init() { IndicatorBuffers(3); SetIndexBuffer(0,vol); SetIndexBuffer(1,volavg); SetIndexBuffer(2,cross); SetLevelValue(0,VolLevel); Smooth = MathMax(Smooth,1); return(0); } int deinit() { return(0); } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int start() { int counted_bars=IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars>0) counted_bars--; int limit = MathMin(Bars-counted_bars,Bars-1); // // // // // for(int i = limit; i >= 0; i--) { double range = MathMax(High[i],Close[i+1])-MathMin(Low[i],Close[i+1]); double atr = iATR(NULL,0,VolPeriod,i+1); if (atr!=0) vol[i] = range/atr; else vol[i] = 0; } for(i = limit; i >= 0; i--) { volavg[i] = iMAOnArray(vol,0,Smooth,0,SmoothMethod,i); cross[i] = cross[i+1]; if (alertsOnSmoothed) { if (volavg[i]>VolLevel) cross[i] = 1; if (volavg[i]VolLevel) cross[i] = 1; if (vol[i]