PDA

View Full Version : Nested loops


traderT
12-21-2008, 02:22 PM
Hi,

I am getting an out of bounds error with the following code and I am hoping that it is something stupid and easily rectifyable. Any ideas why?

protectedoverridevoid OnBarUpdate()
{
if(CurrentBar <= 500)return;

{
for (int bBar = 2; bBar < 49; bBar++)
{
bValue = Low[bBar];
for (int aBar = 3; bBar < 48; aBar++)
{
aValue = High[aBar];

for (int xBar = 4; xBar < 47; xBar++)
{
xValue = Low[xBar];
}
}

if((High[1] > BullCa() -5)
&& (High[1] < BullCa() +5))
{
Plot0.Set(bValue);
};
Print("bValue = " + bValue + " :aValue = " + aValue + " :xValue = " + xValue + " :cValue = " + BullCa());
}

Ralph
12-21-2008, 02:36 PM
for (int aBar = 3; bBar < 48; aBar++)

This for-loop would loop for ever, if it could.

Regards
Ralph

traderT
12-21-2008, 02:52 PM
Changed the bBar to an aBar and that has got rid of the out of bounds error. Now to figure out if it does what I want ;-)