Advertisement
njengaz

Pinbar mql4 code

Jan 10th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1.  
  2.  
  3. #property indicator_chart_window
  4. #property indicator_buffers 2
  5. #property indicator_width1 0
  6. #property indicator_color1 Lime
  7. #property indicator_width2 0
  8. #property indicator_color2 Red
  9. extern int qual=6;
  10. extern int len=30;
  11. extern int Distance = 1;
  12. extern int Countbars=1000;
  13. input int TriggerCandle = 1;
  14. input bool EnableNativeAlerts = true;
  15. input bool EnableSoundAlerts = true;
  16. input bool EnableEmailAlerts = true;
  17. input string AlertEmailSubject = "";
  18. input string AlertText = "";
  19. input string SoundFileName = "alert.wav";
  20.  
  21. datetime LastAlertTime = D'01.01.1970';
  22. int LastAlertDirection = 0;
  23. double Up[];
  24. double Dn[];
  25. double point;
  26. double bs=0;
  27. double index=0;
  28. double bindex=0;
  29. double sindex=0;
  30. double length=0;
  31. double ret=0;
  32.  
  33. int init() {
  34. if(Digits==3 || Digits==5) {
  35. point=10*Point;
  36. }
  37. else{
  38. point=Point;
  39.  
  40. }
  41.  
  42. IndicatorBuffers(2);
  43. SetIndexStyle(0, DRAW_ARROW);
  44. SetIndexBuffer(0, Up);
  45. SetIndexArrow(0,108);
  46. SetIndexStyle(1, DRAW_ARROW);
  47.  
  48. SetIndexBuffer(1, Dn);
  49. SetIndexArrow(1,108);
  50.  
  51.  
  52.  
  53. return (0);
  54. }
  55.  
  56. int deinit() {
  57. return (0);
  58. }
  59.  
  60. int start() {
  61. bool TurnedUp = false;
  62. bool TurnedDown = false;
  63. double highest,lowest;
  64.  
  65. int i,limit,limit2;
  66. int counted_bars = IndicatorCounted();
  67. if(counted_bars < 0)
  68. return(-1);
  69.  
  70. limit=Countbars-counted_bars;
  71. if (i> limit2)
  72. limit2= i;
  73. if (limit2 <Countbars-1)
  74. limit =Countbars- 1;
  75.  
  76. for( i=limit; i>=0; i--) {
  77. if (Close[i]>Close[i+4]){
  78. bindex=bindex+1;
  79. }
  80. if(Close[i]<Close[i+4]){
  81. sindex=sindex+1;
  82. }
  83. ret=0;
  84. index=0;
  85.  
  86.  
  87. if ((bindex>qual) && (Close[i]<Open[i])&& (High[i]>=High[iHighest(Symbol(),0,MODE_HIGH,len,i+1)])) {
  88. index=1;
  89. bindex=0;
  90. ret=-1;
  91. }
  92. if ((sindex>qual) && (Close[i]>Open[i])&& (Low[i]<= Low[iLowest(Symbol(),0,MODE_LOW,len,i+1)])) {
  93. index=-1;
  94. sindex=0;
  95. ret=1;
  96. }
  97.  
  98. if (ret==1 && i!=0){
  99. Up[i]=Low[i]-Distance*point;
  100. }
  101.  
  102. if (ret==-1 && i!=0){
  103. Dn[i]=High[i]+Distance*point;
  104.  
  105. }
  106.  
  107. }
  108.  
  109. if (i> limit2)
  110. limit2= i;
  111.  
  112. if (((TriggerCandle > 0) && (Time[0] > LastAlertTime)) || (TriggerCandle == 0))
  113. {
  114. string Text;
  115. // Up Arrow Alert
  116. if (( Up[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
  117. {
  118. Text = AlertText + "ACT: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - ACT.";
  119. if (EnableNativeAlerts) Alert(Text);
  120. if (EnableEmailAlerts) SendMail(AlertEmailSubject + "up", Text);
  121. if (EnableSoundAlerts) PlaySound(SoundFileName);
  122. LastAlertTime = Time[0];
  123. LastAlertDirection = 1;
  124. }
  125. // Down Arrow Alert
  126. if ((Dn[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
  127. {
  128. Text = AlertText + "ACT: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - ACT .";
  129. if (EnableNativeAlerts) Alert(Text);
  130. if (EnableEmailAlerts) SendMail(AlertEmailSubject + "CCI Arrows Alert", Text);
  131. if (EnableSoundAlerts) PlaySound(SoundFileName);
  132. LastAlertTime = Time[0];
  133. LastAlertDirection = -1;
  134. }
  135. }
  136.  
  137. return (0);
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement