Advertisement
keine_rente

Untitled

Mar 18th, 2020
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. //+------------------------------------------------------------------+
  2. //| True Strength Index.mq5 |
  3. //| Copyright 2009, MetaQuotes Software Corp. |
  4. //| http://www.mql5.com |
  5. //+------------------------------------------------------------------+
  6. #property copyright "2009, MetaQuotes Software Corp."
  7. #property link "http://www.mql5.com"
  8. #property version "1.00"
  9. #property indicator_separate_window
  10. #property indicator_buffers 1
  11. #property indicator_plots 1
  12. #property indicator_type1 DRAW_LINE
  13. #property indicator_color1 Red
  14.  
  15. input int MAPeriod = 5;
  16. input int MAShift = 0;
  17. input int TriggerCandle = 1;
  18. input bool EnableNativeAlerts = true;
  19. input bool EnableSoundAlerts = true;
  20. input bool EnableEmailAlerts = true;
  21. input bool EnablePushAlerts = true;
  22. input string AlertEmailSubject = "";
  23. input string AlertText = "";
  24. input string SoundFileName = "alert.wav";
  25.  
  26. datetime LastAlertTime = D'01.01.1970';
  27. int LastAlertDirection = 0;
  28.  
  29. double ExtLineBuffer[];
  30. //+------------------------------------------------------------------+
  31. //| Custom indicator initialization function |
  32. //+------------------------------------------------------------------+
  33. void OnInit()
  34. {
  35. SetIndexBuffer(0, ExtLineBuffer, INDICATOR_DATA);
  36. PlotIndexSetInteger(0, PLOT_SHIFT, MAShift);
  37. PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, MAPeriod - 1);
  38. }
  39. //+------------------------------------------------------------------+
  40. //| Custom indicator iteration function |
  41. //+------------------------------------------------------------------+
  42. int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[])
  43. {
  44. if (rates_total < MAPeriod - 1)
  45. return(0);
  46.  
  47. int first, bar, iii;
  48. double Sum, SMA;
  49.  
  50. if (prev_calculated == 0)
  51. first = MAPeriod - 1 + begin;
  52. else first = prev_calculated - 1;
  53.  
  54. for(bar = first; bar < rates_total; bar++)
  55. {
  56. Sum = 0.0;
  57. for(iii = 0; iii < MAPeriod; iii++)
  58. Sum += price[bar - iii];
  59.  
  60. SMA = Sum / MAPeriod;
  61. SMA=SMA-price[bar];
  62.  
  63. ExtLineBuffer[bar] = SMA;
  64. }
  65. }
  66.  
  67.  
  68. // Alert System generated
  69.  
  70.  
  71.  
  72. if (((TriggerCandle > 0) && (time[rates_total - 1] > LastAlertTime)) || (TriggerCandle == 0))
  73. {
  74. string Text;
  75. // Above Zero Alert
  76. if (((ExtLineBuffer[rates_total - 1 - TriggerCandle] > 0) && (ExtLineBuffer[rates_total - 2 - TriggerCandle] <= 0)) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
  77. {
  78. Text = AlertText + "ExtLineBuffer: " + Symbol() + " - " + EnumToString(Period()) + " - Above Zero.";
  79. if (EnableNativeAlerts) Alert(Text);
  80. if (EnableEmailAlerts) SendMail(AlertEmailSubject + "ExtLineBuffer Alert", Text);
  81. if (EnableSoundAlerts) PlaySound(SoundFileName);
  82. if (EnablePushAlerts) SendNotification(Text);
  83. LastAlertTime = time[rates_total - 1];
  84. LastAlertDirection = 1;
  85. }
  86. // Below Zero Alert
  87. if (((ExtLineBuffer[rates_total - 1 - TriggerCandle] < 0) && (ExtLineBuffer[rates_total - 2 - TriggerCandle] >= 0)) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
  88. {
  89. Text = AlertText + "ExtLineBuffer: " + Symbol() + " - " + EnumToString(Period()) + " - Below Zero.";
  90. if (EnableNativeAlerts) Alert(Text);
  91. if (EnableEmailAlerts) SendMail(AlertEmailSubject + "ExtLineBuffer", Text);
  92. if (EnableSoundAlerts) PlaySound(SoundFileName);
  93. if (EnablePushAlerts) SendNotification(Text);
  94. LastAlertTime = time[rates_total - 1];
  95. LastAlertDirection = -1;
  96. }
  97.  
  98.  
  99.  
  100. return(rates_total);
  101. }
  102.  
  103.  
  104. ---> 'if' - expressions are not allowed on a global scope Row 72 col 2 if (((TriggerCandle > 0) && (time[rates_total - 1] > LastAlertTime)) || (TriggerCandle == 0))
  105. ---> '}' - not all control paths return a value Row 65 col 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement