This simple code is not working and i cant understand why? Can someone explain?

 
//--------------------------------------------------------------------

// Tester_Invert.mq4

// To be used as an example in MQL4 book.

#include <stdlib.mqh>

#include <WinUser32.mqh>

//--------------------------------------------------------------------

// Global variable

//--------------------------------------------------------------------

int init() // Spec. funct. init()

{

Alert("Function init() triggered at start"); // Alert

return; // Exit init()

}

//-----------------------------------------------------------------------

int start() // Spec. funct. start()

{

for(int i=5; i<=3; i--)

{

Alert("High[",i,"] = ", High[i]);

Alert("High[",i-1,"] = ", High[i-1]);

Alert("High[",i-2,"] = ", High[i-2]);

}

return(0);

}

I fail to understand why the for loop does not produce any output. All i need is to display the High[i] values of candles from 5 to 1 in the manner suggested by the for loop.

Can someone help clarify this ?

Thanks .

 

for(int i=5; i > =3; i--)

 
for(int i=5; i>=1; i--)
{
   Alert("High[",i,"] = ", High[i]);
} 
This would be better.......
 

"I fail to understand why the for loop does not produce any output."

for(int i=5; i<=3; i--)

That says start with i equal to five, and if i is less than or equal to three (which it is not), perform the code below then decrement i.

 
kennyhubbard:
This would be better.......


yes sir, you are right but if you substitute your loop for mine even that will not work.

for(int i=5; i>=1; i--)
{
Alert("High[",i,"] = ", High[i]);
}

The loop simply does not work as the alert displays no values for i. I am not able to figure why the loop is not functioning. If we do an incremental value of i instead of a decrment, it works. So why not for the decrmental values of i ? See if you can figure it out.

The reason i used 3 alearts is because i needed 3 consecutive values for each value of i.

Thanks.

 
phy:

"I fail to understand why the for loop does not produce any output."

for(int i=5; i<=3; i--)

That says start with i equal to five, and if i is less than or equal to three (which it is not), perform the code below then decrement i.


sir the loop simply produces no result. the alert within the loop gives no output. I want to know why if you can explain. Thanks
 
aps:

sir the loop simply produces no result. the alert within the loop gives no output. I want to know why if you can explain. Thanks
he explaind you already in detail why the loop will not work
 
zzuegg:
he explaind you already in detail why the loop will not work

did he ? where ? i cannot figure out. Kindly explain. Bear with my less knowledge of the language. Kindly elaborate. i'ld be grateful.
 
aps:

did he ? where ? i cannot figure out. Kindly explain. Bear with my less knowledge of the language. Kindly elaborate. i'ld be grateful.


oh is it that it shoud be >= instead of <= ?? in the testing of the loop ? is that the mistake ?

 
aps:


oh is it that it shoud be >= instead of <= ?? in the testing of the loop ? is that the mistake ?

i assume you are correct
 
kennyhubbard:
This would be better.......

Sir i think your code wud work. I think the testing part of my code was faulty. <=3 should have been >= 3 i guess. Thanks loads.
Reason: