| 发表于 2026-8-14 12:22:14 | 显示全部楼层 |复制链接
  1. //+------------------------------------------------------------------+
  2. //|                                          XAUUSD_Monitor_Dots.mq4 |
  3. //|                     Range / High Volatility / Drop Monitor       |
  4. //+------------------------------------------------------------------+
  5. #property copyright "XAUUSD Monitor"
  6. #property version   "1.10"
  7. #property strict
  8. #property indicator_chart_window
  9. #property indicator_buffers 3
  10. #property indicator_color1  clrRed
  11. #property indicator_color2  clrLime
  12. #property indicator_color3  clrYellow
  13. //--- inputs
  14. input int    ATR_Period        = 14;
  15. input double RangeMultiplier   = 0.55;   // Red   - Range / consolidation
  16. input double HighVolMultiplier = 1.60;   // Green - High volatility
  17. input double DropMultiplier    = 1.10;   // Yellow- Strong directional move
  18. input int    ArrowCode         = 159;    // Wingdings solid circle
  19. input int    ArrowSize         = 2;
  20. input bool   OnlyClosedBars    = true;   // true = safer for EA
  21. //--- buffers
  22. double RangeBuffer[];   // Buffer 0 - Red
  23. double HighVolBuffer[]; // Buffer 1 - Green
  24. double DropBuffer[];    // Buffer 2 - Yellow
  25. //+------------------------------------------------------------------+
  26. int OnInit()
  27. {
  28.    SetIndexBuffer(0, RangeBuffer);
  29.    SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, ArrowSize);
  30.    SetIndexArrow(0, ArrowCode);
  31.    SetIndexLabel(0, "Range");
  32.    SetIndexBuffer(1, HighVolBuffer);
  33.    SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, ArrowSize);
  34.    SetIndexArrow(1, ArrowCode);
  35.    SetIndexLabel(1, "High Volatility");
  36.    SetIndexBuffer(2, DropBuffer);
  37.    SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, ArrowSize);
  38.    SetIndexArrow(2, ArrowCode);
  39.    SetIndexLabel(2, "Drop / Spike");
  40.    IndicatorShortName("XAUUSD Monitor");
  41.    return(INIT_SUCCEEDED);
  42. }
  43. //+------------------------------------------------------------------+
  44. int OnCalculate(const int rates_total,
  45.                 const int prev_calculated,
  46.                 const datetime &time[],
  47.                 const double &open[],
  48.                 const double &high[],
  49.                 const double &low[],
  50.                 const double &close[],
  51.                 const long &tick_volume[],
  52.                 const long &volume[],
  53.                 const int &spread[])
  54. {
  55.    if(rates_total < ATR_Period + 5) return(0);
  56.    int limit = (prev_calculated == 0) ? rates_total - ATR_Period - 2
  57.                                      : rates_total - prev_calculated + 1;
  58.    for(int i = limit; i >= 0; i--)
  59.    {
  60.       // Skip current forming bar if requested
  61.       if(OnlyClosedBars && i == 0)
  62.       {
  63.          RangeBuffer   = EMPTY_VALUE;
  64.          HighVolBuffer = EMPTY_VALUE;
  65.          DropBuffer    = EMPTY_VALUE;
  66.          continue;
  67.       }
  68.       double atr = iATR(NULL, 0, ATR_Period, i);
  69.       if(atr <= 0) continue;
  70.       double barRange = high - low;
  71.       double barBody  = MathAbs(open - close);
  72.       // Clear previous values
  73.       RangeBuffer   = EMPTY_VALUE;
  74.       HighVolBuffer = EMPTY_VALUE;
  75.       DropBuffer    = EMPTY_VALUE;
  76.       // Priority: Drop > HighVol > Range
  77.       if(barBody > DropMultiplier * atr)
  78.       {
  79.          DropBuffer = (close >= open) ? low - atr*0.25 : high + atr*0.25;
  80.       }
  81.       else if(barRange > HighVolMultiplier * atr)
  82.       {
  83.          HighVolBuffer = (close >= open) ? low - atr*0.15 : high + atr*0.15;
  84.       }
  85.       else if(barRange < RangeMultiplier * atr)
  86.       {
  87.          RangeBuffer = (high + low) / 2.0;
  88.       }
  89.    }
  90.    return(rates_total);
  91. }
  92. //+------------------------------------------------------------------+
复制代码

indicator

indicator

Custom indicator

Custom indicator
举报

评论 使用道具

精彩评论2

ujukkiii
D
| 发表于 2026-8-15 00:33:49 | 显示全部楼层
下载试试
举报

点赞 评论 使用道具

爱交易
DD
| 发表于 2026-8-15 10:25:05 | 显示全部楼层
源码直接贴。。。感谢。。
举报

点赞 评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册