Parabolic SAR Strategy

Description

Parabolic SAR (Stop and Reversal) strategy is a trading algorithm which role is to predict market trend change and buy / sell an asset in a specific market conditions. It works well in a bull or bear markets. If a market is neither bear nor bull then SAR coefficient does not have to be helpful and SAR coefficient might be ‘belated’.

Values of all the variables defined in the following paragraphs, except l_t \text{ and } h_t, are not defined for t = 1.

Lets define by h_t (l_t) the market high (low) at the end of a day t. Moreover, O_t is a strategy’s opinion about market trend at the day t. It has value +1 if the opinion is uptrend, and -1 otherwise. It will be formally defined later. To defined it precisely (by a math expression) we need first define Extreme Point (EP), Acceletarion Factor (AF) and Stop and Reverse (SAR) variables.

A variable EP_t, if o_t = +1, is the highest value of a high from the beginning of the uptrend. Similarly, if market o_t = -1, it is the lowest value of low from the beginning of the downtrend. Formally we can defined it as follows:

EP_t =
\begin{cases}
  max(h_1, h_2) & t = 2 \wedge O_2 = +1 \\
  min(l_1, l_2) & t = 2 \wedge O_2 = -1 \\
  max_{c < i \leq t} h_i & O_t = +1 \wedge t \geq 3 \\
  min_{c < i \leq t} l_i & O_t = -1 \wedge t \geq 3
\end{cases}

where c < t is the biggest value for which O_{c-1} \neq  O_{c}. If there is no such c (there was no trend change from the time when the strategy starts) then we should set c to 1. To sum up: the value of EP_t is the highest high or the lowest low of the current trend.

A variable AF is a kind of a counter which is set to Acceleration Coefficient when the strategy’s opinion about market trend has changed, it is usually equal to 0.02. Moreover it is increased by Acceleration Coefficient when the new extreme value of EP is found (either high or low depending on the strategy’s opinion about market trend). It is worth to mention that its value cannot exceed Acceleration Limit, by default 0.2. Lets define it formally:

AF_t =
\begin{cases}
  Acceleration~coefficient & O_t \neq O_{t-1} \vee t = 2 \\
  min(Acceleration~limit, AF_{t-1} + Acceleration~coefficient) & EP_{t-1} \neq EP_{t} \\
  min(Acceleration~limit, AF_{t-1}) & otherwise
\end{cases}

The SAR coefficient is defined as a function of its previous value, AF and EP. Formally we can defined it as follows:

SAR_t =
\begin{cases}
  h_t & O_{t} = -1 \wedge t = 2 \\
  l_t & O_{t} = +1 \wedge t = 2 \\
  SAR_{t - 1} + AF_{t-1} \times (EP_{t-1} - SAR_{t-1}) & O_{t} = O_{t-1} \wedge t \geq 3 \\
  min(l_t, EP_{t-1}) & O_{t} \neq O_{t-1} \wedge O_{t} = +1 \wedge t \geq 3 \\
  max(h_t, EP_{t-1}) & O_{t} \neq O_{t-1} \wedge O_{t} = -1 \wedge t \geq 3
\end{cases}

Additionally, when SAR indicator is rising it cannot stay above last two intervals’ low price. When the indicator is falling - it cannot stay below maximum of last two intervals’ high price, either. So, if O_t = 1 and calculated SAR value is bigger than last two periods’ low price (l_{t-1}, l_{t-2}), then SAR value is set to min(l_{t-1}, l_{t-2}). Analogous, if O_t = -1 and calculated SAR value is smaller than last two periods’ high price (h_{t-1}, h_{t-2}), then SAR value is set to max(h_{t-1}, h_{t-2}).

Finally we can give a formal definition of the O_t. Its definition is the following:

O_t =
 \begin{cases}
   \frac{h_2 - h_1}{|h_2 - h_1|} & t = 2 \\
   +1 & SAR_t < l_t\wedge t \geq 3 \\
   -1 & SAR_t > h_t \wedge t \geq 3 \\
       -O_{t-1} & otherwise
\end{cases}

As you can see the decision about a actual trend is normally made on the basis of the comparision between the SAR coefficient and the local high (low). At the beginning (t \leq 2) we have to determine whether we have an uptrend or downtrend. In above formula fleeting high prices have been used, but this automatic method can be replaced by a parameter Initial Market Trend basing on the user’s opinion.

Market Data

  • Last trade
  • Historical market data

Parameters

Parameter name Description Essential
Acceleration Coefficient Coefficient of acceleration factor, usually set to 0.02 by default Yes
Acceleration Limit Upper limit of acceleration factor, usually set to 0.2 by default Yes
Initial Market Trend Initial market trend set arbitrary by an user No

Conditions

Open position

Side Buy or Sell
Amount One asset per order
Price Last market price
Type Price limit

Consider day t \geq 3. If strategy does not have an open position and:

  • O_{t} = +1 \wedge O_{t-1} = -1 \rightarrow algorithm opens long position
  • O_{t} = -1 \wedge O_{t-1} = +1 \rightarrow algorithm opens short position

Close position

Consider day t \geq 3. If strategy does have an open position and:

  • O_{t} = +1 \wedge O_{t-1} = -1 \rightarrow algorithm closes short position
  • O_{t} = -1 \wedge O_{t-1} = +1 \rightarrow algorithm closes long position

Termination

There is no strategy termination condition.

Time frame

Strategy is designed for long-term trading, usually for whole weeks.

Further information & source

PLEASE NOTE: Empirica does not provide tax, investment, or financial services. The information available through this website is provided on an "as is" basis at user's sole risk and does not constitute trading advice or a solicitation to buy or sell any stock, option, future, commodity, or forex product. Empirica makes no guarantees as to the accurateness, quality, or completeness of the information and shall not be responsible or liable for any errors, omissions, inaccuracies in the information or for any user's reliance on the information. User is solely responsible for verifying the information as being appropriate for user's personal use, including without limitation, seeking the advice of a qualified professional regarding any specific financial questions a user may have. Past performance is not necessarily an indication of future performance. Trading is inherently risky.