mql4 iLowest() giving the wrong candle ID?
mql4 iLowest() giving the wrong candle ID?
Loading saved threads...
Umer · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Umer
Original post: https://stackoverflow.com/questions/67410207
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I am trying to get the lowest candle ID inside for loop
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
Step 2:
i am using iLowest() to get the candle ID of the bar having the lowest value out of 5 ,
Step3 :
using the candle id (from step 2) to get low value of that candle and then calculate the SL for that candle.
But i am getting wrong ID of candle in
Step 2.
please have a look at the below screenshot, the comment of bar should be 74 but it shows 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 ?
Quote
Report
Ala Ben Aicha · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Ala Ben Aicha
Original post: https://stackoverflow.com/a/68018155
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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).
Quote
Report
Post Reply
Checking account access…