So, in this chapter, we’re going to take a closer look at how the Parabolic SAR strategy works. After seeing how it played out with Reliance in the previous chapter, it’s time to break down the basics. We’ll start by understanding the key settings that control how the Parabolic SAR behaves.
We’ll then move on to spotting market trends which is what this strategy is all about. We’ll learn how to tell if prices are likely going up or down, and how the strategy responds to these changes.
We’ll also talk about how to spot points where trends might flip, and how to make buying or selling decisions based on what the strategy tells us. This is key to making smart trades.
Plus, we’ll go over how the strategy speeds up or slows down based on price movements, and we’ll see how to plot these details on a chart to visualize what’s going on.
Lastly, we’ll wrap it up with a step-by-step walkthrough of how the strategy works, written in a programming-like way to clearly outline the logic.
So, there’s a lot to cover but it will give us a solid understanding of how the Parabolic SAR strategy works, setting us up to use it smartly in our future trades.
The behavior of the Parabolic SAR is governed by three key parameters:
The first step in the strategy is to identify the prevailing trend:
Once the trend is identified, the Parabolic SAR behaves accordingly:
Reversals are a key aspect of market behavior:
Based on the trend information, trading decisions are made:
The AF is crucial for adjusting the SAR’s sensitivity towards price movements:
The strategy employs plots to visualize the SAR values, providing a clear representation of the market’s trend and potential reversal points.
A well-defined pseudo code encapsulates the logic of the strategy, providing a step-by-step blueprint of the operations, from trend identification to trading decisions, all under the governance of the defined parameters.
Initialize variables: start, increment, maximum, uptrend, EP, SAR, AF, nextBarSAR, firstTrendBar For each bar in the price data: Determine the trend based on the closing prices of the current and previous bars. If it's the first bar of a new trend: Set initial SAR, EP, and AF values based on the price data. If in an uptrend: If SAR value drops below the lowest price of the current or previous bar: Detect a trend reversal to downward. Adjust SAR, EP, and AF values. If in a downward trend: If SAR value rises above the highest price of the current or previous bar: Detect a trend reversal to upward. Adjust SAR, EP, and AF values. If not the first bar of the new trend: Adjust AF value if a new high (in an upward trend) or a new low (in a downward trend) is made. Calculate the next bar's SAR value based on the current SAR, EP, and AF values. If a bar is confirmed: Enter or exit trades based on the trend and SAR value. Plot the current and next bar's SAR values.
class ParabolicSARStrategy: def __init__(self, start=0.02, increment=0.02, maximum=0.2): self.start = start self.increment = increment self.maximum = maximum self.uptrend = None self.EP = None self.SAR = None self.AF = start self.nextBarSAR = None self.firstTrendBar = False def calculate(self, bars): for i in range(len(bars)): if i > 0: self.firstTrendBar = False self.SAR = self.nextBarSAR if i == 1: prevSAR = prevEP = lowPrev = highPrev = closeCur = closePrev = None lowPrev, highPrev = bars[i-1]['low'], bars[i-1]['high'] closeCur, closePrev = bars[i]['close'], bars[i-1]['close'] if closeCur > closePrev: self.uptrend = True self.EP = bars[i]['high'] prevSAR, prevEP = lowPrev, bars[i]['high'] else: self.uptrend = False self.EP = bars[i]['low'] prevSAR, prevEP = highPrev, bars[i]['low'] self.firstTrendBar = True self.SAR = prevSAR + self.start * (prevEP - prevSAR) if self.uptrend: if self.SAR > bars[i]['low']: self.firstTrendBar = True self.uptrend = False self.SAR = max(self.EP, bars[i]['high']) self.EP = bars[i]['low'] self.AF = self.start else: if self.SAR < bars[i]['high']: self.firstTrendBar = True self.uptrend = True self.SAR = min(self.EP, bars[i]['low']) self.EP = bars[i]['high'] self.AF = self.start if not self.firstTrendBar: if self.uptrend: if bars[i]['high'] > self.EP: self.EP = bars[i]['high'] self.AF = min(self.AF + self.increment, self.maximum) else: if bars[i]['low'] < self.EP: self.EP = bars[i]['low'] self.AF = min(self.AF + self.increment, self.maximum) if self.uptrend: self.SAR = min(self.SAR, bars[i-1]['low']) if i > 1: self.SAR = min(self.SAR, bars[i-2]['low']) else: self.SAR = max(self.SAR, bars[i-1]['high']) if i > 1: self.SAR = max(self.SAR, bars[i-2]['high']) self.nextBarSAR = self.SAR + self.AF * (self.EP - self.SAR) # Additional logic for entering/exiting trades and plotting can be added here # Usage: # Assume bars is a list of dictionaries where each dictionary contains the open, high, low, and close prices for each bar. # strategy = ParabolicSARStrategy() # strategy.calculate(bars)
In this Python code, the
ParabolicSARStrategy class is defined, which encapsulates the logic of the strategy. The
calculate method processes a list of price bars, executing the logic of the strategy for each bar.
The Parabolic SAR strategy provides a structured approach for traders to navigate market trends, making informed entry and exit decisions. We will explore this strategy by applying it to various stocks and see their outcome.
By understanding the operational mechanics and the governing parameters of the Parabolic SAR, traders are well-positioned to utilize this strategy for enhanced trading outcomes.
Similar to how the Entropy strategy relies on Bollinger Bands, it also incorporates the use of Parabolic SAR for making trading decisions.
However, a common drawback persists; both these strategies operate under the assumption that the stock price distribution follows a normal distribution.
Therefore, in scenarios where this assumption is disrupted, especially during fundamental news releases or any other significant market events, it’s advisable to refrain from employing the Entropy or Parabolic SAR strategies.