nepalcargoservices.com

Combining Parabolic SAR and SuperTrend for Effective Trading

Written on

Understanding the Power of Two Indicators

In the world of trading, the combination of the Parabolic SAR and the SuperTrend indicators can yield sophisticated signals. This approach leverages the quick responsiveness of the SuperTrend alongside the confirmation provided by the Parabolic SAR, making it a compelling choice for trend-following traders. This article delves into the methodology of integrating these two indicators to identify trading opportunities.

Recently, I launched a new book following the success of my previous work, "New Technical Indicators in Python." This latest publication offers a comprehensive analysis and structured trading strategies, complete with a dedicated GitHub page for updated code. If you're intrigued, feel free to check it out on Amazon or reach out via LinkedIn for the PDF version.

Understanding the SuperTrend Indicator

To effectively utilize the SuperTrend indicator, one must first grasp the concept of volatility, often measured through the Average True Range (ATR). While the ATR is a lagging indicator, it provides valuable insights into current and past volatility levels.

The True Range is calculated as the maximum of three values:

  1. High - Low
  2. High - Previous Close
  3. Previous Close - Low

The ATR is simply the average of the True Range over a specific period. Typically, during periods of market distress, the ATR tends to rise, whereas it decreases during stable trends.

Keep in mind that the ATR is a lagging indicator and should be used judiciously. Below is a Python function for calculating the ATR, assuming you have an OHLC data array.

def adder(Data, times):

for i in range(1, times + 1):

new_col = np.zeros((len(Data), 1), dtype=float)

Data = np.append(Data, new_col, axis=1)

return Data

def deleter(Data, index, times):

for i in range(1, times + 1):

Data = np.delete(Data, index, axis=1)

return Data

def jump(Data, jump):

Data = Data[jump:, ]

return Data

After understanding ATR, we can move on to the SuperTrend indicator, which provides entry and exit signals for traders. It functions similarly to a moving average or MACD, but its unique calculation method sets it apart.

The two primary variables involved in the SuperTrend are the ATR lookback period and the multiplier, usually set to integers like 2 or 3. To begin, average the high and low prices of a bar, then adjust this average by adding or subtracting the product of the multiplier and ATR. This yields two arrays: the basic upper and lower bands, essential for constructing the SuperTrend.

The following code illustrates how to compute the SuperTrend:

def supertrend(Data, multiplier, atr_col, close, high, low, where):

Data = adder(Data, 6)

for i in range(len(Data)):

Data[i, where] = (Data[i, high] + Data[i, low]) / 2

Data[i, where + 1] = Data[i, where] + (multiplier * Data[i, atr_col])

Data[i, where + 2] = Data[i, where] - (multiplier * Data[i, atr_col])

for i in range(len(Data)):

if i == 0:

Data[i, where + 3] = 0

else:

if (Data[i, where + 1] < Data[i - 1, where + 3]) or (Data[i - 1, close] > Data[i - 1, where + 3]):

Data[i, where + 3] = Data[i, where + 1]

else:

Data[i, where + 3] = Data[i - 1, where + 3]

for i in range(len(Data)):

if i == 0:

Data[i, where + 4] = 0

else:

if (Data[i, where + 2] > Data[i - 1, where + 4]) or (Data[i - 1, close] < Data[i - 1, where + 4]):

Data[i, where + 4] = Data[i, where + 2]

else:

Data[i, where + 4] = Data[i - 1, where + 4]

for i in range(len(Data)):

if i == 0:

Data[i, where + 5] = 0

elif (Data[i - 1, where + 5] == Data[i - 1, where + 3]) and (Data[i, close] <= Data[i, where + 3]):

Data[i, where + 5] = Data[i, where + 3]

elif (Data[i - 1, where + 5] == Data[i - 1, where + 3]) and (Data[i, close] > Data[i, where + 3]):

Data[i, where + 5] = Data[i, where + 4]

elif (Data[i - 1, where + 5] == Data[i - 1, where + 4]) and (Data[i, close] >= Data[i, where + 4]):

Data[i, where + 5] = Data[i, where + 4]

elif (Data[i - 1, where + 5] == Data[i - 1, where + 4]) and (Data[i, close] < Data[i, where + 4]):

Data[i, where + 5] = Data[i, where + 3]

Data = deleter(Data, where, 5)

return Data

The above code calculates the SuperTrend for EUR/USD hourly values.

When interpreting the SuperTrend indicator, consider that if it appears above the market price, it suggests a potential short position, while if it is below, it indicates a possible long position. This indicator serves as a vital tool for capturing trends and exiting when they conclude.

Integrating the Parabolic SAR

The Parabolic Stop-and-Reverse (SAR) is another effective trend-following indicator developed by Wilder Wilder, also known for the RSI. It's primarily used as a trailing stop that follows the trend but can be utilized as a standalone trading strategy. While it performs well during steady trends, it may struggle in ranging markets.

To calculate the Parabolic SAR, you can leverage the talib library in Python. Below is a modified implementation of the SAR function:

def sar(s, af=0.02, amax=0.2):

high, low = s.high, s.low

sig0, xpt0, af0 = True, high[0], af

sar = [low[0] - (high - low).std()]

for i in range(1, len(s)):

sig1, xpt1, af1 = sig0, xpt0, af0

lmin = min(low[i - 1], low[i])

lmax = max(high[i - 1], high[i])

if sig1:

sig0 = low[i] > sar[-1]

xpt0 = max(lmax, xpt1)

else:

sig0 = high[i] >= sar[-1]

xpt0 = min(lmin, xpt1)

if sig0 == sig1:

sari = sar[-1] + (xpt1 - sar[-1]) * af1

af0 = min(amax, af1 + af)

if sig0:

af0 = af0 if xpt0 > xpt1 else af1

sari = min(sari, lmin)

else:

af0 = af0 if xpt0 < xpt1 else af1

sari = max(sari, lmax)

else:

af0 = af

sari = xpt0

sar.append(sari)

return sar

The primary idea is that when the Parabolic SAR (represented as dots around market prices) lies below the current price, the outlook is bullish, and when it is above, the outlook is bearish.

Creating the Trading Strategy

The strategy hinges on the confluence of signals from both indicators. The trading rules are as follows:

  • A long (buy) signal is generated when the market price rises above the SuperTrend while also being above the Parabolic SAR.
  • A short (sell) signal is triggered when the market price falls below the SuperTrend while also being below the Parabolic SAR.

The following code implements this strategy:

def signal(Data, close, psar_col, super_trend_col, buy, sell):

Data = adder(Data, 10)

for i in range(len(Data)):

if Data[i, close] > Data[i, psar_col] and

Data[i, close] > Data[i, super_trend_col] and

Data[i - 1, close] < Data[i - 1, super_trend_col]:

Data[i, buy] = 1

if Data[i, close] < Data[i, psar_col] and

Data[i, close] < Data[i, super_trend_col] and

Data[i - 1, close] > Data[i - 1, super_trend_col]:

Data[i, sell] = -1

return Data

This approach utilizes the SuperTrend as the primary trigger while the Parabolic SAR serves as a filter, improving signal quality.

When deploying this strategy, it is advisable to focus on trending markets, which can be assessed using indicators like the ADX or moving averages. You may also consider reversing the roles of the filter and trigger for alternative trading rules.

Conclusion

Always conduct thorough back-testing before implementing any strategy. While the indicators and strategies shared may work well for some, it's essential to customize and refine them to suit your unique trading style. My intention is to inspire thought and innovation in trading strategies beyond conventional methods.

For a deeper dive into technical indicators, consider my best-selling book on the subject.

Lastly, I have recently launched an NFT collection aimed at supporting various humanitarian causes. Each sale contributes a portion to charity, allowing you to invest while also making a positive impact. For every NFT purchase, buyers receive a free PDF copy of my latest book.

In this video, we explore the Supertrend Indicator Strategy utilizing the Parabolic SAR for intraday trading, providing insights into maximizing trading potential.

This video demonstrates how to effectively use the Parabolic SAR indicator in trading, illustrating its application and effectiveness in various market scenarios.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Enhancing Social Awareness with Colleagues and Clients

Explore ways to build genuine connections with colleagues and clients through social awareness and empathy.

# The Wily Fox and the Truthful Chicken: A Lesson on Integrity

A clever fox and an honest chicken teach valuable lessons about honesty and caution.

Transform Your Daily Routine: 4 Habits for Extraordinary Days

Discover how four simple daily habits can transform ordinary days into extraordinary ones for a fulfilling life.