This code is open source under the MIT license. If you have any improvements or corrections to suggest, please send me a pull request via the github repository https://github.com/casey-bowman/sar
For more details on the initial script, see https://www.tradingview.com/script/KU6P5...
Sawcruhteez from Lucid Investment Strategies wrote the following description of the , where the quotes are from Section II of J. Welles Wilder, Jr.'s book New Concepts in Technical Trading Systems (1978)
"The Parabolic Time / Price System derives its name from the fact that when charted, the
pattern formed by the stops resembles a parabola, or if you will, a French Curve. The system
allows room for the market to react for the first few days after a trade is initiated and then the
stop begins to move up more rapidly. The stop is not only a function of price but also a function
"The stop never backs up. It moves an incremental amount each day, only in the direction which
the trade has been initiated."
"The stop is also a function of price because the distance the stop moves up is relative to the
favorable distance the price has moved... specifically, the most favorable price reached since the
trade was initiated."
A. The calculation for a is:
Tomorrow’s SAR = Today’s SAR + AF (EP - Today’s SAR )
"Acceleration Factor ( AF ) is one of a progression of numbers beginning at 0.02 and ending at
0.20. The AF is increased by 0.02 each period that a new high is made" (if long) or new low is
made (if short).
EP is the "Extreme Price Point for the trade made so far. If Long, EP is the extreme high price for
the trade; if Short, EP is the extreme low price for the trade.”
Most websites will provide the above calculation for the but almost all of them
leave out this crucial detail:
B. "Never move the SAR into the previous day’s range or today’s range
"1. If Long, never move the SAR for tomorrow above the previous day’s low or
today’s low. If the SAR is calculated to be above the previous day’s low or
today’s low, then use the lower low between today and the previous day as
the new SAR . Make the next days calculations based upon this SAR .
"2. If Short, never move the SAR for tomorrow below the previous day’s high or
today’s high. If the SAR is calculated to be below the previous days’ high or
today’s high, then use the higher high between today and the previous day
as the new SAR . Make the next days calculations based upon this SAR ."
When a SAR is broken then it gets placed at the SIP (significant point) of the prior trend.
In otherwords it is placed above the current candle and at the price that was the SIP.
The inverse is true for the first SAR .
"This system is a true reversal system; that is, every stop point is also a reverse point." If breaking
through a SAR (one above price) that simultaneously signals to close a short and go
There are only two SAR reverses ever created for one candle and they can toggle.
When one returns to a former SAR reverse, that SAR could be lower (higher) if there was a candle low (high) below (above) the SAR before that reversal if one is reversing from an uptrend (downtrend).
So in any one candle, the two SAR reverses would only spread farther apart with new highs and lows before a reversal. In other words, the low SAR might only move lower upon a reversal from the high SAR when there’s been an intervening new low for the candle, and the high SAR might only move higher upon a reversal from the low SAR when there’s been an intervening new high for the candle.
I have asked Sawcruhteez to give me feedback on this proposed intracandle rule.
Sawcruhteez has also suggested a new, exciting feature which I plan to include in the next version. It'll combine two indicators into one, optionally. More on that later. We have agreed to brand the new combo indicator the "Sawcruhteez SAR" and to keep everything open source.
Regarding the requests for an alert, it looks like it'd be simple. So I hope to add it soon. It should only require one new line. Perhaps I could make it available in a separate public script for people to test out before I replace the current one that I know works, thanks to the vetting and testing by @Sawcruhteez. So to anyone who requests a feature, I ask that you please spend time checking it out when I make it available and please give me feedback. If there's an issue, please give detailed errors with exact numbers and all, so that I can replicate it, verify it, and correct it.
A few requests for simple features I think I can do with little time spent. If some complications do arise that make a new feature take more time to either implement or test, then I might start asking for payment to compensate for my time. I'm primarily devoted these days to a bitcoin software project stemming from ideas I had as a grad student at Stanford, back in the days before the idea of open money was cool.