Bugs in NT Parabolic code - NinjaTrader | futures io social day trading
futures io futures trading


Bugs in NT Parabolic code
Updated: Views / Replies:3,621 / 23
Created: by cprtrader Attachments:15

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 15  
 
Thread Tools Search this Thread
 

Bugs in NT Parabolic code

  #1 (permalink)
Trading Apprentice
Adelaide Australia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 18 since Jun 2012
Thanks: 7 given, 3 received

Bugs in NT Parabolic code

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
Bugs in NT Parabolic code-nt-parabolic-bug-001.jpg   Bugs in NT Parabolic code-nt-parabolic-bug-002.jpg  
Reply With Quote
 
  #2 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,600 received
Forum Reputation: Legendary

@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
The following 5 users say Thank You to Fat Tails for this post:
 
  #3 (permalink)
Trading Apprentice
Adelaide Australia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 18 since Jun 2012
Thanks: 7 given, 3 received

Bugs in NT Parabolic code


@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)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,600 received
Forum Reputation: Legendary


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
The following 3 users say Thank You to Fat Tails for this post:
 
  #5 (permalink)
Trading Apprentice
Adelaide Australia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 18 since Jun 2012
Thanks: 7 given, 3 received

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)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,600 received
Forum Reputation: Legendary


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
The following user says Thank You to Fat Tails for this post:
 
  #7 (permalink)
Trading Apprentice
Adelaide Australia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 18 since Jun 2012
Thanks: 7 given, 3 received

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)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,600 received
Forum Reputation: Legendary

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.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



(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.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



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

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Last edited by Fat Tails; May 19th, 2014 at 06:46 PM.
Reply With Quote
The following 4 users say Thank You to Fat Tails for this post:
 
  #9 (permalink)
Trading Apprentice
Adelaide Australia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 18 since Jun 2012
Thanks: 7 given, 3 received

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
The following user says Thank You to cprtrader for this post:
 
  #10 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,600 received
Forum Reputation: Legendary



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
The following user says Thank You to Fat Tails for this post:

Reply



futures io > > > > Bugs in NT Parabolic code

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
NT - How to set ATM Quantity via NT script code Adfra The Elite Circle 1 November 11th, 2013 04:00 AM
NT Change Indicator code vitto The Elite Circle 1 January 30th, 2013 05:31 PM
NT code problem lincor NinjaTrader 8 November 21st, 2012 07:00 AM
Convert this NT code to EL, Please lizmerrill EasyLanguage Programming 8 January 20th, 2011 02:33 PM
Need confirmation of NT code please Saroj NinjaTrader Programming 4 September 26th, 2009 01:51 PM


All times are GMT -4. The time now is 02:39 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-12 in 0.17 seconds with 20 queries on phoenix via your IP 54.90.207.75