SZSE:159949   创业板50
Sometimes when inspiration comes, you have to grasp it in time and quickly turn your ideas into code. It is said that I suddenly wanted to explore SAR today, but the original plan was disrupted. I summed up some past scripts wholeheartedly, and released the sar_ta library.


A common SAR is an acronym for "Stop And Reveres". It means stop loss turning and was created by American technical analysis guru Wells Wilder. It is an easy-to-learn and relatively accurate medium- and short-term technical analysis tool. SAR uses a parabolic method to adjust the position of the stop loss at any time to observe the buying and selling points. Because the stop loss point (also known as the turning point) moves in an arc, many people in China call it the parabolic turning indicator.

SAR has two meanings:

One is "Stop", which means stop loss, stop loss, which requires investors to set a stop loss price before buying or selling a stock to reduce investment risks. And this stop-loss price is not always the same, it is constantly adjusted with the fluctuation of the stock price. How to effectively control potential risks without missing the opportunity to earn greater returns is the goal pursued by every investor. However, the stock market situation is unpredictable, and different stocks have different trends in different periods. If the stop loss level is set too high, the stock may be sold when it adjusts and falls, and the sold stock will expand from then on. A new uptrend misses the opportunity to earn greater profits. On the contrary, if the stop loss is set too low, it will not be able to control the risk at all. Therefore, how to accurately set the stop loss level is the purpose of various technical analysis theories and indicators, and the SAR indicator has its own unique function in this regard.

The second is "Reverse", which means reversal and reverse operation, which requires investors to set a stop loss level before deciding to invest in stocks. The stock is closed, and the reverse short operation can be carried out while the position is closed, in order to maximize the income. At present, the domestic market does not allow shorting, so investors mainly use two methods. One is to sell the stock in time and wait and see when the stock price falls below the stop-loss price. When the time comes, buy stocks in time or hold stocks to rise.

Compared with other technical indicators, the SAR indicator can provide considerable help for quantitative investment, and it is simple and easy to operate:

1. Hold currency and wait and see. When the stock price of a stock is suppressed by the SAR indicator and keeps moving downward, investors can wait and see until the stock price breaks through the pressure of the SAR indicator and issues a clear buy signal before considering whether to buy or not. stock.

2. The shareholding is pending. When the stock price of a stock is above the SAR indicator and keeps moving upwards relying on the SAR indicator, investors can hold the stock all the way up until the stock price breaks down the support of the SAR indicator and issues a clear sell signal, then consider whether to sell or not. out of stock.

3. Clear stop loss. The SAR indicator has a very clear stop loss function, and its stop loss is divided into buy stop loss and sell stop loss. Sell ​​stop loss means that when the SAR sends a clear buy signal, no matter what price the investor sold the stock at before and whether it lost or not, the investor should buy the stock in time and hold the stock to rise. Buy stop loss means that when the SAR indicator sends a clear sell signal, no matter what price the investor bought the stock at before and whether it made a profit or not, the investor should sell the stock in time and wait and see.

Hercules SAR is a private SAR I released, which is conveniently referred to as "Hercules SAR". The first goal of optimizing it is to be closer to the price trend, and the second is to filter out some short-term trend jitters. I compared it graphically with the traditional SAR, with Hercules in red and SAR built into TradingView in blue.

A common SAR is an acronym for "Stop And Reveres". It means stop loss turning and was created by American technical analysis guru Wells Wilder. It is an easy-to-learn and relatively accurate medium- and short-term technical analysis tool. SAR uses a parabolic method to adjust the position of the stop loss at any time to observe the buying and selling points. Because the stop loss point (also known as the turning point) moves in an arc, many people in China call it the parabolic turning indicator.

SAR has two meanings:

One is "Stop", which means stop loss, stop loss, which requires investors to set a stop loss price before buying or selling a stock to reduce investment risks. And this stop-loss price is not always the same, it is constantly adjusted with the fluctuation of the stock price. How to effectively control potential risks without missing the opportunity to earn greater returns is the goal pursued by every investor. However, the stock market situation is unpredictable, and different stocks have different trends in different periods. If the stop loss level is set too high, the stock may be sold when it adjusts and falls, and the sold stock will expand from then on. A new uptrend misses the opportunity to earn greater profits. On the contrary, if the stop loss is set too low, it will not be able to control the risk at all. Therefore, how to accurately set the stop loss level is the purpose of various technical analysis theories and indicators, and the SAR indicator has its own unique function in this regard.

The second is "Reverse", which means reversal and reverse operation, which requires investors to set a stop loss level before deciding to invest in stocks. The stock is closed, and the reverse short operation can be carried out while the position is closed, in order to maximize the income. At present, the domestic market does not allow shorting, so investors mainly use two methods. One is to sell the stock in time and wait and see when the stock price falls below the stop-loss price. When the time comes, buy stocks in time or hold stocks to rise.

Compared with other technical indicators, the SAR indicator can provide considerable help for quantitative investment, and it is simple and easy to operate:

1. Hold currency and wait and see. When the stock price of a stock is suppressed by the SAR indicator and keeps moving downward, investors can wait and see until the stock price breaks through the pressure of the SAR indicator and issues a clear buy signal before considering whether to buy or not. stock.

2. The shareholding is pending. When the stock price of a stock is above the SAR indicator and keeps moving upwards relying on the SAR indicator, investors can hold the stock all the way up until the stock price breaks down the support of the SAR indicator and issues a clear sell signal, then consider whether to sell or not. out of stock.

3. Clear stop loss. The SAR indicator has a very clear stop loss function, and its stop loss is divided into buy stop loss and sell stop loss. Sell ​​stop loss means that when the SAR sends a clear buy signal, no matter what price the investor sold the stock at before and whether it lost or not, the investor should buy the stock in time and hold the stock to rise. Buy stop loss means that when the SAR indicator sends a clear sell signal, no matter what price the investor bought the stock at before and whether it made a profit or not, the investor should sell the stock in time and wait and see.

Hercules SAR is a private SAR I released, which is conveniently referred to as "Hercules SAR". The first goal of optimizing it is to be closer to the price trend, and the second is to filter out some short-term trend jitters. I compared it graphically with the traditional SAR, with Hercules in red and SAR built into TradingView in blue.


SZSE:159949 ChiNext 50 Quotes from TradingView

The other one, which I think is better optimized is Taurus SAR, which is recorded as "Taurus" SAR. In contrast, it pays more attention to the filtering of disturbance signals. The comparison is as follows, the yellow is Taurus, and the blue is the built-in classic SAR of TradingView.

SZSE: 159949 GEM 50 quotes from TradingView
SAR's criteria for judging price trends are mainly:

1. When the stock price starts to break above the SAR curve from below the SAR curve, it is a buy signal, indicating that a round of rising stock prices may unfold, and investors should buy stocks quickly and in a timely manner.

2. When the stock price breaks through the SAR curve and continues to move upward and the SAR curve moves upward at the same time, it indicates that the upward trend of the stock price has been formed, and the SAR curve constitutes a strong support for the stock price. Overweight to buy stocks.

3. When the stock price starts to break down the SAR curve from the top of the SAR curve, it is a sell signal, indicating that a round of decline in the stock price may start. Investors should sell the stock quickly and in a timely manner.

4. When the stock price breaks through the SAR curve and continues to move downward, and the SAR curve also moves downward at the same time, it indicates that the downward trend of the stock price has been formed, and the SAR curve poses huge pressure on the stock price. Investors should resolutely hold the currency and wait and see. High lighten up.

Of course, the above is just a classic point of view. In a comprehensive quantitative system, SAR is only a good functional module, and it still needs to resonate with other factors to judge the market.

sar_ta is an impure sar_ta library

The original intention is to compare the performance of various similar SARs in order to screen better strategic factors. It turns out that there are actually very few variants of pure SAR technology. However, there are many SAR-like technologies that have already emerged. Therefore, this library also includes similar technical indicators such as Gann Hilo activator and Chandelier Exit, which are rare but work well.


I finally decided to open source this library to facilitate more people to learn and exchange SAR-like technologies. For members of the community who can provide me with some help, I have clearly written some incentives on the sar_ta library release page, which can not only activate the atmosphere, but also benefit each other.

Avoid losing contact!Don't miss out! The first and most important thing to do is to join my Discord chat now! Click here to start your adventure: discord.com/invite/ZTGpQJq 防止失联,请立即行动,加入本猫聊天群: discord.com/invite/ZTGpQJq
免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。