SHARE
TWEET

Untitled

Masternook Jul 1st, 2018 165 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //+------------------------------------------------------------------+
  2. //|                                                    Sequence.mq5 |
  3. //|                                                  Henrique Vilela |
  4. //|                                               http://vilela.one/ |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Henrique Vilela"
  7. #property link      "http://vilela.one/"
  8. #property version   "1.00"
  9.  
  10. #property indicator_chart_window
  11.  
  12. #property indicator_buffers 3
  13. #property indicator_plots   3
  14.  
  15. #property indicator_label1  "Sell"
  16. #property indicator_type1   DRAW_ARROW
  17. #property indicator_color1  clrRed
  18. #property indicator_style1  STYLE_SOLID
  19. #property indicator_width1  1
  20.  
  21. #property indicator_label2  "Buy"
  22. #property indicator_type2   DRAW_ARROW
  23. #property indicator_color2  clrDodgerBlue
  24. #property indicator_style2  STYLE_SOLID
  25. #property indicator_width2  1
  26.  
  27. double         SellBuffer[];
  28. double         BuyBuffer[];
  29.  
  30. double         SequenceBuffer[];
  31.  
  32. input ushort   Account=3; // Accountgem
  33.  
  34. input int    TriggerCandle  = 1;
  35. input bool   EnableNativeAlerts = true;
  36. input bool   EnableSoundAlerts  = true;
  37. input bool   EnableEmailAlerts  = true;
  38. input bool   EnablePushAlerts  = true;
  39. input string AlertEmailSubject  = "";
  40. input string AlertText      = "";
  41. input string SoundFileName  = "alert.wav";
  42.  
  43. datetime LastAlertTime = D'01.01.1970';
  44. int LastAlertDirection = 0;
  45.  
  46.  
  47. //+------------------------------------------------------------------+
  48. //|                                                                  |
  49. //+------------------------------------------------------------------+
  50. int OnInit()
  51.   {
  52.    SetIndexBuffer(0,SellBuffer,INDICATOR_DATA);
  53.    SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA);
  54.    SetIndexBuffer(2,SequenceBuffer,INDICATOR_DATA);
  55.  
  56.    PlotIndexSetInteger(0,PLOT_ARROW,234);
  57.    PlotIndexSetInteger(1,PLOT_ARROW,233);
  58.  
  59.    PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-10);
  60.    PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,10);
  61.  
  62.    return(INIT_SUCCEEDED);
  63.   }
  64. //+------------------------------------------------------------------+
  65. //|                                                                  |
  66. //+------------------------------------------------------------------+
  67. int OnCalculate(const int rates_total,
  68.                 const int prev_calculated,
  69.                 const datetime &time[],
  70.                 const double &open[],
  71.                 const double &high[],
  72.                 const double &low[],
  73.                 const double &close[],
  74.                 const long &tick_volume[],
  75.                 const long &volume[],
  76.                 const int &spread[])
  77.   {
  78.    for(int i=MathMax(1,prev_calculated-1); i<rates_total; i++)
  79.      {
  80.       if(close[i]>open[i]) // Positivo
  81.         {
  82.          
  83.          if(close[i-1]<open[i-1]) // Anterior Positivo
  84.            {
  85.             SequenceBuffer[i]=SequenceBuffer[i-1]+1;
  86.            }
  87.          else  // Anterior Negativo
  88.            {
  89.             SequenceBuffer[i]=0;
  90.            }
  91.         }
  92.       else if(close[i]<open[i]) // Negativo
  93.         {
  94.          if(close[i-1]>open[i-1]) //  // Anterior Negativo
  95.            {
  96.             SequenceBuffer[i]=SequenceBuffer[i-1]+1;
  97.            }
  98.          else  // Anterior Positivo
  99.            {
  100.             SequenceBuffer[i]=0;
  101.            }
  102.         }
  103.       else // Doji (nem positivo, nem negativo)
  104.         {
  105.          SequenceBuffer[i]=0;
  106.         }
  107.  
  108.       BuyBuffer[i]= SequenceBuffer[i] == Account ? low[i] : EMPTY_VALUE;
  109.       SellBuffer[i] = -SequenceBuffer[i] == Account ? high[i] : EMPTY_VALUE;
  110.       }
  111.  
  112.  
  113.    if (((TriggerCandle > 0) && (time[rates_total - 1] > LastAlertTime)) || (TriggerCandle == 0))
  114. {
  115.  
  116.     string Text;
  117.  
  118.     if (BuyBuffer == Account)
  119.     {
  120.         Text = AlertText + "CCI Arrows: " + Symbol() + " - " + EnumToString(Period()) + " - Up.";
  121.         if (EnableNativeAlerts) Alert(Text);
  122.         if (EnableEmailAlerts) SendMail(AlertEmailSubject + "CCI Arrows Alert", Text);
  123.         if (EnableSoundAlerts) PlaySound(SoundFileName);
  124.         if (EnablePushAlerts) SendNotification(Text);
  125.         LastAlertTime = time[rates_total - 1];
  126.         LastAlertDirection = 1;
  127.     }
  128. }
  129.  
  130.    return(rates_total);
  131.   }
  132. //+------------------------------------------------------------------+
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top