From 227a42b36be4551c8d38ef17d5dbaeeb6963349c Mon Sep 17 00:00:00 2001 From: Abyss Alora Date: Mon, 6 Jun 2022 08:21:56 +0200 Subject: [PATCH] PSAR fix to fit TV --- pandas_ta/trend/psar.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas_ta/trend/psar.py b/pandas_ta/trend/psar.py index 576759d..800cb19 100644 --- a/pandas_ta/trend/psar.py +++ b/pandas_ta/trend/psar.py @@ -96,7 +96,11 @@ def psar( _sar = min(low.iloc[row - 1], low.iloc[row - 2], _sar) if reverse: - _sar = ep + if falling: + _sar = min(low.iloc[row - 1], low.iloc[row - 2], ep) + else: + _sar = max(high.iloc[row - 1], high.iloc[row - 2], ep) + af = af0 falling = not falling # Must come before next line ep = low_ if falling else high_