SHARE
TWEET

Untitled

a guest Mar 28th, 2017 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //+------------------------------------------------------------------+
  2. //|                                              StochWithPoints.mq4 |
  3. //|                                                                * |
  4. //+------------------------------------------------------------------+
  5. #property copyright "*"
  6. #property link      "*"
  7.  
  8. #property indicator_separate_window
  9. #property indicator_minimum -10
  10. #property indicator_maximum 110
  11. #property indicator_buffers 6
  12. #property indicator_color1 Yellow
  13. #property indicator_width1 1
  14. #property indicator_color2 RoyalBlue
  15. #property indicator_width2 3
  16. #property indicator_color3 OrangeRed
  17. #property indicator_width3 2
  18. #property indicator_color4 Lime
  19. #property indicator_width4 2
  20. #property indicator_color5 Red
  21. #property indicator_width5 0
  22. #property indicator_color6 Blue
  23. #property indicator_width6 0
  24. #property indicator_level1 10
  25. #property indicator_level2 30
  26. #property indicator_level3 70
  27. #property indicator_level4 90
  28. #property indicator_levelcolor DimGray
  29. #property indicator_levelstyle STYLE_SOLID
  30.  
  31. //---- input parameters
  32. extern int       K=10;//5;
  33. extern int       D=3;
  34. extern int       S=4;//3;
  35. extern int       Method=3;
  36. extern int       Price=1;
  37. extern int       MainHP=3;
  38. extern int       SignalHP=3;
  39. extern bool      DrawConfirmArrow=true;
  40. input int    TriggerCandle  = 1;
  41. input bool   EnableNativeAlerts = true;
  42. input bool   EnableSoundAlerts  = true;
  43. input bool   EnableEmailAlerts  = true;
  44. input string AlertEmailSubject  = "";
  45. input string AlertText      = "";
  46. input string SoundFileName  = "alert.wav";
  47.  
  48. datetime LastAlertTime = D'01.01.1970';
  49. int LastAlertDirection = 0;
  50.  
  51. //---- buffers
  52. double ExtMapBuffer1[];
  53. double ExtMapBuffer2[];
  54. double ExtMapBuffer3[];
  55. double ExtMapBuffer4[];
  56. double ExtMapBuffer5[];
  57. double ExtMapBuffer6[];
  58.  
  59. //+------------------------------------------------------------------+
  60. //| Custom indicator initialization function                         |
  61. //+------------------------------------------------------------------+
  62. int init()
  63.   {
  64. //---- indicators
  65.    SetIndexStyle(0,DRAW_LINE);
  66.    SetIndexBuffer(0,ExtMapBuffer1);
  67.    SetIndexLabel(0,NULL);
  68.    SetIndexStyle(1,DRAW_LINE);
  69.    SetIndexBuffer(1,ExtMapBuffer2);
  70.    SetIndexLabel(1,NULL);
  71.    SetIndexStyle(2,DRAW_ARROW);
  72.    SetIndexArrow(2,159);
  73.    SetIndexBuffer(2,ExtMapBuffer3);
  74.    SetIndexStyle(3,DRAW_ARROW);
  75.    SetIndexArrow(3,159);
  76.    SetIndexBuffer(3,ExtMapBuffer4);
  77.    
  78.    if (DrawConfirmArrow)
  79.    {
  80.    SetIndexStyle(4,DRAW_ARROW);
  81.    SetIndexArrow(4,234);//(4,159);
  82.    SetIndexBuffer(4,ExtMapBuffer5);
  83.    SetIndexStyle(5,DRAW_ARROW);
  84.    SetIndexArrow(5,233);//(5,159);
  85.    SetIndexBuffer(5,ExtMapBuffer6);
  86.    }
  87.      
  88.    SetIndexEmptyValue(5,0.0);    
  89.    SetIndexDrawBegin(0,K+D+S);
  90.    SetIndexDrawBegin(1,K+D+S);  
  91.    SetIndexDrawBegin(2,K+D+S);  
  92.    SetIndexDrawBegin(3,K+D+S);  
  93.    SetIndexDrawBegin(4,K+D+S);  
  94.    SetIndexDrawBegin(5,K+D+S);  
  95.    IndicatorShortName("S_p");
  96.    
  97. //----
  98.    return(0);
  99.   }
  100. //+------------------------------------------------------------------+
  101. //| Custom indicator deinitialization function                       |
  102. //+------------------------------------------------------------------+
  103. int deinit()
  104.   {
  105. //----
  106.    
  107. //----
  108.    return(0);
  109.   }
  110. //+------------------------------------------------------------------+
  111. //| Custom indicator iteration function                              |
  112. //+------------------------------------------------------------------+
  113. int start()
  114.   {
  115.    int limit=Bars-IndicatorCounted()-1;
  116.       for(int i=limit;i>=0;i--){
  117.          ExtMapBuffer1[i]=iStochastic(NULL,0,K,D,S,Method,Price,0,i);
  118.          ExtMapBuffer2[i]=iStochastic(NULL,0,K,D,S,Method,Price,1,i);        
  119.          
  120.          if(ArrayMaximum(ExtMapBuffer1,MainHP*2+1,i)==i+MainHP)
  121.          ExtMapBuffer3[i+MainHP]=ExtMapBuffer1[i+MainHP];
  122.          if(ArrayMinimum(ExtMapBuffer1,MainHP*2+1,i)==i+MainHP)
  123.          ExtMapBuffer4[i+MainHP]=ExtMapBuffer1[i+MainHP];    
  124.          
  125.          if(ArrayMaximum(ExtMapBuffer2,SignalHP*2+1,i)==i+SignalHP)
  126.          ExtMapBuffer5[i+SignalHP]=ExtMapBuffer2[i+SignalHP];
  127.          if(ArrayMinimum(ExtMapBuffer2,SignalHP*2+1,i)==i+SignalHP)
  128.          ExtMapBuffer6[i+SignalHP]=ExtMapBuffer2[i+SignalHP];            
  129.       }
  130.       if (((TriggerCandle > 0) && (Time[0] > LastAlertTime)) || (TriggerCandle == 0))
  131. {
  132.     string Text;
  133.     // Up Arrow Alert
  134.     if ((ExtMapBuffer5[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
  135.     {
  136.         Text = AlertText + "CCI Arrows: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - Up.";
  137.         if (EnableNativeAlerts) Alert(Text);
  138.         if (EnableEmailAlerts) SendMail(AlertEmailSubject + "CCI Arrows Alert", Text);
  139.         if (EnableSoundAlerts) PlaySound(SoundFileName);
  140.         LastAlertTime = Time[0];
  141.         LastAlertDirection = 1;
  142.     }
  143.     // Down Arrow Alert
  144.     if ((ExtMapBuffer6[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
  145.     {
  146.         Text = AlertText + "CCI Arrows: " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - Down.";
  147.         if (EnableNativeAlerts) Alert(Text);
  148.         if (EnableEmailAlerts) SendMail(AlertEmailSubject + "CCI Arrows Alert", Text);
  149.         if (EnableSoundAlerts) PlaySound(SoundFileName);
  150.         LastAlertTime = Time[0];
  151.         LastAlertDirection = -1;
  152.     }
  153. }
  154.    return(0);
  155.   }
  156. //+------------------------------------------------------------------+
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top