pacificbay / sar

Lucid SAR - a parabolic SAR indicator, written in Pine Script, based on section II of J. Welles Wilder, Jr.'s book “New Concepts in Technical Trading Systems” (1978)
MIT License
21 stars 9 forks source link

Wrong AF value on the second bar of a trend #1

Open ileasile opened 5 years ago

ileasile commented 5 years ago

On the first bar of a trend value of AF is inherited from the previous trend. I.e. it should be updated on the the next bar of trend, becuase EP. But it'll be taken as initial AF (0.02 insted of 0.04). It breaks the calculation.

casey-bowman commented 5 years ago

I plan to set up a unit test for this case. If you have any suggestions on how to best set up unit tests for Pine, please let me know. Thank you very much for your PR on this! Offhand it looks nice, but I'll need to verify and test.

casey-bowman commented 5 years ago

Short of finding a way of doing a unit test, an example of the issue in a specific chart would be helpful for verifying this issue Thanks again, Ilya

casey-bowman commented 5 years ago

It just struck me that the title of this issue could be misconstrued as being particularly vehement :) The variable name 'AF' has another meaning in common parlance