找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
首页论坛EAHub 外汇论坛
查看: 47|回复: 0

XAUUSD_Monitor_Dots

[复制链接]

4万

主题

54

回帖

4万

积分

管理员

积分
45954
发表于 2026-8-27 23:42:00 | 显示全部楼层 |阅读模式
//+------------------------------------------------------------------+
//|                                          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_color1  clrRed
#property indicator_color2  clrLime
#property indicator_color3  clrYellow

//--- 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);
}
//+------------------------------------------------------------------+
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|EAHub外汇论坛

GMT+8, 2026-10-9 18:13 , Processed in 0.103299 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表