Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+------------------------------------------------------------------+
- //| True Strength Index.mq5 |
- //| Copyright 2009, MetaQuotes Software Corp. |
- //| http://www.mql5.com |
- //+------------------------------------------------------------------+
- #property copyright "2009, MetaQuotes Software Corp."
- #property link "http://www.mql5.com"
- #property version "1.00"
- #property indicator_separate_window
- #property indicator_buffers 1
- #property indicator_plots 1
- #property indicator_type1 DRAW_LINE
- #property indicator_color1 Red
- input int MAPeriod = 5;
- input int MAShift = 0;
- 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 ExtLineBuffer[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- void OnInit()
- {
- SetIndexBuffer(0, ExtLineBuffer, INDICATOR_DATA);
- PlotIndexSetInteger(0, PLOT_SHIFT, MAShift);
- PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, MAPeriod - 1);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[])
- {
- if (rates_total < MAPeriod - 1)
- return(0);
- int first, bar, iii;
- double Sum, SMA;
- if (prev_calculated == 0)
- first = MAPeriod - 1 + begin;
- else first = prev_calculated - 1;
- for(bar = first; bar < rates_total; bar++)
- {
- Sum = 0.0;
- for(iii = 0; iii < MAPeriod; iii++)
- Sum += price[bar - iii];
- SMA = Sum / MAPeriod;
- SMA=SMA-price[bar];
- ExtLineBuffer[bar] = SMA;
- }
- }
- // Alert System generated
- if (((TriggerCandle > 0) && (time[rates_total - 1] > LastAlertTime)) || (TriggerCandle == 0))
- {
- string Text;
- // Above Zero Alert
- if (((ExtLineBuffer[rates_total - 1 - TriggerCandle] > 0) && (ExtLineBuffer[rates_total - 2 - TriggerCandle] <= 0)) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
- {
- Text = AlertText + "ExtLineBuffer: " + Symbol() + " - " + EnumToString(Period()) + " - Above Zero.";
- if (EnableNativeAlerts) Alert(Text);
- if (EnableEmailAlerts) SendMail(AlertEmailSubject + "ExtLineBuffer Alert", Text);
- if (EnableSoundAlerts) PlaySound(SoundFileName);
- if (EnablePushAlerts) SendNotification(Text);
- LastAlertTime = time[rates_total - 1];
- LastAlertDirection = 1;
- }
- // Below Zero Alert
- if (((ExtLineBuffer[rates_total - 1 - TriggerCandle] < 0) && (ExtLineBuffer[rates_total - 2 - TriggerCandle] >= 0)) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
- {
- Text = AlertText + "ExtLineBuffer: " + Symbol() + " - " + EnumToString(Period()) + " - Below Zero.";
- if (EnableNativeAlerts) Alert(Text);
- if (EnableEmailAlerts) SendMail(AlertEmailSubject + "ExtLineBuffer", Text);
- if (EnableSoundAlerts) PlaySound(SoundFileName);
- if (EnablePushAlerts) SendNotification(Text);
- LastAlertTime = time[rates_total - 1];
- LastAlertDirection = -1;
- }
- return(rates_total);
- }
- ---> 'if' - expressions are not allowed on a global scope Row 72 col 2 if (((TriggerCandle > 0) && (time[rates_total - 1] > LastAlertTime)) || (TriggerCandle == 0))
- ---> '}' - not all control paths return a value Row 65 col 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement