# Offset Function (and Square Bracket Syntax)

Author: Optuma Team Last updated: Sep 13, 2022 10:00

The `Offset()` function can be used to calculate previous bar or tool values. The offset value is the number of lookback periods (bars by default), so the previous bar’s value would require an offset of 1, and two days ago a value of 2, etc.

To see if the current 50MA value is higher than it was 10 bars ago:

``````MA1 = MA(BARS=50);
MA1 > OFFSET(MA1, OFFSET=10)
``````

### Using square brackets for offsets

Instead of using the Offset function it’s also possible to use square brackets in a formula which contain the offset value for bars. Taking the 50MA example above using the 10 period offset, it can also be expressed as follows:

``````MA1 = MA(BARS=50);
MA1 > MA1[10]
``````

### Alternative Offset syntax for price bars

For open, high, low, and closing prices simply put the offset in value in the parentheses, eg the closing price 5 bars ago:

`CLOSE(5)` is the same as `CLOSE()[5]` which is the same as `OFFSET(CLOSE(), OFFSET=5)`

Low price 3 bars ago: `LOW(3)` High price 3 weeks ago: `HIGH(Week(PERIODAMOUNT=1), 3)`