Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #property indicator_chart_window
- #property indicator_buffers 2
- #property indicator_color1 Red
- #property indicator_color2 Aqua
- extern int dist=24;
- extern double arrowPosition = 0.25;
- input int TriggerCandle = 1;
- input bool EnableNativeAlerts = true;
- input bool EnableSoundAlerts = true;
- input bool EnableEmailAlerts = true;
- input bool EnablePushAlerts = true;
- input string AlertEmailSubject = "";
- input string AlertText = "";
- input string SoundFileName = "alert.wav";
- datetime LastAlertTime = D'01.01.1970';
- int LastAlertDirection = 0;
- double b1[];
- double b2[];
- int init() {
- SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
- SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
- SetIndexArrow(1,233);
- SetIndexArrow(0,234);
- SetIndexBuffer(0,b1);
- SetIndexBuffer(1,b2);
- return(0);
- }
- int start() {
- int counted_bars=IndicatorCounted();
- int k,i,j,limit,hhb,llb;
- if (counted_bars<0) return(-1);
- if (counted_bars>0) counted_bars--;
- limit=Bars-counted_bars-1;
- limit=MathMax(limit,dist);
- if (limit<0) limit=0;
- for (i=limit;i>=0;i--) {
- hhb = Highest(NULL,0,MODE_HIGH,dist,i-dist/2);
- llb = Lowest(NULL,0,MODE_LOW,dist,i-dist/2);
- if (i==hhb) b1[i]=High[hhb]+iATR(NULL,0,10,i)*arrowPosition; else b1[i]=EMPTY_VALUE;
- if (i==llb) b2[i]=Low[llb] -iATR(NULL,0,10,i)*arrowPosition; else b2[i]=EMPTY_VALUE;
- }
- if (((TriggerCandle > 0) && (Time[0] > LastAlertTime)) || (TriggerCandle == 0))
- {
- string Text;
- // Up Arrow Alert
- if ((b1[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
- {
- Text = AlertText + "Up Arrow Buy Now: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - Up.";
- if (EnableNativeAlerts) Alert(Text);
- if (EnableEmailAlerts) SendMail(AlertEmailSubject + "Up Arrow Buy Now", Text);
- if (EnableSoundAlerts) PlaySound(SoundFileName);
- if (EnablePushAlerts) SendNotification(Text);
- LastAlertTime = Time[0];
- LastAlertDirection = 1;
- }
- // Down Arrow Alert
- if ((b2[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
- {
- Text = AlertText + "Down Arrow Sell Now: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - Down.";
- if (EnableNativeAlerts) Alert(Text);
- if (EnableEmailAlerts) SendMail(AlertEmailSubject + "Down Arrow Sell Now", Text);
- if (EnableSoundAlerts) PlaySound(SoundFileName);
- if (EnablePushAlerts) SendNotification(Text);
- LastAlertTime = Time[0];
- LastAlertDirection = -1;
- }
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement