TOS Parabolic SAR bug... is there a working alternative?

Has anyone else noticed that the builtin Parabolic SAR indicator in TOS is buggy? The stop is never supposed to move backwards - when price pulls back to the stop "dot", the dot simply disappears and the position reverses. That's how it's supposed to work.

I've spent the last 3 hours testing a trading concept using the SAR and about 1/3 the time, when price reaches the stop the dot moves backwards several pennies before (hopefully) finally reversing. I've been placing my stop order at the exact penny where the SAR dot is placed, and when price gets there, my order is triggered, but instead of flipping around the other way, SAR just backs up and sometimes price goes the other way... then I've reversed but SAR hasn't and the whole thing becomes useless.

The last trade I tried (before I gave up on the worthless, poorly coded POS) had a stop set at 348.07 on a long trade... when the price came down to and through that value, the stop backed up all the way to 347.96!! Then price turned back up - SAR showing we're still in the long trade, but of course, my order got filled way back up at 348.07 and I'm now short...

I watched this happen at least seven to ten times over the last 3 hours of trade testing - it happens in both directions. Looking at the code, I can't see how it would happen, but it does and it makes the builtin indicator totally, absolutely useless.

Has anyone coded a Parabolic SAR for TOS that doesn't re-paint like this?
 
Well, I pulled out my copy of J. Welles Wilders's "New Concepts in Technical Trading Systems" where he first described this system and compared it line by line to the code for the TOS Parabolic SAR 'indicator'. I've determined that the TOS version is technically calculating the values correctly, but it's displaying them differently than Wilder's original intent. Essentially, the SAR point displayed on a given bar is the SAR point to be used for the next bar (which hasn't printed yet), and the SAR point to be used for the current bar is the one displayed on the previous bar.

The reason they did it this way is that - in Wilder's day - price data was taken from the evening newspaper, so all calculations were made by hand after a given day's price action was complete, and it generated an SAR point to be used for the following day's trading. In his book, he would mark Tuesday's SAR on Tuesday's bar, and it was used to reverse (if penetrated) during Tuesday's trading. This makes sense when you're trading on a daily chart using data after the market close.

In a TOS indicator (as is typical of modern charting packages), a given bar's value is calculated in real time, as the bar is being progressively formed. As such, the current bar can't be affected by the current SAR point because that bar isn't finished so the final value of that SAR point is not yet settled. The coders therefore print each SAR point on the bar from which it is calculated, not the bar for which it is effective. This allows the proper SAR points to be determined and put into effect as they should be, but they are displayed one bar back from where Wilder would have marked them.

My confusion stemmed from the fact that there is no mention of this fact anywhere that I could find, so I assumed that the TOS 'indicator' (it's written as an indicator, but in reality it is a full stop and reverse trading system) would display the same way that Wilder drew it. The answer is to ignore "Tuesday's" SAR point when considering "Tuesday's" price action, and instead trade "Tuesday's" price action against "Monday's" SAR point. The only real downsides to this are that (A) the price bubble shown for the current SAR point is not the one to be used for actual stop orders, which is inconvenient, and (B) for the current trade it is visually confusing to see an SAR point on the current candle which will not affect the current candle. If anyone knows of a way to have the current SAR point hidden, please share (I don't think it's possible). An alternative would be to detect when one candle has completed and a new candle has begun - then it would be possible to display the SAR points in their proper location and keep the (as yet incomplete) calculation for the future candle's SAR point in a separate variable - to be added to the displayed series only when the new candle is begun. Anyone know if that's possible?
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hello @MoneyMagnet - Thanks for sharing your analysis. Very helpful. I feel there is still a gap/question that remains unanswered, at least in my mind. My understanding is that:
1) the PSAR for the first bar after the trend reverses is the Extreme Point from the previous trend
2) also, the first bar of a new trend should also be used to compute the PSAR value for the 2nd bar (using AF = 0.02, Extreme Point = High of the 1st bar)

As per the true intent of the author, the value from the 1st point above would have been plotted underneath the 1st bar of the new trend and value from the 2nd point above would have been plotted under the 2nd bar or "yet to be plotted bar".

However, If TOS is choosing to shift the plotting of PSAR by 1 bar to the left, then the PSAR value computed for the 2nd bar as above should be plotted under the 1st bar of the trend. And as a result the PSAR value effective for the 1st bar should get overwritten. However, in my manual scan of multiple charts in TOS, I am seeing that the PSAR value plotted on the 1st bar of any trend is consistently the extreme point of the previous trend (instead of being overwritten by the value computed for the 2nd bar). So if 1st bar is showing the PSAR value effective for the 1st bar, but the subsequent bars are showing the value effective for the next bar, does it mean that the value effective for the 2nd bar in each trend is getting lost (overwritten)? In other words, is the 1st bar showing 1st bar's PSAR but the 2nd bar is showing 3rd bar's PSAR?

Also, given you have access to the TOS PSAR code, can you please check if TOS is indeed computing two values while on the 1st bar of a new trend - one that is effective for the 1st bar (equal to Extreme Point of the previous trend) and the 2nd value that is supposed to be effective for the 2nd bar (using Extreme Point as High of the 1st bar and AF = 0.02)?

I will sincerely appreciate any thoughts you may have on this.

Thanks.
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
372 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top