NexusFi: Find Your Edge


Home Menu

 





Bugs in NT Parabolic code


Discussion in NinjaTrader

Updated
    1. trending_up 11,382 views
    2. thumb_up 23 thanks given
    3. group 3 followers
    1. forum 23 posts
    2. attach_file 15 attachments




 
Search this Thread

Bugs in NT Parabolic code

  #1 (permalink)
cprtrader
Adelaide Australia
 
Posts: 18 since Jun 2012
Thanks Given: 7
Thanks Received: 3

Does anyone here use the Parabolic for actual trading?

I have reason to believe that there are at least two bugs in the Ninja implementation of this indicator. I know this because I spent time studying Wilder's definitions and rules, and I have written the code for my own charting software, which I use for EOD trading (I use NT for intraday trading). The results of my code perfectly matches the all examples in Wilder's book. When I crosschecked the output of my program with Ninja, the anomalies became apparent.

For example, Wilder was clear that the Parabolic was to be used as both an entry signal and a trailing stop. So with a long position, the stops would rise or stay at the same level, but never fall. With a short position, the stops should fall or stay at the same level, but never rise. This is trailing stops 101.

The attached chart #1 shows an example where NT incorrectly lowered the stop for a long position. This is not a rare or isolated example.

The other bug relates to Wilder's rule (and he was emphatic about this) that, when calculating the Parabolic (always for the NEXT bar), the stop should not be within the range of EITHER the current OR the previous bar. NT does not consistently apply this rule. See attached chart #2.

I raised these issues with Ninja support and received a polite pat on the head, with a suggestion that I could change the Ninja code if I didn't like the way it functioned. Seems the designers intentions don't matter.

Also, the way Ninja handles the last plot on the chart is curious. When applying the Parabolic, the parameter default is "Calculate on bar close = True", which results in no plot on the last bar of the chart. This TOTALLY NEGATES the purpose of this indicator. The last plot is crucial for new entry signals and to manage open trades. Without the last plot the indicator achieves NOTHING. Changing the default setting from True to False displays the Parabolic as Wilder intended.

So we have a parameter that serves only to make the indicator useless. And the useless setting is the default.

Are there any Parabolic fans on futures.io (formerly BMT)? I'd be interested in your thoughts and experiences with this indicator.

Cheers

CPR

Attached Thumbnails
Click image for larger version

Name:	NT Parabolic bug 001.jpg
Views:	306
Size:	187.7 KB
ID:	146913   Click image for larger version

Name:	NT Parabolic bug 002.jpg
Views:	304
Size:	222.5 KB
ID:	146914  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

@cprtrader: There are many different implementations of the PSAR. For example I have seen a version that does not move the stop for the first bar after the entry.

Now let me comment your two examples.

(1) The first case you have identified is a special case. The wide ranging red bar on your chart breaches the stop in place, but also marks a new high of the current long position. If you apply the original PSAR logic, the breach of the stop should lead to reverting the position. The new stop for the resulting short position should have been located at the high of that red bar. In my opinion you are correct that the NinjaTrader PSAR does not reflect the original logic.

(2) In your second example the stop is located at the high of the prior bar. If I look at the rules given by Welles Wilder in his book "New Concepts in Technical Trading Systems", see page 11:

"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 day's high or today's high, then use the higher high between today and the previous day as the new SAR."

From this rule it becomes clear that the stop shown on your second chart should be the high of the prior bar. And this is exactly what the NinjaTrader default PSAR does. So in my opinion your are incorrect here, as the PSAR calculates as intended by Wilder Welles.

(3) The issue with "CalculateOnBarClose" or "COBC".

If you use NinjaTrader for intraday trading - that is what is designed for - the last bar of the chart is typically incomplete. Therefore NinjaTrader lets you select for all indicators between "COBC = true" and "COBC = false".

"COBC = true": The indicator value for the developing bar is not shown. The indicator value will only be calculated once this bar has been completed.
"COBC = false": The indicator value for the developing bar is recalculated with each incoming tick. The preliminary indicator value is shown on the chart.

The setting "COBC = false" can take a significant toll on your CPU, if applied to all indicators. Therefore all NinjaTrader indicator come with the default setting "COBC = true". It is up to you how to use an indicator.

It is true that all indicators that come with stops that can be triggered intra-bar should be set to "COBC = false", as otherwise they would only signal the breach of the stop with a significant delay.


Modifications of the code required:

The NinjaTrader default PSAR is certainly cumbersome and at least in the first case it does not apply Wilder Welles' logic correctly. Also in order to use it with the setting "COBC = false", the code should be modified to avoid recalculating the stop with every incoming tick.

All NinjaTrader indicators are open source, so you can do the modifications yourself.

Reply With Quote
  #3 (permalink)
cprtrader
Adelaide Australia
 
Posts: 18 since Jun 2012
Thanks Given: 7
Thanks Received: 3


@Fat Tails,

Thanks for your post.

I agree there are many implementations of the Parabolic (and other indicators), however, as a software purchaser I expect software developers to respect the specifications of the indicator's designer, in this case Welles Wilder. By all means, include additional variations if there is a quantifiable improvement. However, I suspect many "variations" are simply the result of sloppy programming.

These days indicators have a bad name, with many high profile "traders" making statements like "indicators don't work". Inadequate implementation by software developers will only contribute to this perception.

With reference to item 2 in your post, I am scratching head. Wilder's rule states that "If short, never move the SAR for tomorrow below the previous day's high ... ". Clearly, by Wilder's definition the stop should not have been lowered, but is was. So NinjaTrader's calculation for this plot is 100% wrong.

Regarding CBOC, your point regarding CPU toll is probably the reason why the default. However, I wonder whether this is still valid with today's high powered PCs. I trade with 12 live charts, each with an EMA and Parabolic with CBOC=False (on a 4 year old PC), and I have never had a performance problem. In Ninja's defence, Parabolic is probably the only indicator that is rendered useless by the default setting, which if traded would result in every entry and every exit being up to 1 bar late.

Cheers

CPR

Reply With Quote
  #4 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


cprtrader View Post
With reference to item 2 in your post, I am scratching head. Wilder's rule states that "If short, never move the SAR for tomorrow below the previous day's high ... ". Clearly, by Wilder's definition the stop should not have been lowered, but is was. So NinjaTrader's calculation for this plot is 100% wrong.

I think you missed the second half of the citation, where it reads: "If the SAR is calculated to be below the previous day's high or today's high, then use the higher high between today and the previous day as the new SAR." This is exactly what the NinjaTrader indicator does. It uses the high of the previous day as the new SAR. So in my opinion it is 100% correct here.


cprtrader View Post

Regarding CBOC, your point regarding CPU toll is probably the reason why the default. However, I wonder whether this is still valid with today's high powered PCs. I trade with 12 live charts, each with an EMA and Parabolic with CBOC=False (on a 4 year old PC), and I have never had a performance problem. In Ninja's defence, Parabolic is probably the only indicator that is rendered useless by the default setting, which if traded would result in every entry and every exit being up to 1 bar late.

Cheers

CPR

The COBC logic is necessary because the indicator value is preliminary and may even be skewed. As an example consider an ATR(4). When the first tick of a new bar is detected, the range of the new bar is zero, and the indicator shows an average true range which is made up from the prior bar's average true range and the new range which is zero. This indicator would be systematically skewed to the downside, when set to "COBC = false".

We should not complain abouth this, as we have the choice between "COBC = false" and "COBC = true". If you always want to use the Parabolic with the setting "COBC = false", then simply open the indicator dialogue box, right-click that field next to CalculateOnBarClose and select "false" as the default option for this indicator.

Reply With Quote
Thanked by:
  #5 (permalink)
cprtrader
Adelaide Australia
 
Posts: 18 since Jun 2012
Thanks Given: 7
Thanks Received: 3

Fat Tails,

If you look at the 2nd chart carefully you will see that the plot marked with a black line has been lowered slightly. This is not correct. The previous plot should have been used. This is clearly stated in the rule that you quoted. The previous (higher) plot should have been used. It wasn't. The plot should not have been lowered. It was.

Regarding the CBOC, your statement is correct for most indicators, but absolutely does NOT apply to the Parabolic because Parabolic plots are never preliminary, under any circumstances. If you plot the Parabolic real time, you will see that the plot values do not change (unless the stop is hit), no matter what the CBOC setting. The changing prices on the current incomplete bar have zero effect because all Parabolic values (including the latest plot) are always calculated from the previous COMPLETED bar. Incomplete bars are NEVER used to calculate any Parabolic plot, not even on NinjaTrader. This is why the CBOC parameter is totally, completely, 100% redundant on the Parabolic, assuming CPU toll is not a problem. And if it is, the Parabolic cannot be used for real time trading.

If you trade with the Parabolic or attempt to write the program code, these issues become clear.

Cheers

CPR

Reply With Quote
  #6 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


cprtrader View Post
Fat Tails,

If you look at the 2nd chart carefully you will see that the plot marked with a black line has been lowered slightly. This is not correct. The previous plot should have been used. This is clearly stated in the rule that you quoted. The previous (higher) plot should have been used. It wasn't. The plot should not have been lowered. It was.

@cprtrader: Sorry, I am paying attention to little details. The rule does not specify to use the previous plot, but it specifies to use the high of the previous bar. The NinjaTrader indicator exactly follows that rule.

I have also referenced the exact source for that rule.

Reply With Quote
Thanked by:
  #7 (permalink)
cprtrader
Adelaide Australia
 
Posts: 18 since Jun 2012
Thanks Given: 7
Thanks Received: 3

Fat Tail,

You are correct. Ninja's calculations are incorrect on the first example, but correct on the 2nd example.

Thanks for your input.

Cheers

CPR

Reply With Quote
  #8 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

I have now coded my own Parabolic SAR by strictly applying the rules written down by Welles Wilder.

Most of the time the two indicators match, see chart below. However, there are a few features that can be debated.




(1) When the Parabolic Stop is touched, but not penetrated, would this lead to a reversal? The NinjaTrader default indicator reverses. My indicator does not, for the following reason: The stop should only be triggered, when price approaches the stop and not when the stop approaches price. In many cases, it is the stop that is moved towards price, as it is moved to the low of the prior bar. In that case a double bottom would trigger the long stop and revert to a short position.




(2) The other difference is the bug that we have already discovered.


Reply With Quote
  #9 (permalink)
cprtrader
Adelaide Australia
 
Posts: 18 since Jun 2012
Thanks Given: 7
Thanks Received: 3

Fat Tails,

I agree with your suggestion that the Parabolic should trigger on a penetration (instead of a touch) because, as you say, there are times that the Parabolic will equal previous high (or lows). But, for some reason Wilder specified a touch.

It would be an interesting exercise to test whether a penetration would improve the SAR results.

Cheers

CPR

Reply With Quote
Thanked by:
  #10 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



cprtrader View Post
Fat Tails,

I agree with your suggestion that the Parabolic should trigger on a penetration (instead of a touch) because, as you say, there are times that the Parabolic will equal previous high (or lows). But, for some reason Wilder specified a touch.

It would be an interesting exercise to test whether a penetration would improve the SAR results.

Cheers

CPR

Wilder applied the indicator to daily charts only - his book was published 35 years ago. Penetration or touch does not make much of a difference on daily charts, but it does if you apply the PSAR to smaller timeframe charts.

Reply With Quote
Thanked by:




Last Updated on May 27, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts