Skip to content
All library documents

Building Five-Minute OHLC Bars for Pivot Support and Resistance

Article Quant Q&A · Author: Valentin Garreau

Summary

The document addresses how to calculate pivot points and first support and resistance levels from a stream of trade data. The key preprocessing step is to aggregate trades into five-minute bars using calendar time. Each bar should contain its open, high, low, and close for that interval; the pivot formulas then use the bar’s high, low, and close rather than averages across a collection of raw records or a single arbitrary row.

The answer is concise and focuses on the distinction between time-based bars and economic-time sequences. It does not specify how to handle intervals with no trades, market-session boundaries, time zones, or whether a pivot should use the current or prior bar. Those choices affect implementation and should be set consistently for the intended instrument and trading convention. The source offers no performance evidence for pivot levels as a trading signal; it explains only the data construction needed to calculate them.

Key ideas

  • Pivot calculations require OHLC values aggregated over the intended five-minute calendar intervals.
  • The open and close represent the first and last traded prices within a bar.
  • The high and low are the maximum and minimum prices observed during that interval.
  • Raw trades should not be averaged together as substitutes for a five-minute OHLC bar.

Tags

Full text
# Calculate resistance / support on 5 minutes timeframe


# Calculate resistance / support on 5 minutes timeframe












I'm starting to learn resistance / support.

I'm trying to calculate it, but i'm not sure to understand something.

Let say i have an array of 5 last trades done (i can have much more, it's just for the example) : `[[1611965400000, 107.145, 107.434, 107.0, 107.029, 230.9], [1611965700000, 107.033, 107.182, 106.714, 106.73, 490.3], [1611966000000, 106.708, 106.834, 106.524, 106.545, 390.3], [1611966300000, 106.603, 106.626, 106.038, 106.154, 597.3], [1611966600000, 106.145, 106.311, 106.037, 106.188, 462.9]]`

Here what value is equal in my array of data:

```
[
    [
        1504541580000, // UTC timestamp in milliseconds, integer
        4235.4,        // (O)pen price, float
        4240.6,        // (H)ighest price, float
        4230.0,        // (L)owest price, float
        4230.7,        // (C)losing price, float
        37.72941911    // (V)olume (in terms of the base currency), float
    ],
    ...
]
```

To calculate the pivot /support / resistance i have to do that :

```
 pp = (high + low + close) / 3
 r1 = 2 * pp - low 
 s1 = 2 * pp - high
```

But, for high / low / close, should i take the average of all my data in array? or should i take only the last element ? or should i take the highest for the high, the lowest for the low, but what for the close ?

Thank for your help !

## Answer by user42108 (score 1)

https://quant.stackexchange.com/a/60873

"for high / low / close, should i take the average of all my data in array"

You require OHLC data based on calendar time, not economic time. You will need to create 5-minute bars from the trade data.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.