指标: MACD 背离 - 页 5

 
Alain Verleyen:

你没抓住重点。你提到的帖子是关于如何从 EA 中获取信号,显然,仅获取最后两根蜡烛的值是不可能的,你需要第三根蜡烛的值。

不可能有早期信号,因为要检测背离,你需要一个峰值/谷值,为此你需要一个额外的收盘蜡烛。因此,当蜡烛 0 刚刚打开时,意味着蜡烛 1 已经关闭,这样就可以确认蜡烛 2 的峰值/谷底。如果有人想修改指标,使用未经确认的峰/谷来获得早期信号,也是可以做到的,但我不会提供帮助,因为这是一个坏主意,因为你会得到很多坏信号。

可以做的是在蜡烛 1 甚至蜡烛 0 上绘制信号,但这不会改变什么,我决定在实际显示峰/谷的蜡烛上绘制信号。

我修改了代码,你是对的。在实际背离之前,你会得到错误的移动。感谢您在这方面花费的时间。
 
Alain Verleyen:

你没抓住重点。你提到的帖子是关于如何从 EA 中获取信号,显然,仅获取最后两根蜡烛的值是不可能的,你需要第三根蜡烛的值。

不可能有早期信号,因为要检测背离,你需要一个峰值/谷值,为此你需要一个额外的收盘蜡烛。因此,当蜡烛 0 刚刚打开时,意味着蜡烛 1 已经关闭,这样就可以确认蜡烛 2 的峰值/谷底。如果有人想修改指标,使用未经确认的峰/谷来获得早期信号,也是可以做到的,但我不会提供帮助,因为这是一个坏主意,因为你会得到很多坏信号。

可以做的是在蜡烛 1 甚至蜡烛 0 上绘制信号,但这不会改变什么,我决定在实际显示峰/谷的蜡烛上绘制信号。

你可能还忽略了一点。

在 renko 图表中,当前条形图(大部分)已经关闭,因此您需要少一根蜡烛。还是我遗漏了什么?

 
你好,Alain,非常好的指示器,即使不调整设置也能很好地工作。有提示功能是件好事,但我还缺少一件事,那就是向我的手机发送推送通知的 功能。弹出警报上出现的相同信息可以发送到我的手机上。你们能添加这个功能吗?那就太感谢您了。
 
谢谢阿兰,这是一个很好的指标
 

关于交易、自动交易系统和测试交易策略的论坛

macd divegence

eneza peter mkiramweni, 2021.09.12 12:26

您好,请帮助我使用这个指标,它在三格后显示警报,我想在一格后立即显示警报。


//+------------------------------------------------------------------+
//|MACD_Divergence.mq5
//|Alain Verleyen | |
//|http://www.alamga.be ||
//+------------------------------------------------------------------+
#property copyright     "Alain Verleyen (mql5) - Original author FX5 (mql4)"
#property link          "http://codebase.mql4.com/1115"
#property version       "1.01"
#property description   "The original indicator was totally rewrite to improve performance and"
#property description   "to correct a little bug. Also it's more funny that simply converting it."

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots   4

//--- 图 1:看涨 
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrGreen
#property indicator_label1  "Bullish divergence"
//--- 图 2:看跌
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrRed
#property indicator_label2  "Bearish divergence"
//--- 图 3:MACD 主图
#property indicator_type3   DRAW_LINE
#property indicator_style3  STYLE_SOLID
#property indicator_width3   2
#property indicator_color3  clrMagenta
#property indicator_label3  "Main"
//--- 图 4:MACD 信号
#property indicator_type4   DRAW_LINE
#property indicator_style4  STYLE_SOLID
#property indicator_width4   1
#property indicator_color4  clrNONE
#property indicator_label4  "Signal"
//--- 输入参数
input string s1="-----------------------------------------------";      // ----------- MACD 设置 ----------------------
input int    fastEMA                 = 12;
input int    slowEMA                 = 26;
input int    signalSMA               = 9;
input string s2="-----------------------------------------------";      // ----------- 指标设置 -----------------
input bool   drawIndicatorTrendLines = true;
input bool   drawPriceTrendLines     = true;
input bool   displayAlert            = true;
//--- 常量
#define  OBJECT_PREFIX       "MACD_DivergenceLine"
#define  ARROWS_DISPLACEMENT 0.0001
//--- 缓冲区
double bullishDivergence[];
double bearishDivergence[];
double macdBuffer[];
double signalBuffer[];
//--- 手柄
int    macdHandle=INVALID_HANDLE;
//--- 全局变量
static datetime lastAlertTime;
//+------------------------------------------------------------------+
//| 自定义指示器初始化函数
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 指标句柄 
   macdHandle=iMACD(NULL,0,fastEMA,slowEMA,signalSMA,PRICE_CLOSE);
   if(macdHandle==INVALID_HANDLE)
     {
      Print("The iMACD handle is not created: Error ",GetLastError());
      return(INIT_FAILED);
     }
//--- 指示器缓冲区映射
   SetIndexBuffer(0,bullishDivergence);
   SetIndexBuffer(1,bearishDivergence);
   SetIndexBuffer(2,macdBuffer);
   SetIndexBuffer(3,signalBuffer);
//--- 箭头代码见http://www.mql5.com/en/docs/constants/objectconstants/wingdings
   PlotIndexSetInteger(0,PLOT_ARROW,233);
   PlotIndexSetInteger(1,PLOT_ARROW,234);
//--- 指示器属性
   string indicatorName=StringFormat("MACD_Divergence(%i, %i, %i)",fastEMA,slowEMA,signalSMA);
   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,signalSMA);
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits+2);
   IndicatorSetString(INDICATOR_SHORTNAME,indicatorName);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
// 清除图表|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectDeleteByName("MACD_DivergenceLine");
  }
//+------------------------------------------------------------------+
//| 自定义指标迭代函数|
//+------------------------------------------------------------------+
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[])
  {
//---------------------------------------------------------指标仅在新蜡烛上更新,总重绘除外
   static datetime lastCandleTime=0;
   if(lastCandleTime==time[rates_total-1])
      return(rates_total);
   else
      lastCandleTime=time[rates_total-1];
//--- 第一次计算或条数发生变化
   int start;
   if(prev_calculated<=0)
     {
      start=slowEMA;
      ArrayInitialize(bullishDivergence,EMPTY_VALUE);   // 分歧缓冲区必须初始化
      ArrayInitialize(bearishDivergence,EMPTY_VALUE);
     }
   else
     {
      start=prev_calculated-2;
      bullishDivergence[rates_total-1]=EMPTY_VALUE;
      bearishDivergence[rates_total-1]=EMPTY_VALUE;
     }
//--- 要复制的数据(MACD 缓冲区)计数 
   int toCopy=rates_total-prev_calculated+(prev_calculated<=0 ? 0 : 1);
//--- 并非所有数据都可以计算
   int calculated=BarsCalculated(macdHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of macdHandle is calculated (",calculated,"bars ). Error",GetLastError());
      return(0);
     }
//--- 获取主 MACD 缓冲区
   if(IsStopped()) return(0); //检查停止标志
   if(CopyBuffer(macdHandle,MAIN_LINE,0,toCopy,macdBuffer)<=0)
     {
      Print("Getting MACD Main is failed! Error : ",GetLastError());
      return(0);
     }
//--- 获取信号 MACD 缓冲区
   if(IsStopped()) return(0); //检查停止标志
   if(CopyBuffer(macdHandle,SIGNAL_LINE,0,toCopy,signalBuffer)<=0)
     {
      Print("Getting MACD Signal is failed! Error : ",GetLastError());
      return(0);
     }
//--- 主循环计算
   for(int shift=start; shift<rates_total-2; shift++)
     {
      int currentExtremum,lastExtremum;
      bool isBullishDivergence,isBearishDivergence;
      string divergenceMsg;
      ENUM_LINE_STYLE divergenceStyle=0;

      //-- 捕捉看涨背离
      isBullishDivergence=false;

      if(macdBuffer[shift]<=macdBuffer[shift-1] && 
         macdBuffer[shift]<macdBuffer[shift-2] && 
         macdBuffer[shift]<macdBuffer[shift+1])
         //--- 如果当前 macd 主线是一个底部(低于 2 个前一个和 1 个后一个)
        {
         currentExtremum=shift;
         lastExtremum=GetIndicatorLastTrough(shift);
         //--- 
         if(macdBuffer[currentExtremum]>macdBuffer[lastExtremum] && 
            low[currentExtremum]<low[lastExtremum])
           {
            isBullishDivergence=true;
            divergenceMsg="Classical bullish divergence on: ";
            divergenceStyle=STYLE_SOLID;
           }
         //--- 
         if(macdBuffer[currentExtremum]<macdBuffer[lastExtremum] && 
            low[currentExtremum]>low[lastExtremum])
           {
            isBullishDivergence=true;
            divergenceMsg="Reverse bullish divergence on: ";
            divergenceStyle=STYLE_DOT;
           }
         //-- 发现看涨背离
         if(isBullishDivergence)
           {
            bullishDivergence[currentExtremum]=macdBuffer[currentExtremum]-ARROWS_DISPLACEMENT;
            //---
            if(drawPriceTrendLines==true)
               DrawTrendLine(TRENDLINE_MAIN,time[currentExtremum],time[lastExtremum],low[currentExtremum],low[lastExtremum],Green,divergenceStyle);
            //---
            if(drawIndicatorTrendLines==true)
               DrawTrendLine(TRENDLINE_INDICATOR,time[currentExtremum],time[lastExtremum],macdBuffer[currentExtremum],macdBuffer[lastExtremum],Green,divergenceStyle);
            //---
            if(displayAlert==true && shift>=rates_total-3 && time[currentExtremum]!=lastAlertTime)
               DisplayAlert(divergenceMsg,time[currentExtremum]);
           }
        }
      //--- 捕捉看跌背离
      isBearishDivergence=false;

      if(macdBuffer[shift]>=macdBuffer[shift-1] && 
         macdBuffer[shift]>macdBuffer[shift-2] && 
         macdBuffer[shift]>macdBuffer[shift+1])
         //--- 如果当前 macd 主线是顶部(高于 2 个前一个和 1 个后一个)
        {
         currentExtremum=shift;
         lastExtremum=GetIndicatorLastPeak(shift);
         //--- 
         if(macdBuffer[currentExtremum]<macdBuffer[lastExtremum] && 
            high[currentExtremum]>high[lastExtremum])
           {
            isBearishDivergence=true;
            divergenceMsg="Classical bearish divergence on: ";
            divergenceStyle=STYLE_SOLID;
           }
         if(macdBuffer[currentExtremum]>macdBuffer[lastExtremum] && 
            high[currentExtremum]<high[lastExtremum])
           {
            isBearishDivergence=true;
            divergenceMsg="Reverse bearish divergence on: ";
            divergenceStyle=STYLE_DOT;
           }
         //--- 发现看跌背离
         if(isBearishDivergence)
           {
            bearishDivergence[currentExtremum]=macdBuffer[currentExtremum]+ARROWS_DISPLACEMENT;
            //---
            if(drawPriceTrendLines==true)
               DrawTrendLine(TRENDLINE_MAIN,time[currentExtremum],time[lastExtremum],high[currentExtremum],high[lastExtremum],Red,STYLE_SOLID);
            //---
            if(drawIndicatorTrendLines==true)
               DrawTrendLine(TRENDLINE_INDICATOR,time[currentExtremum],time[lastExtremum],macdBuffer[currentExtremum],macdBuffer[lastExtremum],Red,STYLE_SOLID);
            //---
            if(displayAlert==true && shift>=rates_total-3 && time[currentExtremum]!=lastAlertTime)
               DisplayAlert(divergenceMsg,time[currentExtremum]);
           }
        }
     }
//--- 为下一次调用返回 prev_calculated 的值
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| 搜索最后一个波谷|
//+------------------------------------------------------------------+
int GetIndicatorLastTrough(int shift)
  {
   for(int i=shift-5; i>=2; i--)
     {
      if(signalBuffer[i] <= signalBuffer[i-1] && signalBuffer[i] <= signalBuffer[i-2] &&
         signalBuffer[i] <= signalBuffer[i+1] && signalBuffer[i] <= signalBuffer[i+2])
        {
         for(int j=i; j>=2; j--)
           {
            if(macdBuffer[j] <= macdBuffer[j-1] && macdBuffer[j] < macdBuffer[j-2] &&
               macdBuffer[j] <= macdBuffer[j+1] && macdBuffer[j] < macdBuffer[j+2])
               return(j);
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| 搜索最后一个峰值|
//+------------------------------------------------------------------+
int GetIndicatorLastPeak(int shift)
  {
   for(int i=shift-5; i>=2; i--)
     {
      if(signalBuffer[i] >= signalBuffer[i-1] && signalBuffer[i] >= signalBuffer[i-2] &&
         signalBuffer[i] >= signalBuffer[i+1] && signalBuffer[i] >= signalBuffer[i+2])
        {
         for(int j=i; j>=2; j--)
           {
            if(macdBuffer[j] >= macdBuffer[j-1] && macdBuffer[j] > macdBuffer[j-2] &&
               macdBuffer[j] >= macdBuffer[j+1] && macdBuffer[j] > macdBuffer[j+2])
               return(j);
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| DrawTrendLine | 使用的 ENUM_TRENDLINE_TYPE
//+------------------------------------------------------------------+
enum ENUM_TRENDLINE_TYPE
  {
   TRENDLINE_MAIN,
   TRENDLINE_INDICATOR
  };
//+------------------------------------------------------------------+
//| 在主图表或指标上绘制趋势线
//+------------------------------------------------------------------+
void DrawTrendLine(ENUM_TRENDLINE_TYPE window,datetime x1,datetime x2,double y1,double y2,color lineColor,ENUM_LINE_STYLE style)
  {
   string label=OBJECT_PREFIX+"#"+IntegerToString(window)+DoubleToString(x1,0);
   int subwindow=(window==TRENDLINE_MAIN) ? 0 : ChartWindowFind();
   ObjectDelete(0,label);
   ObjectCreate(0,label,OBJ_TREND,subwindow,x1,y1,x2,y2,0,0);
   ObjectSetInteger(0,label,OBJPROP_RAY,false);
   ObjectSetInteger(0,label,OBJPROP_COLOR,lineColor);
   ObjectSetInteger(0,label,OBJPROP_STYLE,style);
  }
//+------------------------------------------------------------------+
//| 发现分歧时显示警报|
//+------------------------------------------------------------------+
void DisplayAlert(string message,const datetime alertTime)
  {
   lastAlertTime=alertTime;
   Alert(message,Symbol()," , ",EnumToString(Period())," minutes chart");
  }
//+------------------------------------------------------------------+
//| 删除指示器绘制的所有对象
//+------------------------------------------------------------------+
void ObjectDeleteByName(string prefix)
  {
   int total=ObjectsTotal(0),
   length=StringLen(prefix);

//-- 删除指示器使用的所有对象
   for(int i=total-1; i>=0; i--)
     {
      string objName=ObjectName(0,i);
      if(StringSubstr(objName,0,length)==prefix)
        {
         ObjectDelete(0,objName);
        }
     }
  }
//+------------------------------------------------------------------+



 

关于交易、自动交易系统和测试交易策略的论坛

指标:MACD 背离

Alain Verleyen, 2013.11.05 19:14

太友好了。

信号是在蜡烛收盘时发出的,是在过去的 1 根蜡烛(如果算上开放蜡烛,则是 2 根,而不是 3 根)。这很正常,也是必须的工作方式。背离是基于对极值(顶部/底部)的研究。如果您有办法检测当前蜡烛图上的极值,我建议您学习编程,并免费为我们提供这项伟大的创新。

感谢您的意见。


 
你好,阿兰。非常好的指标。它能发出正确的信号。
不过,在"//----发现看跌背离"部分,应该是 "divergenceStyle",而不是 "STYLE_SOLID"。

指标完全没有重绘。为了达到我的目的,我决定稍作修改,使指标的最后一个条形图以及背离信号可以重绘。
它将显示前一个柱状图上的背离信号,而且肯定是可重绘信号。这将有助于在快速时间框架中使用收盘前的信号。

我做了修改

- removed all part "//--- indicator updated only on new candle except total redraw"
- 将 "start=prev_calculated-2; "改为 "start=prev_calculated-1;"。
- 在"//----计算的主循环 "部分,"for(int shift=start; shift<rates_total-2; shift++) "改为 "for(int shift=start; shift<rates_total-1; shift++)"

发散信号现在出现在前一个柱状图上,但在出现的瞬间就冻结了,而且在这个柱状图上不跟随指标线移动。
您能帮我解决这个问题吗?
 

我修改了这一部分,解决了这个问题。也许可以做得更好、更简单,但它还是有效的。箭头向前移动了一格。没有箭头的线是未确认的信号。

//---------------------------------------------------------指标仅在新蜡烛上更新,总重绘除外
 // static datetime lastCandleTime=0;
 // if(lastCandleTime==time[rates_total-1])
 // return(rates_total);
 // 否则
 // lastCandleTime=time[rates_total-1];
//--- 第一次计算或条数被更改
   int start;
   if(prev_calculated<=0)
     {
      start=slowEMA;
      ArrayInitialize(bullishDivergence,EMPTY_VALUE);   // 分歧缓冲区必须初始化
      ArrayInitialize(bearishDivergence,EMPTY_VALUE);
     }
   else
     { 
      start=prev_calculated-1;
      bullishDivergence[rates_total-1]=EMPTY_VALUE;
      bearishDivergence[rates_total-1]=EMPTY_VALUE;
     }
//--- 要复制的数据(MACD 缓冲区)计数 
   int toCopy=rates_total-prev_calculated+(prev_calculated<=0 ? 0 : 1);
//--- 并非所有数据都可以计算
   int calculated=BarsCalculated(macdHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of macdHandle is calculated (",calculated,"bars ). Error",GetLastError());
      return(0);
     }
//--- 获取主 MACD 缓冲区
   if(IsStopped()) return(0); //检查停止标志
   if(CopyBuffer(macdHandle,MAIN_LINE,0,toCopy,macdBuffer)<=0)
     {
      Print("Getting MACD Main is failed! Error : ",GetLastError());
      return(0);
     }
//--- 获取信号 MACD 缓冲区
   if(IsStopped()) return(0); //检查停止标志
   if(CopyBuffer(macdHandle,SIGNAL_LINE,0,toCopy,signalBuffer)<=0)
     {
      Print("Getting MACD Signal is failed! Error : ",GetLastError());
      return(0);
     }
//--- 主循环计算
   for(int shift=start; shift<rates_total; shift++)
     {
      int currentExtremum,lastExtremum;
      bool isBullishDivergence,isBearishDivergence;
      string divergenceMsg;
      ENUM_LINE_STYLE divergenceStyle=0;
      
      //-- 捕捉看涨背离
      isBullishDivergence=false;
               
      if(macdBuffer[shift-1]<=macdBuffer[shift-2] && 
         macdBuffer[shift-1]<macdBuffer[shift-3] && 
         macdBuffer[shift-1]<macdBuffer[shift])
         //--- 如果当前 macd 主线是一个底部(低于 2 个前一个和 1 个后一个)
        {
         currentExtremum=shift;
         lastExtremum=GetIndicatorLastTrough(shift);
         //--- 
         if(macdBuffer[currentExtremum-1]>macdBuffer[lastExtremum] && 
            low[currentExtremum-1]<low[lastExtremum])
           {
            isBullishDivergence=true;
            divergenceMsg="Classical bullish divergence on: ";
            divergenceStyle=STYLE_SOLID;
           }
         //--- 
         if(macdBuffer[currentExtremum-1]<macdBuffer[lastExtremum] && 
            low[currentExtremum-1]>low[lastExtremum])
           {
            isBullishDivergence=true;
            divergenceMsg="Reverse bullish divergence on: ";
            divergenceStyle=STYLE_DOT;
           }
         //-- 发现看涨背离
         if(isBullishDivergence)
           {
            bullishDivergence[currentExtremum]=macdBuffer[currentExtremum]-ARROWS_DISPLACEMENT;
            //---
            if(drawPriceTrendLines==true)
               DrawTrendLine(TRENDLINE_MAIN,time[currentExtremum-1],time[lastExtremum],low[currentExtremum-1],low[lastExtremum],Green,divergenceStyle);
            //---
            if(drawIndicatorTrendLines==true)
               DrawTrendLine(TRENDLINE_INDICATOR,time[currentExtremum-1],time[lastExtremum],macdBuffer[currentExtremum-1],macdBuffer[lastExtremum],Green,divergenceStyle);
            //---
            if(displayAlert==true && shift>=rates_total-3 && time[currentExtremum-1]!=lastAlertTime)
               DisplayAlert(divergenceMsg,time[currentExtremum-1]);
           }
        }
      //--- 捕捉看跌背离
      isBearishDivergence=false;

      if(macdBuffer[shift-1]>=macdBuffer[shift-2] && 
         macdBuffer[shift-1]>macdBuffer[shift-3] && 
         macdBuffer[shift-1]>macdBuffer[shift])
         //--- 如果当前 macd 主线是顶部(高于 2 个前一个和 1 个后一个)
        {
         currentExtremum=shift;
         lastExtremum=GetIndicatorLastPeak(shift);
         //--- 
         if(macdBuffer[currentExtremum-1]<macdBuffer[lastExtremum] && 
            high[currentExtremum-1]>high[lastExtremum])
           {
            isBearishDivergence=true;
            divergenceMsg="Classical bearish divergence on: ";
            divergenceStyle=STYLE_SOLID;
           }
         if(macdBuffer[currentExtremum-1]>macdBuffer[lastExtremum] && 
            high[currentExtremum-1]<high[lastExtremum])
           {
            isBearishDivergence=true;
            divergenceMsg="Reverse bearish divergence on: ";
            divergenceStyle=STYLE_DOT;
           }
         //--- 发现看跌背离
         if(isBearishDivergence)
           {
            bearishDivergence[currentExtremum]=macdBuffer[currentExtremum]+ARROWS_DISPLACEMENT;
            //---
            if(drawPriceTrendLines==true)
               DrawTrendLine(TRENDLINE_MAIN,time[currentExtremum-1],time[lastExtremum],high[currentExtremum-1],high[lastExtremum],Red,divergenceStyle);
            //---
            if(drawIndicatorTrendLines==true)
               DrawTrendLine(TRENDLINE_INDICATOR,time[currentExtremum-1],time[lastExtremum],macdBuffer[currentExtremum-1],macdBuffer[lastExtremum],Red,divergenceStyle);
            //---
            if(displayAlert==true && shift>=rates_total-3 && time[currentExtremum-1]!=lastAlertTime)
               DisplayAlert(divergenceMsg,time[currentExtremum-1]);
           }
        }
     }
//--- 为下一次调用返回 prev_calculated 的值
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| 搜索最后一个波谷|
//+------------------------------------------------------------------+
int GetIndicatorLastTrough(int shift)
  {
   for(int i=shift-6; i>=2; i--)
     {
      if(signalBuffer[i] <= signalBuffer[i-1] && signalBuffer[i] <= signalBuffer[i-2] &&
         signalBuffer[i] <= signalBuffer[i+1] && signalBuffer[i] <= signalBuffer[i+2])
        {
         for(int j=i; j>=2; j--)
           {
            if(macdBuffer[j] <= macdBuffer[j-1] && macdBuffer[j] < macdBuffer[j-2] &&
               macdBuffer[j] <= macdBuffer[j+1] && macdBuffer[j] < macdBuffer[j+2])
               return(j);
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| 搜索最后一个峰值|
//+------------------------------------------------------------------+
int GetIndicatorLastPeak(int shift)
  {
   for(int i=shift-6; i>=2; i--)
     {
      if(signalBuffer[i] >= signalBuffer[i-1] && signalBuffer[i] >= signalBuffer[i-2] &&
         signalBuffer[i] >= signalBuffer[i+1] && signalBuffer[i] >= signalBuffer[i+2])
        {
         for(int j=i; j>=2; j--)
           {
            if(macdBuffer[j] >= macdBuffer[j-1] && macdBuffer[j] > macdBuffer[j-2] &&
               macdBuffer[j] >= macdBuffer[j+1] && macdBuffer[j] > macdBuffer[j+2])
               return(j);
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| DrawTrendLine | 使用的 ENUM_TRENDLINE_TYPE
//+------------------------------------------------------------------+
 
Vladimir Karputov #:

当背离零线以下也是价格形成 HL 底(价格如果没有再次做出 LL)柱状图的任何其他 5 30 60 240 tf 3 tf 签署富有成效

 

你好,阿兰、

非常感谢你提供这么好的指标!

我正试图在 EA 中使用该指标的数据窗口值(请参阅附件)。

我对所有四个指标都使用了相同的逻辑,但只有最后两个指标(主要指标和信号指标)能够得到正确的数值。


对于前两个指数,我看到的总是一个固定的数字

而在所附的示例中,一个应该有正确的值,另一个应该是 0/空白


您知道我为什么会遇到这个问题吗?


谢谢。

附加的文件:
Screenshot.PNG  85 kb