Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+------------------------------------------------------------------+
- //| Sequence.mq5 |
- //| Henrique Vilela |
- //| http://vilela.one/ |
- //+------------------------------------------------------------------+
- #property copyright "Henrique Vilela"
- #property link "http://vilela.one/"
- #property version "1.00"
- #property indicator_chart_window
- #property indicator_buffers 3
- #property indicator_plots 3
- #property indicator_label1 "Sell"
- #property indicator_type1 DRAW_ARROW
- #property indicator_color1 clrRed
- #property indicator_style1 STYLE_SOLID
- #property indicator_width1 1
- #property indicator_label2 "Buy"
- #property indicator_type2 DRAW_ARROW
- #property indicator_color2 clrDodgerBlue
- #property indicator_style2 STYLE_SOLID
- #property indicator_width2 1
- double SellBuffer[];
- double BuyBuffer[];
- double SequenceBuffer[];
- input ushort Account=3; // Accountgem
- 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;
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- SetIndexBuffer(0,SellBuffer,INDICATOR_DATA);
- SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA);
- SetIndexBuffer(2,SequenceBuffer,INDICATOR_DATA);
- PlotIndexSetInteger(0,PLOT_ARROW,234);
- PlotIndexSetInteger(1,PLOT_ARROW,233);
- PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-10);
- PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,10);
- return(INIT_SUCCEEDED);
- }
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- int OnCalculate(const int rates_total,
- const int prev_calculated,
- const datetime &time[],
- const double &open[],
- const double &high[],
- const double &low[],
- const double &close[],
- const long &tick_volume[],
- const long &volume[],
- const int &spread[])
- {
- for(int i=MathMax(1,prev_calculated-1); i<rates_total; i++)
- {
- if(close[i]>open[i]) // Positivo
- {
- if(close[i-1]<open[i-1]) // Anterior Positivo
- {
- SequenceBuffer[i]=SequenceBuffer[i-1]+1;
- }
- else // Anterior Negativo
- {
- SequenceBuffer[i]=0;
- }
- }
- else if(close[i]<open[i]) // Negativo
- {
- if(close[i-1]>open[i-1]) // // Anterior Negativo
- {
- SequenceBuffer[i]=SequenceBuffer[i-1]+1;
- }
- else // Anterior Positivo
- {
- SequenceBuffer[i]=0;
- }
- }
- else // Doji (nem positivo, nem negativo)
- {
- SequenceBuffer[i]=0;
- }
- BuyBuffer[i]= SequenceBuffer[i] == Account ? low[i] : EMPTY_VALUE;
- SellBuffer[i] = -SequenceBuffer[i] == Account ? high[i] : EMPTY_VALUE;
- }
- if (((TriggerCandle > 0) && (time[rates_total - 1] > LastAlertTime)) || (TriggerCandle == 0))
- {
- string Text;
- if (BuyBuffer == Account)
- {
- Text = AlertText + "CCI Arrows: " + Symbol() + " - " + EnumToString(Period()) + " - Up.";
- if (EnableNativeAlerts) Alert(Text);
- if (EnableEmailAlerts) SendMail(AlertEmailSubject + "CCI Arrows Alert", Text);
- if (EnableSoundAlerts) PlaySound(SoundFileName);
- if (EnablePushAlerts) SendNotification(Text);
- LastAlertTime = time[rates_total - 1];
- LastAlertDirection = 1;
- }
- }
- return(rates_total);
- }
- //+------------------------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement