Hi,

Assume I am running this in 5 minutes time frame. I can calculate Highest High of first 15 minutes using the below code which is working fine like shown below.

```
ValueWhen( EndBar, HighestSince( StartBar, High ))
```

Now I have to calculate average of first 15 minutes high say 5 periods of back. I tried using the below formula but with no luck. Any advice or help is much appreciate.

```
MA(ValueWhen( EndBar, HighestSince( StartBar, High )),5);
```

Thanks,

Vinay

@vinaykumar I am not sure I understand what you want but maybe something like this?

```
Condition1 = ValueWhen( EndBar, HighestSince( StartBar, High ));
AveCondition1 = MA(Condition1, 5);
```

I did the same thing like you have shown. Its not working as expected. I need average of first 15 minutes High of previous periods.

```
MA(ValueWhen( EndBar, HighestSince( StartBar, High )),5);
```

The above code is same as the one you mentionedâ€¦

@vinaykumar Yes you are correct, sorry for the wasted post. I don't have my intraday database to use and I am not sure what you want.

My interpretation is ,

you are using 5 minute bars

you want the Highest High of the past 3 bars ("15 minutes")

you want to average the past 5 values of that Highest High

This code works as just described

```
Condition = HHV( High, 3 ); // if using 5 minute bars you have 3 bars in 15 minutes
AveCondition = MA( Condition, 5 ); // every bar find the average
Filter = 1;
AddColumn( High, "High" );
AddColumn( Condition, "Highest H in past 3 bars" );
AddColumn( AveCondition, "Ave of last 5" );
```

Another possible interpretation (you are not clear in your question) is you do not want the average every bar (in your case every 5 minutes). You want to jump ahead every 15 minutes (3 bars) and get a new number generated by looking at the Highest High in the first 15 minutes, then at 30 minutes, then at 45 minutes, etc. And you want those averages. If that is the case, sorry can't help at this time.

1 Like

Thanks @portfoliobuilder for your response. Let me again explain clearly. Indian market starts at 9:15 AM. I am using 5 minutes timeframe. I have defined start time as 9:15 AM and 9:25 AM, so I am considering here 3 5 mins candles. I can easily calculate the highest of the 3 candles, that part I have done. Now I want to calculate the average of past 5 days first three 5 minutes candles.

For example

9/6 - 100, 101, 102 (So highest is 102)

9/5 - 101.5, 101.75, 101.6 (So highest is 101.75)

9/4 - 101.5, 101.75, 101.6 (So highest is 101.75)

9/3 - 101.5, 101.75, 101.6 (So highest is 101.75)

9/2 - 101.5, 101.75, 101.6 (So highest is 101.75)

Average of first 3 candles of past 5 days is (102+101.75+101.75+101.75+101.75) / 2