Strange results from iLowest()??

To add comments, please log in or register
Tony
262
Tony  

Hi


I trying to use the lowest low over the previous 10 bars, but I am getting strange results from iLowest(). Do others have this problem? Am I doing something wrong?

It appears to mix up the type constants. I've tested it on M1 & M5 because they move faster.


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   
   // Lowest low is obtained by using Lowest PRICE_OPEN !!!
   Low10[0] =  iLow(  NULL, 0, iLowest(  NULL, 0, PRICE_OPEN,  10, 1 ) );
   
   // Testing for strange results
   int Shift = iLowest(  NULL, 0, PRICE_OPEN,  10, 1 );
   // Using PRICE_CLOSE gives the shift of the lowest OPEN !!!
   // Using PRICE_OPEN gives the shift of the lowest LOW !!!
   // Using PRICE_HIGH gives the shift of the lowest HIGH - OK
   // Using PRICE_LOW gives the shift of the lowest CLOSE !!!
   Comment( "Shift = " + DoubleToStr( Shift, 0 )
            + "\nValue = " + DoubleToStr( iLow( NULL, 0, Shift ), 5 ) );

   // Highest High is OK
   High10[0] = iHigh( NULL, 0, iHighest( NULL, 0, PRICE_HIGH, 10, 1 ) );
   
   return(0);
}
Any suggestions would be appreciated.


Cheers

Jellybean

Files:
William Roeder
19977
William Roeder  
  Comment( "Shift = " + DoubleToStr( Shift, 0 )
            + "\nValue = " + DoubleToStr( iLow( NULL, 0, Shift ), 5 ) );
Your print out is misleading you:
DoubleToStr( Shift, 0 ) // Equivalent to Shift since it's an int
iLow( NULL, 0, Shift ) // Wrong parameters iLow(symbol,timeframe,TYPE,COUNT,shift)
Al W
163
Al W  

You mixed up your constants.

Applied price constants. It can be any of the following values:

Constant Value Description
PRICE_CLOSE 0 Close price.
PRICE_OPEN 1 Open price.
PRICE_HIGH 2 High price.
PRICE_LOW 3 Low price.
PRICE_MEDIAN 4 Median price, (high+low)/2.
PRICE_TYPICAL 5 Typical price, (high+low+close)/3.
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

Series array identifier used with ArrayCopySeries(), iHighest() and iLowest() functions.
It can be any of the following values:

Constant Value Description
MODE_OPEN 0 Open price.
MODE_LOW 1 Low price.
MODE_HIGH 2 High price.
MODE_CLOSE 3 Close price.
MODE_VOLUME 4 Volume, used in iLowest() and iHighest() functions.
MODE_TIME 5 Bar open time, used in ArrayCopySeries() function.
meikel
365
meikel  
  int Shift = iLowest(  NULL, 0, PRICE_OPEN,  10, 1 );

"Shift" has to be a double.
Al W
163
Al W  
guys, he has everything right EXCEPT his constants. Maybe a redundant DoubleToStr mixed in there, but it wasn't the problem.
meikel
365
meikel  
circlesquares:
guys, he has everything right EXCEPT his constants. Maybe a redundant DoubleToStr mixed in there, but it wasn't the problem.

if the price is i.e. 1.4560, how can you copy this to an integer ?

the result ist 1.

Al W
163
Al W  
Because it returns a shift. its the shift of the lowest bar in the range he provides.
meikel
365
meikel  
circlesquares:
Because it returns a shift. its the shift of the lowest bar in the range he provides.

ok, my error, iLow returns the value, iLowest returns the shift.

sorry...

php,perl,c++,html,css and mq4 at the same time can produce strange results while hacking ;-)

Tony
262
Tony  

Thanks WHR & meikel for your contributions.

circlesquares, you're a legend. This confused the **** out of me. I've used the function many times before and couldn't see what I had done differently. Looking too hard, perhaps ;-)

Thanks

Jellybean

To add comments, please log in or register