错误、漏洞、问题 - 页 3148 1...314131423143314431453146314731483149315031513152315331543155...3184 新评论 Maxim Kuznetsov 2022.02.07 09:27 #31471 Roman #:这是因为IndBuff没有分配给rate_total + 1 而且ArrayResize 也不适用于它。 他们打破了构造。我们现在必须使用if-arses吗? for(int i=limit - 1;.... 至少... Nikolai Semko 2022.02.07 09:42 #31472 Roman #:这是因为IndBuff没有分配给rate_total + 1,ArrayResize 也不适用于它。 这就是你需要减去1的地方:))打印结果显示,尺寸没有问题。使用逻辑。如果limit = 0,那么它就是一个新的tick。如果limit = 1,这意味着一个新的酒吧(rate_total缓冲区的最后一个元素是-1,你有rates_total - 因此溢出)。如果限制>1,那么最好重新计算整个指标。 Roman 2022.02.07 09:42 #31473 Maxim Kuznetsov #: for(int i=limit - 1;.... 至少... 你知道什么是最令人讨厌的吗?任何行为都是默默地被欺骗,没有任何警告。 然后人们就会受到伤害。我受够了这个metatrader。 Nikolai Semko 2022.02.07 09:44 #31474 Roman #:你知道什么是最令人讨厌的吗?任何行为都是默默地被欺骗,没有任何警告。 然后人们就会受到伤害。我受够了这个metatrader。 一切都和以前一样。你的错。提示--学会使用调试器,你就不必做校对了,你会一下子看到你所有的错误。 Artyom Trishkin 2022.02.07 09:45 #31475 Roman #:你知道什么是最令人讨厌的吗?任何行为都是默默地被欺骗,没有任何警告。 然后人们就会受到伤害。我受够了这个metatrader。 我没有注意到指标的计算有任何变化。正如你在上面看到的,Nikolay已经正确地解释了作为rate_total-prev_calculated计算的极限值是什么意思。 而且它已经工作了多年--从第四个终端开始。 Roman 2022.02.07 09:46 #31476 Nikolai Semko #: 这就是你需要减一的地方:)) 打印结果显示,尺寸没有问题。 使用逻辑。 如果limit = 0,那么一个新的tick 如果limit = 1,这意味着一个新的酒吧(rate_total缓冲区的最后一个元素是-1,而你有rate_total,因此出现溢出) 如果限制>1,那么最好重新计算整个指标。 尼古拉我知道如果和为一的结构,,但我总是和为一一起工作,我只是习惯于它,它更方便。 但我在很久以前就注意到了一些奇怪的事情,我一直在拖延,试图弄清楚它。 以前工作很正常 for i>=0 ticks for i>0 bars 而且不需要什么 "如果"。 Vladimir Karputov 2022.02.07 09:49 #31477 Roman #: 第1步:使用 "MQL5向导 "创建一个模板。 //+------------------------------------------------------------------+ //| Simple.mq5 | //| Copyright © 2022, Vladimir Karputov | //| https://www.mql5.com/en/users/barabashkakvn | //+------------------------------------------------------------------+ #property copyright "Copyright © 2022, Vladimir Karputov" #property link "https://www.mql5.com/en/users/barabashkakvn" #property version "1.00" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot Close #property indicator_label1 "Close" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- input parameters input int Input1=9; //--- indicator buffers double CloseBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,CloseBuffer,INDICATOR_DATA); //--- 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[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ 第2步:正确拼写 "limit",并使用close数组--而不是iClose调用!!。 //+------------------------------------------------------------------+ //| Simple.mq5 | //| Copyright © 2022, Vladimir Karputov | //| https://www.mql5.com/en/users/barabashkakvn | //+------------------------------------------------------------------+ #property copyright "Copyright © 2022, Vladimir Karputov" #property link "https://www.mql5.com/en/users/barabashkakvn" #property version "1.00" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot Close #property indicator_label1 "Close" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- input parameters input int Input1=9; //--- indicator buffers double CloseBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,CloseBuffer,INDICATOR_DATA); //--- 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=prev_calculated-1; if(prev_calculated==0) limit=0; for(int i=limit; i<rates_total; i++) { CloseBuffer[i]=close[i]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ 结果。 而且没有任何错误。 附加的文件: Simple.mq5 5 kb Roman 2022.02.07 10:06 #31478 Vladimir Karputov #:第1步:使用 "MQL5向导 "创建一个模板。第2步:正确拼写'limit',并使用close数组--而不是iClose调用!!。结果。并且没有错误。 当然,感谢你直接提供了i++的例子。 但事实上,我有一个反向循环,你没有注意到。 而如果引用iClose作为例子,则必须用来说明i指数随后将被用于其他函数中。 Nikolai Semko 2022.02.07 10:09 #31479 Roman #:尼古拉 我知道if和for one的结构。否则如果Nikolai Semko#: 使用逻辑。 如果limit = 0,那么一个新的tick 如果limit = 1,这意味着一个新的酒吧(rate_total缓冲区的最后一个元素是-1,而你有rate_total,因此出现溢出) 如果限制>1,那么最好重新计算整个指标。 这就是 的错误之处--最好使用 if limit != 1所以整个逻辑大致是这样的。limit = rates_total - prev_calculated; if (limit == 0) {..} // новый тик else if ( limit == 1) {..} // новый бар else {..} // полный пересчет всего индикатора 我明白有些人会愤愤不平,说我为什么要重新计算一切,如果limit == 2,,但是当limit不等于1,也不等于0的时候,意味着这是指标的第一次初始化,或者出了问题(例如连接失败或服务器故障),此外,我多次遇到prev_calculated大于rate_total的情况。可能,以前是一些小故障,现在已经修好了,但从那时起,我就把这种设计作为一种安全防范措施。 TheXpert 2022.02.07 10:10 #31480 Nikolai Semko #:如果limit !=1 这有什么区别呢? 能不能小于零? 1...314131423143314431453146314731483149315031513152315331543155...3184 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
这是因为IndBuff没有分配给rate_total + 1
而且ArrayResize 也不适用于它。
他们打破了构造。我们现在必须使用if-arses吗?
for(int i=limit - 1;....
至少...
这是因为IndBuff没有分配给rate_total + 1
,ArrayResize 也不适用于它。
for(int i=limit - 1;....
至少...
你知道什么是最令人讨厌的吗?任何行为都是默默地被欺骗,没有任何警告。
然后人们就会受到伤害。我受够了这个metatrader。
你知道什么是最令人讨厌的吗?任何行为都是默默地被欺骗,没有任何警告。
然后人们就会受到伤害。我受够了这个metatrader。
你知道什么是最令人讨厌的吗?任何行为都是默默地被欺骗,没有任何警告。
然后人们就会受到伤害。我受够了这个metatrader。
我没有注意到指标的计算有任何变化。正如你在上面看到的,Nikolay已经正确地解释了作为rate_total-prev_calculated计算的极限值是什么意思。
而且它已经工作了多年--从第四个终端开始。
这就是你需要减一的地方:))
尼古拉我知道如果和为一的结构,
,但我总是和为一一起工作,我只是习惯于它,它更方便。
但我在很久以前就注意到了一些奇怪的事情,我一直在拖延,试图弄清楚它。
以前工作很正常
for i>=0 ticks
for i>0 bars
而且不需要什么 "如果"。
第1步:使用 "MQL5向导 "创建一个模板。
第2步:正确拼写 "limit",并使用close数组--而不是iClose调用!!。
结果。
而且没有任何错误。
第1步:使用 "MQL5向导 "创建一个模板。
第2步:正确拼写'limit',并使用close数组--而不是iClose调用!!。
结果。
并且没有错误。
当然,感谢你直接提供了i++的例子。
但事实上,我有一个反向循环,你没有注意到。
而如果引用iClose作为例子,则必须用来说明i指数随后将被用于其他函数中。
尼古拉 我知道if和for one的结构。
否则如果
这就是
的错误之处--最好使用
if limit != 1
所以整个逻辑大致是这样的。
我明白有些人会愤愤不平,说我为什么要重新计算一切,如果limit == 2,,但是当limit不等于1,也不等于0的时候,意味着这是指标的第一次初始化,或者出了问题(例如连接失败或服务器故障)
,此外,我多次遇到prev_calculated大于rate_total的情况。可能,以前是一些小故障,现在已经修好了,但从那时起,我就把这种设计作为一种安全防范措施。
如果limit !=1