Hi, im having a small problem with developing a code to determine the ‘x’ value which is the index of the bar on the 5 minute chart with a range of 50 pips or more between bar 1 and bar 8640. The Code keeps on returning a value of 1 even when the range of the bar with an index of 1 is less than 50 pips and even worse, the index of bar is supposed to be greater than 50. Please assist with any advice.
have a think about what &&(x>50) is doing
bool IdentifyBigBar() // Code for preventing High volatility { int x; for( x=1;x<=8640; x++) { if ( (iHigh(NULL, PERIOD_M5, x) - iLow(NULL, PERIOD_M5, x) > 50*PipValue*Point)&&(x>=50) ) break; Print("Index of the bar is",x); return(true); } }
What do you expect. You get exactly what you coded. x will never exeed 1.
Maybe you have to use "continue" and not "break" ?
Hi rod178, '&&(x>50)' is ensuring or supposed to ensure that my x value is greater than 50. I went on and tested what happens when I only have if (x>=50) the code still returns a value of x=1 which doesn't make sense.
x is a bar count, not a pip value, hence the result, as eddie stated above, and the reason I gave u the 'tip' to look at x.
Additionally, you should start using meaningful variable names .
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, im having a small problem with developing a code to determine the ‘x’ value which is the index of the bar on the 5 minute chart with a range of 50 pips or more between bar 1 and bar 8640. The Code keeps on returning a value of 1 even when the range of the bar with an index of 1 is less than 50 pips and even worse, the index of bar is supposed to be greater than 50. Please assist with any advice.