求助!自己编写的mt5波幅指标,总是显示在副图上,无法显示在主图。求助大神帮忙看下怎么回事,跪谢!

 
//+------------------------------------------------------------------+
//|                                                      WaveRange.mq5|
//|                        Copyright 2024, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "2024, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window false // 将指标显示在主图表上
#property indicator_buffers 1
#property indicator_plots   1

input ENUM_TIMEFRAMES Period = PERIOD_M30; // 时间周期

// 输入参数
input color WaveColor = clrBlue; // 波幅线颜色
input int WaveWidth = 1; // 波幅线宽度

// 缓冲区
double WaveBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   // 设置指标线属性
   SetIndexBuffer(0, WaveBuffer);
   PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_LINE);
   PlotIndexSetInteger(0, PLOT_LINE_COLOR, WaveColor);
   PlotIndexSetInteger(0, PLOT_LINE_WIDTH, WaveWidth);

   // 设置指标显示在主图表上
   ChartSetInteger(0, CHART_FOREGROUND,true);  // 显示在前景

   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
{
   int limit = rates_total - 1;
   if (prev_calculated > 0)
      limit = prev_calculated - 1;

   for (int i = limit; i >= 0; i--)
   {
      // 计算波幅
      double range = MathAbs(open[i] - close[i]);

      // 将波幅保存到缓冲区中
      WaveBuffer[i] = range;
   }

   return(rates_total);
}
 
如图
附加的文件:
uto.png  39 kb
 
#property indicator_chart_window


#property indicator_separate_window false

兩個指令換一下

你這個計算數值很小 放在主圖上看不到啥東西的

 
Hung Wen Lin #:


兩個指令換一下

你這個計算數值很小 放在主圖上看不到啥東西的

谢谢
原因: