Advertisement
Guest User

Arrow Signals

a guest
Jul 8th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1.  
  2.  
  3. #property indicator_chart_window
  4. #property indicator_buffers 2
  5. #property indicator_color1 Red
  6. #property indicator_color2 Aqua
  7.  
  8. extern int dist=24;
  9. extern double arrowPosition = 0.25;
  10. input int TriggerCandle = 1;
  11. input bool EnableNativeAlerts = true;
  12. input bool EnableSoundAlerts = true;
  13. input bool EnableEmailAlerts = true;
  14. input bool EnablePushAlerts = true;
  15. input string AlertEmailSubject = "";
  16. input string AlertText = "";
  17. input string SoundFileName = "alert.wav";
  18.  
  19. datetime LastAlertTime = D'01.01.1970';
  20. int LastAlertDirection = 0;
  21. double b1[];
  22. double b2[];
  23.  
  24. int init() {
  25. SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
  26. SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
  27. SetIndexArrow(1,233);
  28. SetIndexArrow(0,234);
  29. SetIndexBuffer(0,b1);
  30. SetIndexBuffer(1,b2);
  31.  
  32. return(0);
  33. }
  34. int start() {
  35. int counted_bars=IndicatorCounted();
  36. int k,i,j,limit,hhb,llb;
  37.  
  38. if (counted_bars<0) return(-1);
  39. if (counted_bars>0) counted_bars--;
  40. limit=Bars-counted_bars-1;
  41. limit=MathMax(limit,dist);
  42. if (limit<0) limit=0;
  43.  
  44.  
  45.  
  46.  
  47.  
  48. for (i=limit;i>=0;i--) {
  49. hhb = Highest(NULL,0,MODE_HIGH,dist,i-dist/2);
  50. llb = Lowest(NULL,0,MODE_LOW,dist,i-dist/2);
  51.  
  52. if (i==hhb) b1[i]=High[hhb]+iATR(NULL,0,10,i)*arrowPosition; else b1[i]=EMPTY_VALUE;
  53. if (i==llb) b2[i]=Low[llb] -iATR(NULL,0,10,i)*arrowPosition; else b2[i]=EMPTY_VALUE;
  54. }
  55. if (((TriggerCandle > 0) && (Time[0] > LastAlertTime)) || (TriggerCandle == 0))
  56. {
  57. string Text;
  58. // Up Arrow Alert
  59. if ((b1[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
  60. {
  61. Text = AlertText + "Up Arrow Buy Now: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - Up.";
  62. if (EnableNativeAlerts) Alert(Text);
  63. if (EnableEmailAlerts) SendMail(AlertEmailSubject + "Up Arrow Buy Now", Text);
  64. if (EnableSoundAlerts) PlaySound(SoundFileName);
  65. if (EnablePushAlerts) SendNotification(Text);
  66. LastAlertTime = Time[0];
  67. LastAlertDirection = 1;
  68.  
  69. }
  70. // Down Arrow Alert
  71. if ((b2[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
  72. {
  73. Text = AlertText + "Down Arrow Sell Now: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - Down.";
  74. if (EnableNativeAlerts) Alert(Text);
  75. if (EnableEmailAlerts) SendMail(AlertEmailSubject + "Down Arrow Sell Now", Text);
  76. if (EnableSoundAlerts) PlaySound(SoundFileName);
  77. if (EnablePushAlerts) SendNotification(Text);
  78. LastAlertTime = Time[0];
  79. LastAlertDirection = -1;
  80.  
  81. }
  82. }
  83. return(0);
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement