Support and Resistance Breakout Arrows【支撑阻力突破箭头】

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:01 回复:0 关注量:210
USDJPYH1.png

  1. //+------------------------------------------------------------------+
  2. //|                                          Support and Resistance  |
  3. //|                                  Copyright ?2004 Barry Stander  |
  4. //|                           Arrows added by Lennoi Anderson, 2015  |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright ?2004 Barry Stander; Arrow alerts by Lennoi Anderson, 2015."
  7. #property indicator_chart_window
  8. #property indicator_buffers 4
  9. #property indicator_color1 Blue
  10. #property indicator_color2 Red
  11. #property indicator_color3 Blue
  12. #property indicator_color4 Magenta
  13. #property indicator_width3 2
  14. #property indicator_width4 2

  15. extern bool RSICCI_Filter = FALSE;
  16. extern double RSIPeriod = 14;
  17. extern double RSIOverbought = 75;
  18. extern double RSIOversold = 25;
  19. extern double CCIPeriod = 14;
  20. extern double CCIBuyLevel = 50;
  21. extern double CCISellLevel = -50;
  22. extern int SignalDots = 3;
  23. extern bool alerts = TRUE;
  24. extern bool ApplyToClose = TRUE;
  25. extern int BarCount = 10000;

  26. bool HighBreakout = FALSE;
  27. bool HighBreakPending = FALSE;        
  28. bool LowBreakout = FALSE;
  29. bool LowBreakPending = FALSE;
  30. double LastResistance = 0;
  31. double LastSupport = 0;
  32. double alertBar = 0;
  33. //---- buffers
  34. double v1[];
  35. double v2[];
  36. double BreakUp[];
  37. double BreakDown[];
  38. double val1;
  39. double val2;
  40. int counter1;
  41. int counter2;
  42. //+------------------------------------------------------------------+
  43. //|                                                                  |
  44. //+------------------------------------------------------------------+  
  45. int init()
  46. {
  47. //---- drawing settings
  48.    SetIndexArrow(0, 119);
  49.    SetIndexArrow(1, 119);
  50. //----  
  51.    SetIndexStyle(0, DRAW_ARROW, STYLE_DOT, 0, Red);
  52.    //SetIndexDrawBegin(0, i-1);
  53.    SetIndexBuffer(0, v1);
  54.    SetIndexLabel(0, "Resistance");
  55. //----   
  56.    SetIndexStyle(1, DRAW_ARROW, STYLE_DOT, 0, Blue);
  57.    //SetIndexDrawBegin(1, i-1);
  58.    SetIndexBuffer(1, v2);
  59.    SetIndexLabel(1, "Support");
  60. //----
  61.    SetIndexStyle(2, DRAW_ARROW, EMPTY, 2);
  62.    SetIndexArrow(2, 233);
  63.    SetIndexBuffer(2, BreakUp);
  64. //----   
  65.    SetIndexStyle(3, DRAW_ARROW, EMPTY, 2);
  66.    SetIndexArrow(3, 234);
  67.    SetIndexBuffer(3, BreakDown);
  68.    return(0);
  69. }
  70. //+------------------------------------------------------------------+
  71. int start()
  72. {   
  73. //----
  74.    for(int i = BarCount; i >=0; i--)
  75.    {   
  76.        val1 = iFractals(NULL, 0, MODE_UPPER, i);
  77.        //----
  78.        if(val1 > 0)
  79.        {
  80.            v1[i] = High[i];
  81.            counter1 = 1;         
  82.        }
  83.        else
  84.        {
  85.            v1[i] = v1[i+1];
  86.            counter1++;           
  87.        }
  88.        val2 = iFractals(NULL, 0, MODE_LOWER, i);
  89.        //----
  90.        if(val2 > 0)
  91.        {
  92.            v2[i] = Low[i];
  93.            counter2 = 1;     
  94.        }
  95.        else
  96.        {
  97.            v2[i] = v2[i+1];
  98.            counter2++;        
  99.        }
  100.                     
  101.        if (v1[i] != LastResistance) { HighBreakPending = True; LastResistance = v1[i]; }
  102.        if (v2[i] != LastSupport) { LowBreakPending = True; LastSupport = v2[i]; }  
  103.                   
  104.        if (HighBreakPending && Close[i] > v1[i] && (!RSICCI_Filter || (RSICCI_Filter && iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i) < RSIOverbought &&
  105.            iCCI(Symbol(), NULL, CCIPeriod, PRICE_CLOSE, i) > CCIBuyLevel)) && counter1 >= SignalDots) HighBreakout = TRUE;
  106.        if (LowBreakPending && Close[i] < v2[i] && (!RSICCI_Filter || (RSICCI_Filter && iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i) > RSIOversold &&
  107.            iCCI(Symbol(), NULL, CCIPeriod, PRICE_CLOSE, i) < CCISellLevel)) && counter2 >= SignalDots) LowBreakout = TRUE;
  108.            
  109.        if (ApplyToClose) int alertCandle = 1; else alertCandle = 0;         
  110.       
  111.        if (HighBreakout)
  112.        {         
  113.          if (i >= alertCandle) BreakUp[i] = Low[i]-10*Point;
  114.          if (alerts && i == alertCandle && Bars > alertBar)
  115.          {
  116.            alert(Symbol(), " M", Period(), ": Resistance Breakout: BUY");
  117.            alertBar = Bars;
  118.          }
  119.          HighBreakout = False;
  120.          HighBreakPending = False;
  121.        } else
  122.        if (LowBreakout)
  123.        {
  124.          if (i >= alertCandle) BreakDown[i] = High[i]+10*Point;              
  125.          if (alerts && i==alertCandle && Bars>alertBar)
  126.          {  
  127.            alert(Symbol(), " M", Period(), ": Support Breakout: SELL");
  128.            alertBar = Bars;
  129.          }
  130.          LowBreakout = False;
  131.          LowBreakPending = False;
  132.        }   
  133.    }  
  134.    return(0);
  135. }
打赏