Higher Timeframe's Highest Values Lower than Than the Smaller Timeframe's Highest?

 

 I have been coding and realized that at some points the Highest High of the time periods fluctuate in interesting manners. 


To make my question more understandable: 


double d1highest = High[iHighest(_Symbol,PERIOD_D1,MODE_HIGH, PERIOD_D1, 0)],   //The Highest Point that the price has reached in the last 24 hours on the Daily Chart. 
m30highest = High[iHighest(_Symbol,PERIOD_M30,MODE_HIGH, PERIOD_D1, 0)],        //The Highest Point that the price has reached in the last 24 hours on the 30 Minute Chart. 


Sometimes I notice d1highest is lower than the m30highest. I also experienced this phenomenon with the lowest lows. Any reasonable explanation on why and how this is happening? 

I thought that if the M30's (or any other TFs under D1's) Highest High was broken then that became the newest Highest High of the whole day. Is this a glitch in MQL4? Thanks for your input and God Bless

 

To see for yourself here's a simple function that will prove it to you.

It's based on 1440 candles. 

bool Function(int highertimeframe = PERIOD_D1, int lowertimeframe = PERIOD_M30)
{
        double output, 
        higherhigh = High[iHighest(_Symbol,highertimeframe,MODE_HIGH, PERIOD_D1, 0)],   //The Higher TF's High.
        lowerhigh = High[iHighest(_Symbol, lowertimeframe,MODE_HIGH, PERIOD_D1, 0)];    //The Lower TF's High.

        if (highertimeframe > lowertimeframe)   //Checks if the highertimeframe is higher than the lowertimeframe. 
        {
                if (higherhigh < lowerhigh)
                {
                        output = True;
                
                )
                else (output = False); 
        
        }
        return (output); 
}
 
Chance Watkins:

To see for yourself here's a simple function that will prove it to you.

It's based on 1440 candles. 

You supplied wrong values to the 4th parameter of iHighest()... For example, 7 bars for your highertimeframe is 7 days, but 7 bars for your lowertimeframe is only 3.5 hours. 
 

Your code will not compile

bool Function(int highertimeframe = PERIOD_D1, int lowertimeframe = PERIOD_M30)
{
        double output, 
        higherhigh = High[iHighest(_Symbol,highertimeframe,MODE_HIGH, PERIOD_D1, 0)],   //The Higher TF's High.
        lowerhigh = High[iHighest(_Symbol, lowertimeframe,MODE_HIGH, PERIOD_D1, 0)];    //The Lower TF's High.

        if (highertimeframe > lowertimeframe)   //Checks if the highertimeframe is higher than the lowertimeframe. 
        {
                if (higherhigh < lowerhigh)
                {
                        output = True;
                
                )   //This is ), it should be }
                else (output = False); 
        
        }
        return (output); 
}

) instead of }

output should be a bool.

As Seng says, correct the parameters in iHighest()

 
higherhigh = High[iHighest(_Symbol,highertimeframe,MODE_HIGH, PERIOD_D1, 0)],   //The Higher TF's High.
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

    The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero on the first call.

 

Hi. Yea I kinda made that example function off the top of my head and didn't try to run it. I just assumed the person knowing the answer to the problem would realize any small errors. But I believe y'all are right about the parameters. In order to wrap my mind around it I made my own "iHighest" function that takes the Highest High inside a given amount of minutes. It took me literally 3 or 4 days to wrap my head around the subject. Anyways I needed the iHighest function to be subjective to the TF Periods as I changed it. Here's my homemade function: 

*note I am still troubleshooting it and perfecting it but you get the jest of what I am doing. 


int RealHighest(int span = PERIOD_H4, int shift = 0)
{
   //This makes the function work according to all the time frames. 
   double highs[1440]; //shift needs to be added to the size here. Shift will probably not be used much.
   double realspan = span/Period(); //Gives the correct number of candles. 
   
   for (int candle = shift; candle < realspan; candle++)
   {      
      highs[candle] = High[candle]; 
   
   }
   
   int output = ArrayMaximum(highs); //gives me the index. 
   double realoutput = High[output]; //gives me the acutal high value. 
   
   //NOTE: THIS ONLY WORKS UP TO ONE DAY. IF I NEED MORE THAN ONE DAY'S SPAN I NEED TO INCREASE THE ARRAY SIZE. 
   return (highs[48]); 


//The output is not giving me what I want. I think the problem lies with the array or the iteration. 
//It's giving me the value of 1 for the indexes in the array. 
   
   

}


Didn't mean to post it in the wrong forum :P. Anyways I know iHighest will give me what I want but it's interesting to try to dissect it. 

Reason: