新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 1483

 
Alexey Viktorov:

注意将时间和价格转换为像素的XY坐标

读取行价,将其转换为像素并将坐标分配Y 轴上的 "文本标记 "对象,而X坐标保持不变。

我已经关注这个功能很久了,但不知道如何去做,因为我没有足够的经验。谢谢,我将尝试把它整合到代码中。

 
Aleksei Stepanenko:

行和文本指示器 Ver 1

指示器在该行之后移动文本。在输入参数中插入该行的名称。

谢谢你。这也是一个有趣的布局。我一定会把它拿出来,只要我搞清楚ChartTimePriceToXY()。

 

能否请你告诉我可能出了什么问题?

   for(int i=rates_total-prev_calculated-2;i>=0;i--)
     {
      ADRBuffer1[i]=High[i];
      if(High[i]<ADRBuffer1[i+1])
      ADRBuffer1[i]=ADRBuffer1[i+1];
      ADRBuffer2[i]=Low[i];
      if(Low[i]>ADRBuffer2[i+1])
      ADRBuffer2[i]=ADRBuffer2[i+1];
     }

低位抽签,但高位不愿意...

 
MakarFX:

能否请你告诉我可能出了什么问题?

低位抽签,但高位不愿意...

ADRBuffer1[i+1]在第一次运行时等于什么?可能有比High[i]更多的垃圾。

 
Alexey Viktorov:

ADRBuffer1[i+1]在第一次运行时等于什么?可能有比High[i]更多的垃圾。

请告诉我如何修复它,为什么Low画得很好?

所有代码

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDimGray
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrCrimson
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrTeal
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- indicator buffers
double   ADRBuffer0[];
double   ADRBuffer1[];
double   ADRBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorDigits(Digits);
//--- indicator buffers mapping
   SetIndexBuffer(0,ADRBuffer0,INDICATOR_DATA);
   SetIndexBuffer(1,ADRBuffer1,INDICATOR_DATA);
   SetIndexBuffer(2,ADRBuffer2,INDICATOR_DATA);
   SetIndexLabel(0,"ADR");
   SetIndexLabel(1,"ADR1");
   SetIndexLabel(2,"ADR2");
//---
   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[])
  {
//---
   if((rates_total-prev_calculated-2)<=0)return(0);
   for(int i=rates_total-prev_calculated-2;i>=0;i--)
     {
      ADRBuffer1[i]=High[i];
      if(High[i]<ADRBuffer1[i+1])
      ADRBuffer1[i]=ADRBuffer1[i+1];
      ADRBuffer2[i]=Low[i];
      if(Low[i]>ADRBuffer2[i+1])
      ADRBuffer2[i]=ADRBuffer2[i+1];
     }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
MakarFX:

你能告诉我如何解决,为什么Low会正常绘制吗?

整个代码

构造的数量必然要被宣布。并尝试用0写缓冲区初始化,前提是prev_calculate == 0。

 
Alexey Viktorov:

申报建筑数量是有义务的。

不幸的是,我不清楚这意味着什么。

Alexey Viktorov:

并尝试用0来写缓冲区的初始化,前提是prev_calculate == 0。

没有帮助(

 
MakarFX:

不幸的是,我不明白这意味着什么。

这并没有什么帮助(


if( prev_calculated == 0 ) {
   ADRBuffer1[rates_total-1] = High[rates_total-1];
   ADRBuffer2[rates_total-1] = Low[rates_total-1]
}

for(int i=rates_total-prev_calculated-2;i>=0;i--)
{
...
}
 
MakarFX:

不幸的是,我不明白这意味着什么。

这并没有什么帮助(

#property indicator_plots   3

默认为1。而如果公布建筑数量没有帮助,那么就进行选项B。

 
PapaYozh:


谢谢你,这很有帮助......我做得不对)))。