Fetching iHighest bar value from higher time frame

 

Hi , it seems as if when using the iHighest syntex fetching a value from a higher time frame does not work correctly. The value that is fetched does not exist on the specified time frame's candle highs. When checking this by printing functions to chart the are discrepancies on the smaller time frames i.e. 15min,30min,1hr. The values are fetched from 4Hr in this example. however when using syntex (iHighest) on the 4Hr chart , fetching values from the same chart , it work fine. Please check for me on yourside and let me if fetching iHighest from a higher time frame works fine.

#include <stdlib.mqh>

#include <WinUser32.mqh>


// exported variables



// local variables

double PipValue=1;    // this variable is here to support 5-digit brokers

bool Terminated = false;

string LF = "\n";  // use this in custom or utility blocks where you need line feeds

int NDigits = 4;   // used mostly for NormalizeDouble in Flex type blocks

int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names

int current = 0;




int init()

{

    NDigits = Digits;

    

    if (false) ObjectsDeleteAll();      // clear the chart

    

    

    Comment("");    // clear the chart

    return (0);

}


// Expert start

int start()

{

    if (Bars < 10)

    {

        Comment("Not enough bars");

        return (0);

    }

    if (Terminated == true)

    {

        Comment("EA Terminated.");

        return (0);

    }

    

    OnEveryTick309();

    return (0);

}


void OnEveryTick309()

{

    PipValue = 1;

    if (NDigits == 3 || NDigits == 5) PipValue = 10;

    

    PrintFunctionsToChart397();

    

}


void PrintFunctionsToChart397()

{

    string temp = "Some Text\n";

    temp = temp + "------------------------------------------------\n"

    + "Highest high from bar(2) to bar(5) " + DoubleToStr(High[iHighest(NULL,PERIOD_H4,MODE_HIGH,5,2)], 5) + "\n"

    + "Some text " + DoubleToStr(0, 5) + "\n"

    + "Some text " + DoubleToStr(0, 5) + "\n"

    + "Some text " + DoubleToStr(0, 5) + "\n"

    + "------------------------------------------------\n";

    Comment(temp);

    

}




int deinit()

{

    if (false) ObjectsDeleteAll();

    

    

    return (0);

 
#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables


// local variables
double PipValue=1;    // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n";  // use this in custom or utility blocks where you need line feeds
int NDigits = 4;   // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;



int init()
{
    NDigits = Digits;
    
    if (false) ObjectsDeleteAll();      // clear the chart
    
    
    Comment("");    // clear the chart
    return (0);
}

// Expert start
int start()
{
    if (Bars < 10)
    {
        Comment("Not enough bars");
        return (0);
    }
    if (Terminated == true)
    {
        Comment("EA Terminated.");
        return (0);
    }
    
    OnEveryTick309();
    return (0);
}

void OnEveryTick309()
{
    PipValue = 1;
    if (NDigits == 3 || NDigits == 5) PipValue = 10;
    
    PrintFunctionsToChart397();
    
}

void PrintFunctionsToChart397()
{
    string temp = "Some Text\n";
    temp = temp + "------------------------------------------------\n"
    + "Highest high from bar(2) to bar(5) " + DoubleToStr(High[iHighest(NULL,PERIOD_H4,MODE_HIGH,5,2)], 5) + "\n"
    + "Some text " + DoubleToStr(0, 5) + "\n"
    + "Some text " + DoubleToStr(0, 5) + "\n"
    + "Some text " + DoubleToStr(0, 5) + "\n"
    + "------------------------------------------------\n";
    Comment(temp);
    
}



int deinit()
{
    if (false) ObjectsDeleteAll();
    
    
    return (0);
}
 
DoubleToStr(High[iHighest(NULL,PERIOD_H4,MODE_HIGH,5,2)], 5) 

You are finding the highest of bars 2 to 6, not 2 to 5.

If you run this on the H1 chart and the highest bar on the H4 chart is n

You then find the high of the nth bar of the H1 chart

That is why it appears to work correctly on the H4 chart 

 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. DoubleToStr(High[iHighest(NULL,PERIOD_H4,MODE_HIGH,5,2)], 5)
    You are mixing apples and oranges
 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You are mixing apples and oranges
Hi WHRoeder , thanks for the response , I  inserted the portion of the code you typed for me (your second message) and the results are the same. When on the 15 min time frame for example , the Highest High on the 4Hr chart displayed on the current chart , 15 Min in this example , changes at the beginning of every new 15min candle. And I believe that the H4 Highest high displayed on 15 min chart should remain the same for at least 16 bars.  
#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables


// local variables
double PipValue=1;    // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n";  // use this in custom or utility blocks where you need line feeds
int NDigits = 4;   // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;



int init()
{
    NDigits = Digits;
    
    if (false) ObjectsDeleteAll();      // clear the chart
    
    
    Comment("");    // clear the chart
    return (0);
}

// Expert start
int start()
{
    if (Bars < 10)
    {
        Comment("Not enough bars");
        return (0);
    }
    if (Terminated == true)
    {
        Comment("EA Terminated.");
        return (0);
    }
    
    OnEveryTick422();
    return (0);
}

void OnEveryTick422()
{
    PipValue = 1;
    if (NDigits == 3 || NDigits == 5) PipValue = 10;
    
    PrintFunctionsToChart490();
    
}

void PrintFunctionsToChart490()
{
    string temp = "Some Text\n";
    temp = temp + "------------------------------------------------\n"
    + "Some text " + DoubleToStr(DoubleToStr(High[iHighest(NULL,PERIOD_H4,MODE_HIGH,5,2)], 5), 5) + "\n"
    + "Some text " + DoubleToStr(0, 5) + "\n"
    + "Some text " + DoubleToStr(0, 5) + "\n"
    + "Some text " + DoubleToStr(0, 5) + "\n"
    + "------------------------------------------------\n";
    Comment(temp);
    
}



int deinit()
{
    if (false) ObjectsDeleteAll();
    
    
    return (0);
}
 
I already told you what the problem is
 
N22:Hi WHRoeder , thanks for the response , I  inserted the portion of the code you typed for me (your second message) and the results are the same.
  1. You didn't edit your original post's using SRC as Requested.
  2. I only posted one message and it had no code. It only quoted your line like the one below. Do you replaced your line with your line and got the same results. Why are you surprised?
  3. oubleToStr(High[iHighest(NULL,PERIOD_H4,MODE_HIGH,5,2)
    Since your code has exactly the same problem as your original post, you didn't bother to follow the links I provided and learn why, and you didn't bother to read GunRai's post which said the same thing. You've wasted enough of people's time
 
GumRai:

You are finding the highest of bars 2 to 6, not 2 to 5.

If you run this on the H1 chart and the highest bar on the H4 chart is n

You then find the high of the nth bar of the H1 chart

That is why it appears to work correctly on the H4 chart 

Hi Guys please bare with me here for asking questions that seem basic. I know understand your meaning GumRai. My next question is , is it then possible to do what I am trying to do, which is to fetching the exact value of the highest high from a higher time frame. ( My apologies for the waste of time)
 
N22:
Hi Guys please bare with me here for asking questions that seem basic. I know understand your meaning GumRai. My next question is , is it then possible to do what I am trying to do, which is to fetching the exact value of the highest high from a higher time frame. ( My apologies for the waste of time)

Of course it is possible.

You just need to learn the difference between

High[] and iHigh()

You already know how to use iHighest, so it should be simple for you to use iHigh 

 
GumRai:

Of course it is possible.

You just need to learn the difference between

High[] and iHigh()

You already know how to use iHighest, so it should be simple for you to use iHigh 

Thanks , advice helped figure it out
Reason: