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

 
prom18:

也许有这样的例子。从视觉上看,这将更容易理解。谢谢你。

如果我没有理解错,你需要某个时间间隔内的条形图,你可以用iTime 选择它们
 
prom18:

你好。我在读一本教科书。这里有一些关于如何编写指标的例子。我有一个关于 separatewindow.mq4 指标的问题。 你可以在那里设置计算栏的数量。如果你需要指定从当天的开盘价(或从零开始)到当天的收盘价的计算呢?我应该如何做呢?我试图搜索解决方案,但没有找到。

以下是当前时间框架下的当天开盘价

//+------------------------------------------------------------------+
//|                                                      DayOpen.mq4 |
//|                                            Copyright 2018, IgorM |
//|                              https://www.mql5.com/ru/users/igorm |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, IgorM"
#property link      "https://www.mql5.com/ru/users/igorm"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         Label1Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer);
   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 i,limit;
   static double dayopen=0.0;
   static int lastday=0;
   if(prev_calculated==0)
     {
      limit=rates_total-1;
      dayopen=0.0;
      lastday=0;
     }
   else limit=rates_total-prev_calculated;
   for(i=limit; i>=0; i--)
     {
      if(TimeDay(time[i])!=lastday)
        {
         dayopen=open[i];
         lastday= TimeDay(time[i]);
        }
      Label1Buffer[i]=dayopen;
     }
   return(rates_total);
  }
 

你好!是否可以通过条件找到历史上给定条形的右边的条形? 谢谢你。

 
Sfinks35:

你好!是否可以通过条件找到历史上给定条形的右边的条形? 谢谢你。

是的,我们可以。

 
Artyom Trishkin:

你可以。

你是如何做到的?请告诉我。
 
Sfinks35:
你是如何做到的?你能告诉我这一点吗?

你如何找到一个特定的酒吧?

 
Artyom Trishkin:

你如何找到一个特定的酒吧?


我花了很长时间,但我写了一个这样的函数。

double GetPatt5barsDN()
{
double low3 = 0;
int index = 0。
for(int i=1; i<20; i++)
{
如果
((Close[i] > Open[i]) &&
(Close[i+1] > Open[i+1]) &&
(Close[i+2] > Open[i+2]) && //Low[i+2] 在这根蜡烛上需要。
(Close[i+3] < Open[i+3]) &&
(Close[i+4] < Open[i+4])

low3 = Low[i+2];
index = i+2。
}

return(low3);
}

 
Igor Makanu:

这里是当前TF中一天的开盘价

谢谢你,伊戈尔。但我没有正确地表述它。该指标被计算并在指定的条数(本例中为50)和独立窗口中绘制。它需要的不是开盘价,而是当天的第一根柱子来指示MA。但无论如何,谢谢你。

 
Igor Makanu:

这里是当前TF上一天的开盘价

你能告诉我,在

int i,limit=prev_calculated==0 ?rates_total-1 : rates_total-prev_calculated;

"==" , "?", ": "

?

 
Sfinks35:


我花了很长时间,但我写了一个这样的函数。

同时返回链接所传递的函数参数中的索引

原因: