31 private decimal _outputSar;
33 private readonly decimal _afInit;
34 private readonly decimal _afMax;
35 private readonly decimal _afIncrement;
49 _afIncrement = afIncrement;
60 : this($
"PSAR({afStart},{afIncrement},{afMax})", afStart, afIncrement, afMax)
67 public override bool IsReady => Samples >= 2;
103 _previousBar = input;
109 HandleLongPosition(input);
113 HandleShortPosition(input);
116 _previousBar = input;
127 _isLong = currentBar.
Close >= _previousBar.
Close;
133 _ep = Math.Min(currentBar.
High, _previousBar.
High);
134 _sar = _previousBar.
Low;
138 _ep = Math.Min(currentBar.
Low, _previousBar.
Low);
139 _sar = _previousBar.
High;
146 private void HandleLongPosition(
IBaseDataBar currentBar)
149 if (currentBar.
Low <= _sar)
156 if (_sar < _previousBar.
High)
157 _sar = _previousBar.
High;
158 if (_sar < currentBar.
High)
159 _sar = currentBar.
High;
166 _ep = currentBar.
Low;
169 _sar = _sar + _af * (_ep - _sar);
172 if (_sar < _previousBar.
High)
173 _sar = _previousBar.
High;
174 if (_sar < currentBar.
High)
175 _sar = currentBar.
High;
186 if (currentBar.
High > _ep)
188 _ep = currentBar.
High;
195 _sar = _sar + _af * (_ep - _sar);
198 if (_sar > _previousBar.
Low)
199 _sar = _previousBar.
Low;
200 if (_sar > currentBar.
Low)
201 _sar = currentBar.
Low;
208 private void HandleShortPosition(
IBaseDataBar currentBar)
211 if (currentBar.
High >= _sar)
218 if (_sar > _previousBar.
Low)
219 _sar = _previousBar.
Low;
220 if (_sar > currentBar.
Low)
221 _sar = currentBar.
Low;
228 _ep = currentBar.
High;
231 _sar = _sar + _af * (_ep - _sar);
234 if (_sar > _previousBar.
Low)
235 _sar = _previousBar.
Low;
236 if (_sar > currentBar.
Low)
237 _sar = currentBar.
Low;
247 if (currentBar.
Low < _ep)
249 _ep = currentBar.
Low;
256 _sar = _sar + _af * (_ep - _sar);
259 if (_sar < _previousBar.
High)
260 _sar = _previousBar.
High;
261 if (_sar < currentBar.
High)
262 _sar = currentBar.
High;