简体   繁体   English

mql4 iLowest() 给出了错误的蜡烛 ID?

[英]mql4 iLowest() giving the wrong candle ID?

I am trying to get the lowest candle ID inside for loop我正在尝试在 for 循环中获取最低的蜡烛 ID

Use case:用例:

Step 1: i am using for loop to check candle ID of the candle on which the indicator is visible most recently, and then break the loop第 1 步:我正在使用 for 循环检查指标最近可见的蜡烛的蜡烛 ID,然后中断循环

Step 2: i am using iLowest() to get the candle ID of the bar having the lowest value out of 5,第 2 步:我正在使用 iLowest() 来获取 5 个中值最低的柱的蜡烛 ID,

Step3: using the candle id (from step 2) to get low value of that candle and then calculate the SL for that candle.3 步:使用蜡烛 id(来自第 2 步)获取该蜡烛的低值,然后计算该蜡烛的 SL。

But i am getting wrong ID of candle in Step 2.但是我在第 2 步中得到了错误的蜡烛 ID。

please have a look at the below screenshot, the comment of bar should be 74 but it shows 135请看下面的截图,bar的评论应该是74,但它显示的是135 在此处输入图像描述

Here is my code:这是我的代码:

   for(int i=0;i<1000;i++)
           {
          double btt1= iCustom(NULL,0,"Arrows",0,i);
          double btt2= iCustom(NULL,0,"Arrows",1,i);
          if(btt1!=EMPTY_VALUE)
            {
             if(Digits==5|| Digits==3)
                   {
                    baar =iLowest(NULL,0,MODE_LOW,5+i,i);
                    lowestb = Low[baar];
                    stoploss = lowestb- 20*Point*10; 
                    Comment("value of i :  ",i,"    value of baar :  " , baar );
                     ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0);
                     ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,xx1x);
                     ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,yy1y);
                     ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner); 
                     ObjectSetString(chart_ID,name,OBJPROP_TEXT, stoploss   ); 
                     ObjectSetString(chart_ID,name,OBJPROP_FONT,font); 
                     ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size); 
                     ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clrRed);            
                     ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
 
                   break;
                   }
                  
                   }
                   
                   }

What am i doing wrong?我究竟做错了什么?

Change it to:将其更改为:

baar =iLowest(NULL,0,MODE_LOW,5,i);

Because the 4th parameter of the iLowest function counts the number of bars that you want to analyze starting from the counter i (the last parameter).因为 iLowest function 的第 4 个参数从计数器 i(最后一个参数)开始计算您要分析的柱数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM