//+------------------------------------------------------------------ //| //+------------------------------------------------------------------ #property copyright "www.forex-tsd.com" #property link "www.forex-tsd.com" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 DeepSkyBlue #property indicator_color2 PaleVioletRed #property indicator_color3 DimGray #property indicator_width1 2 #property indicator_width2 2 #property indicator_style3 STYLE_DOT // // // // // extern int Length = 21; extern double Multiplier = 3; extern int ChannelShift = 1; extern int TestBar = 0; extern bool alertsOn = false; // Turn alerts on? extern bool alertsOnCurrent = false; // Alerts on still opened bar? extern bool alertsMessage = true; // Alerts should display message? extern bool alertsSound = false; // Alerts should play a sound? extern bool alertsNotify = false; // Alerts should send a notification? extern bool alertsEmail = false; // Alerts should send an email? extern string soundFile = "alert2.wav"; // Sound file // // // // // double barUp[]; double barDn[]; double signal[]; double atr[],trend[]; //+------------------------------------------------------------------ //| //+------------------------------------------------------------------ // // // // // int init() { IndicatorBuffers(5); SetIndexBuffer(0,barUp); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1,barDn); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2,signal); SetIndexBuffer(3,atr); SetIndexBuffer(4,trend); TestBar = MathMax(MathMin(TestBar,1),0); return(0); } int deinit() { return(0); } //+------------------------------------------------------------------ //| //+------------------------------------------------------------------ // // // // // int start() { int i,limit,counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit = MathMin(Bars-counted_bars,Bars-1); // // // // // for(i=limit; i>=0; i--) atr[i] = MathMax(High[i],Close[i+1])-MathMin(Low[i],Close[i+1]); for(i=limit; i>=0; i--) { double hi = Close[ArrayMaximum(Close,Length,i+TestBar+ChannelShift)]; double lo = Close[ArrayMinimum(Close,Length,i+TestBar+ChannelShift)]; double tr = iMAOnArray(atr,0,Length,0,MODE_LWMA,i+TestBar); double hiLimit = hi-tr*Multiplier; double loLimit = lo+tr*Multiplier; signal[i] = signal[i+1]; trend[i] = 0; barUp[i] = EMPTY_VALUE; barDn[i] = EMPTY_VALUE; if (Close[i+TestBar]>loLimit && Close[i+TestBar]>hiLimit) signal[i] = hiLimit; if (Close[i+TestBar]signal[i]) { barUp[i] = High[i]; barDn[i] = Low[i]; trend[i] = 1; } if (Close[i+TestBar]=0; i--) if (tf==iTfTable[i]) return(sTfTable[i]); return(""); } int timeFrameValue(int _tf) { int add = (_tf>=0) ? 0 : fabs(_tf); if (add != 0) _tf = _Period; int size = ArraySize(iTfTable); int i =0; for (;i