unexplained return of a simple function
//============================================================================== void OnTick() { HighestHigh ( Symbol () , Period () , 0 , 8 ) ; } //============================================================================== //============================================================================== double HighestHigh ( string pSymbol , ENUM_TIMEFRAMES pPeriod , int pStart = 0 , int pBars = 8 ) { //------------------------------------------------------------------------------ string Message [ 7 ] ; Message [ 0 ] = "DIVIDE AND RULE: " ; //------------------------------------------------------------------------------ double high [] ; MqlRates PriceInformation [] ; ArraySetAsSeries ( high , true ) ; ArraySetAsSeries ( PriceInformation , true ) ; //------------------------------------------------------------------------------ int copied = CopyHigh ( pSymbol , pPeriod , pStart , pBars , high ) ; if ( copied == -1 ) return ( copied ) ; Message [ 1 ] = IntegerToString ( copied ) ; //------------------------------------------------------------------------------ int maxIdx = ArrayMaximum ( high , pStart , pBars ) ; Message [ 2 ] = IntegerToString ( maxIdx ) ; //------------------------------------------------------------------------------ //int Data = CopyRates ( pSymbol , pPeriod , 0 , Bars ( pSymbol , pPeriod ) , PriceInformation ) ; int Data = CopyRates ( pSymbol , pPeriod , pStart , Bars ( pSymbol , pPeriod ) , PriceInformation ) ; Message [ 3 ] = IntegerToString ( Data ) ; //------------------------------------------------------------------------------ double highestPrice = PriceInformation [maxIdx].high ; Message [ 4 ] = DoubleToString ( highestPrice ) ; Message [ 5 ] = DoubleToString ( high [maxIdx] ) ; //------------------------------------------------------------------------------ static int TickCounter = NULL ; TickCounter ++ ; Message [ 6 ] = IntegerToString ( TickCounter ) ; //------------------------------------------------------------------------------ for ( int i = 1 ; i < ArraySize ( Message ) ; i ++ ) { Message [ 0 ] += " " + Message [ i ] ; } Comment ( Message [ 0 ] ) ; //------------------------------------------------------------------------------ return highestPrice ; } //==============================================================================
Why wouldnt you use iHigh and iHighest?
something like:
iHigh(pSymbol,pPeriod,iHighest(pSymbol,pPeriod,MODE_HIGH,pBars,pStart));
which would return the high of the timeseries at the index returned by iHighest.
//============================================================================== void OnTick() { Print ( "METHOD 1 " , HighestHigh ( Symbol () , Period () , 0 , 8 ) ) ; Print ( "METHOD 2 " , HIGHEST_HIGH ( Symbol () , Period () , 0 , 8 ) ) ; } //============================================================================== //============================================================================== double HIGHEST_HIGH ( string SYMBOL , ENUM_TIMEFRAMES PERIOD , int START = 0 , int BARS = 8 ) { int INDEX = iHighest ( SYMBOL , PERIOD , MODE_HIGH , BARS , START ) ; return iHigh ( SYMBOL , PERIOD , INDEX ) ; } //==============================================================================
Hello community
the unexpected return I am getting is : the highest High is -977190959
could someone Plz figure this out