DaveSkender / Stock.Indicators

Stock Indicators for .NET is a C# NuGet package that transforms raw equity, commodity, forex, or cryptocurrency financial market price quotes into technical indicators and trading insights. You'll need this essential data in the investment tools that you're building for algorithmic trading, technical analysis, machine learning, or visual charting.
https://dotnet.StockIndicators.dev
Apache License 2.0
957 stars 237 forks source link

Parabolic SAR has any bugs #1226

Closed Sonovogod closed 1 month ago

Sonovogod commented 1 month ago

What happened?

Hello, today I was watching my new strategy based on the SAR indicator and noticed that its work often differs from the same indicator on TraidingView with the same settings.

On TraidingView the indicator works correctly, shows a reversal on time, and does not intersect with the price On SAR In the indicator from the library, I noticed problems with reversals, not always, but very often, SAR notices a reversal with a delay of three candles, and until that moment it continues to draw levels, although they already intersect with the price.

Tested on a minute timeframe

Code usage

No response

Log output

No response

Sonovogod commented 1 month ago

Here is an example, here you can see on the screen that a reversal occurred on the SAR indicator taken from Binance, but not yet on the SAR from the library, also if you look at the time 00:59 on the chart in Binance SAR there are dots above the price chart, while the SAR from the libraries are still downstairs

P.S Don't pay attention to the time, different time zone with Binance chart (+5)

1 2 3

DaveSkender commented 1 month ago

Based on my analysis in #1031, you cannot get these to match since there are at least two observable bugs in the TradingView code. In other words, the TradingView version is incorrect. More info:

What you're showing is this library's correct implementation of the 2-day rule that says "never move the SAR into the previous day's range or today's range. [When long] if the SAR is calculated to be above the previous day's low or today's low, then use the lower low ... as the new SAR." - page 11, New Concepts in Technical Trading Systems, by Welles Wilder, Jr.