Skip to content
All library documents

Initializing Parabolic SAR from the First Two Price Bars

Article Quant Q&A · Author: Matthew Hewitt

Summary

This note explains one implementation’s method for choosing the initial Parabolic SAR value when calculating the indicator from FX price data. It uses the first two bars’ highs to infer the initial direction: when the first high is below the second, it treats the SAR as rising and sets the initial value to the lower of the first two lows. Otherwise, it treats the SAR as falling and uses the higher of the first two highs.

The explanation comes from reverse-engineering implementations and includes a short code excerpt, rather than a full mathematical derivation or comparison of standard conventions. It addresses initialization from new data, but does not fully explain how to set the SAR at later reversals or define the remaining indicator parameters. Implementations may differ, so this rule should be checked against the specific Parabolic SAR definition being used.

Key ideas

  • The described initialization method infers the initial SAR direction by comparing the first two highs.
  • For a rising SAR, the initial value is the lower of the first two lows.
  • For a falling SAR, the initial value is the higher of the first two highs.
  • The answer is based on reverse-engineering implementations rather than a complete formal definition.

Tags

Full text
# How do you calculate the initial prior SAR value in a Parabolic SAR over FX market data


# How do you calculate the initial prior SAR value in a Parabolic SAR over FX market data












So I am attempting to calculate the Parabolic SAR over FX market data. I understand that the SAR equation is:

```
SARt = SARt-1 + * [EPt-1 - SARt-1]
```

with EPt-1 changing depending on if it is a rising or falling SAR but my question is how is the initial/prior SAR (SARt-1) calculated at first with new data or at a transition point (changing from a rising to failing SAR).

Any advice or books with the full mathematical definition would be much appreciated. Many thanks.

## Answer by Matthew Hewitt (score 1, accepted)

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

So after looking through and doing some reverse engineering of some implementations I think I have found the answer.

```
public static ParabolicSAR GenerateFirstSAR (ParabolicSAR sar,double[] high, double[] low) {
    if (high[0] < high[1]) {
        ...
        sar.sars.add(Math.min(low[0], low[1]));
        ...
    } else {
        ...
        sar.sars.add(Math.max(high[0], high[1]));
        ...
    }
    return sar;
}
```

In this high is an array of all the high points but you really only need 2 and then low is the low points. Same rule applies.

So this broken down means that for a rising condition the primary SAR is the minium value from the first 2 low points.

> Math.min(low[0], low[1])

And visa versa for a failing condition.

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.