tonyxx123 发表于 2026-8-14 12:22:14

XAUUSD_Monitor_Dots

//+------------------------------------------------------------------+
//|                                          XAUUSD_Monitor_Dots.mq4 |
//|                     Range / High Volatility / Drop Monitor       |
//+------------------------------------------------------------------+
#property copyright "XAUUSD Monitor"
#property version   "1.10"
#property strict
#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1clrRed
#property indicator_color2clrLime
#property indicator_color3clrYellow

//--- inputs
input int    ATR_Period      = 14;
input double RangeMultiplier   = 0.55;   // Red   - Range / consolidation
input double HighVolMultiplier = 1.60;   // Green - High volatility
input double DropMultiplier    = 1.10;   // Yellow- Strong directional move
input int    ArrowCode         = 159;    // Wingdings solid circle
input int    ArrowSize         = 2;
input bool   OnlyClosedBars    = true;   // true = safer for EA

//--- buffers
double RangeBuffer[];   // Buffer 0 - Red
double HighVolBuffer[]; // Buffer 1 - Green
double DropBuffer[];    // Buffer 2 - Yellow

//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0, RangeBuffer);
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, ArrowSize);
   SetIndexArrow(0, ArrowCode);
   SetIndexLabel(0, "Range");

   SetIndexBuffer(1, HighVolBuffer);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, ArrowSize);
   SetIndexArrow(1, ArrowCode);
   SetIndexLabel(1, "High Volatility");

   SetIndexBuffer(2, DropBuffer);
   SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, ArrowSize);
   SetIndexArrow(2, ArrowCode);
   SetIndexLabel(2, "Drop / Spike");

   IndicatorShortName("XAUUSD Monitor");
   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[])
{
   if(rates_total < ATR_Period + 5) return(0);

   int limit = (prev_calculated == 0) ? rates_total - ATR_Period - 2
                                     : rates_total - prev_calculated + 1;

   for(int i = limit; i >= 0; i--)
   {
      // Skip current forming bar if requested
      if(OnlyClosedBars && i == 0)
      {
         RangeBuffer   = EMPTY_VALUE;
         HighVolBuffer = EMPTY_VALUE;
         DropBuffer    = EMPTY_VALUE;
         continue;
      }

      double atr = iATR(NULL, 0, ATR_Period, i);
      if(atr <= 0) continue;

      double barRange = high - low;
      double barBody= MathAbs(open - close);

      // Clear previous values
      RangeBuffer   = EMPTY_VALUE;
      HighVolBuffer = EMPTY_VALUE;
      DropBuffer    = EMPTY_VALUE;

      // Priority: Drop > HighVol > Range
      if(barBody > DropMultiplier * atr)
      {
         DropBuffer = (close >= open) ? low - atr*0.25 : high + atr*0.25;
      }
      else if(barRange > HighVolMultiplier * atr)
      {
         HighVolBuffer = (close >= open) ? low - atr*0.15 : high + atr*0.15;
      }
      else if(barRange < RangeMultiplier * atr)
      {
         RangeBuffer = (high + low) / 2.0;
      }
   }
   return(rates_total);
}
//+------------------------------------------------------------------+

ujukkiii 发表于 2026-8-15 00:33:49

下载试试

爱交易 发表于 2026-8-15 10:25:05

源码直接贴。。。感谢。。

lvcha 发表于 2026-10-4 16:10:35

蹲个坑顺便看下,观点比较中肯,比一味叫好的帖子强多了。

lvcha 发表于 2026-10-4 17:06:45

感谢无私分享,论坛就需要这种帖子。
页: [1]
查看完整版本: XAUUSD_Monitor_Dots