# Running For Loop Bar wise?

507

I have seen for loop here works tick wise. How to run the loop bar wise?

I want to add +1 pip from the low in per bar in 1 minute chart. I am creating Gann 1x1 Angles, where for each bar angle will rise +1 pip upto 120 bars.

```if( LowT < HighT)  // If low formed first
{
datetime i;
for( i = LowT; i < (LowT + (7200)); i++) // Time counting for next 2 hours
{
for (int k = 0; k <120; k++)
{
A = low + ((double)k * CalcPoint);  // Adding 0.0001 with k
printf(StringConcatenate("Low angle = ",DoubleToString(A,5)));
}
}
}```

Now in above code, "k" is basically adding +1 absolutely ok but not per bar wise, per tick wise. So I am getting wrong data.  Cause after 120 tick it again going into the loop.

How to run the loop bar wise? I want to store 1x1 angle data for 80 bar from that LowT time & low. Do I have to introduce array?

Thank you

15577

1. I have no idea what you are trying to say. It sounds like babble.
2. `for( i = LowT; i < (LowT + (7200)); i++)`
if LowT is a datetime, as is i, you are incrementing time. If you want to find which bar corresponds to a time, use iBarShift
507

WHRoeder:
1. I have no idea what you are trying to say. It sounds like babble.
2. if LowT is a datetime, as is i, you are incrementing time. If you want to find which bar corresponds to a time, use iBarShift

Sorry to put it in that way. Here I explain with examples.

Suppose I draw Gann angle 1x1 from 50 which is a low. Now According to the Angle methods, it grows 1 pip per unit of time (i.e current chart bar). In following way.

Angle [0]  = 50 at T time

Angle [1] = 51 at T1 time

Angle [2] = 52 at T3  time.

...... upto Angle [120]

Now I need to store this data & compare with "Ask" price, so every time "Ask" = "Angle[i]" , I buy. Now with above code I try to calculate angle levels. But " for" loop is adding +1 with the low with each tick, not with each current bar.

15577

You know the low (50) you know the bar index iBarShift(... T ) You know the current bar index (0) Therefor you know the "Angle" = 50 + iBarShift * pip. No loops, no arrays.
507

WHRoeder:
You know the low (50) you know the bar index iBarShift(... T ) You know the current bar index (0) Therefor you know the "Angle" = 50 + iBarShift * pip. No loops, no arrays.
Thank you so much! It worked with less headache...