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

 
Alexey Viktorov:
哪里写着不能在新栏的同时有一个历史分载?

哪里写着应该追踪历史?
在加载过程中,可以不考虑指标 的计算--因为没有完整的历史记录(柱子可以出现在任何地方)。
因此,结论是--只有在所有的酒吧都建成后,才能有新的酒吧。
否则所有的酒吧都是 "老 "的。

 
m-r LSV:

没有任何帮助 :(

显示代码。

 
Taras Slobodyanik:

你需要看看你所建造的东西。

塔拉斯!!!这个人问的是MQL5!!。而MT5是从左到右索引的......事实证明,你不应该计算1条,而应该计算rate_total-2

 
Taras Slobodyanik:

哪里写着你必须监控历史加载?
在加载过程中,可以不考虑指标 的计算--因为没有完整的历史。
因此,结论是--只有在所有的酒吧都建成之后,才能有一个新的酒吧。
否则所有的酒吧都是 "老 "的。

请告知如何用历史来做。
事情是这样的,它是有计划的,当然要检查一些历史上的东西。
我有一些观察,想用缓冲器来做箭头。

但这将在以后发生。

 
Taras Slobodyanik:

显示代码。

//+------------------------------------------------------------------+
//|                                                    test.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window

#property indicator_buffers 2
#property indicator_plots   2

#property indicator_label1  "Signal UP"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2

#property indicator_label2  "Signal DN"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2

double up[];
double dn[];

datetime fin=0, last=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
    IndicatorSetString(INDICATOR_SHORTNAME, "Prototype");
    
   SetIndexBuffer(0,up,INDICATOR_DATA);
   PlotIndexSetInteger(0,PLOT_ARROW,233);
    
   SetIndexBuffer(1,dn,INDICATOR_DATA);
   PlotIndexSetInteger(1,PLOT_ARROW,234);
   
   
  
   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[])
   {
   fin=iTime(Symbol(), PERIOD_M1 ,0);
   if(last==fin) return(rates_total);
   last=fin;
   
   if(rates_total - prev_calculated == 1)
      {
      //Print("Новый бар");
      if(open[1] > close[1])
           {
           Print("Dn");
           }
      else if(open[1] < close[1])
           {
           Print("Up");
           }
      }

return(rates_total);
}
 
Alexey Viktorov:

塔拉斯!!!这个人问的是MQL5!!。在MT5中,索引是从左到右......事实证明,rate_total-2,而不是1条必须被计算在内。

不,不,prev_calculated和rate_total并不依赖于它。

 
Taras Slobodyanik:

没有,prev_calculated和rate_total并不依赖于此。

prev_calculated和rate_total与你提出的读取左边第一个柱子的开盘和收盘有什么关系?

 
Alexey Viktorov:

prev_calculated和rate_total与你提出的读取左边第一个柱子的开盘和收盘的事实有什么关系?

我并不建议阅读左边的关闭条,这不是我的代码)

只有我的

if(rates_total - prev_calculated == 1)
 
m-r LSV:

没有任何帮助 :(

是的,你需要改变数组的方向,或者采取rate_total-2 的索引而不是1

{
   
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);
   ArraySetAsSeries(time,true);
   
   if(rates_total - prev_calculated > 1)
      {
      Print("Загрузка истории");
      return(rates_total);
      }
   
   if(rates_total - prev_calculated == 1)
      {
      //Print("Новый бар");
      if(open[1] > close[1])
           {
           Print("Dn");
           }
      else if(open[1] < close[1])
           {
           Print("Up");
           }
      }

return(rates_total);
}


 
Taras Slobodyanik:

我不建议阅读左边的栏杆关闭,那不是我的代码)

这只是我的。

如此明目张胆地撒谎是不体面的。你删除你的帖子,把你的文盲归咎于别人。骗子。