NexusFi: Find Your Edge


Home Menu

 





compare stochastics on different charting software


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one traderTX with 8 posts (0 thanks)
    2. looks_two Fat Tails with 7 posts (5 thanks)
    3. looks_3 eDanny with 3 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 8,068 views
    2. thumb_up 6 thanks given
    3. group 2 followers
    1. forum 18 posts
    2. attach_file 6 attachments




 
Search this Thread

compare stochastics on different charting software

  #1 (permalink)
 
traderTX's Avatar
 traderTX 
pittsburgh, pa
 
Experience: Intermediate
Platform: Ninjatrader, ensign, wave59
Broker: IB , AMP/ cqg
Trading: ES, CL
Posts: 154 since Mar 2010
Thanks Given: 54
Thanks Received: 47

hi,
i have been working on getting the stochastics from ninja and a charting software i have used for a long time, called Ensign, to coincide..,

the names of the parameters are slightly different. for example, Ensign uses %d, %k, and bars, where as Ninja uses period D, period K, and smooth for its parameters.

in the screenshot attached of the two charts side by side, ninja is on the left, Ensign is on the right, it can be seen in the first subwindow of each chart that the two stochs are lining up quite well..... the parameters i am using are the same and so they should be lining up,

because Ensign and Ninja use different terminology in the indicator properties, it took me a while to sort out, but i think i have that down, I spoke with the creator/programmer of ensign and he said that there is nothing special or unique to the code he uses for the stochastics..

but on the bottom subwindow of each chart, the two stochs dont quite match up. and the only change i have done to both stochastics parameters is change the pricetype parameter to "typical" (thanks to eDanny) in ninja which is the same as (H+L+C)/3 in Ensign.

so can anyone see what would be causing these two stochastics on these two charts not to line up on the bottom subwindow? clearly there is a difference in the calculation somewhere, but i am not seeing where that could be. granted the bottom subwindow stochastics are pretty close on each chart, the Big difference i see that i do want to replicate in the ninja chart is the ensign stoch swings to higher/lower extremes when i have the pricetype set on (H+L+C)/3, but when the pricetype is set to close, then the two stochs on each chart line up.
for example, at time 11:39 there is a high and i put a red arrow on each chart. you can see that the stoch in the left chart- lower subwindow is decked at 100, but the left chart- lower subwindow is only at about 85.

at this point this may be an exercise rather than a necessity.
but i would sure like to know if/where there is a bug?
thanks

Attached Thumbnails
Click image for larger version

Name:	ninja-ensignchart_comapre.png
Views:	304
Size:	96.9 KB
ID:	11304  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
33 thanks
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #3 (permalink)
 
eDanny's Avatar
 eDanny 
East Rochester, NY
 
Experience: Intermediate
Platform: NT
Posts: 329 since Jul 2009
Thanks Given: 18
Thanks Received: 425


Interesting. I would be helpful if the Ensign code for that indicator could be pasted to a .txt file so we could see just what the difference might be.

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

Different Smoothing Methods

Hi traderTX,

the use of different smoothing methods is not only a problem of the stochastics, but also of the RSI. I can give you a nice example of this. In his book "New Concepts in Technical Trading Systems" J.Welles Wilder Jr. presents the RSI. On page 65, you will find "The Relative Strength Index Equation", where he explains the RSI formula by using a simple moving average. On page 66 you will find his handwritten daily worksheet, where he used exponential smoothing. The explanation? The book was published in 1978, the guy did not have a computer. The recursive formula for the EMA just uses yesterday's value of the moving average and today's close - much faster, if you have to calculate this by hand.

So some software developpers applied what the master taught and the others applied what he did, and since you have different smoothing methods used for the RSI. I think it is similar for the Stochastics. Take what you like or code what suits your style.


I think the following problem might be more serious (copy from a post on the NT forum), does anybody know an answer?


Would like to explain here an interesting little bug in the stochastics indicator. I found that the value of the stochastics indicator sometimes exceeded +500, and here comes the explanation.

Line 57 checks a double value for 0. This is should never be done, if the double value is calculated, because the accuracy of the float is limited to about 15 digits.

Even worse, the value that is checked for 0, is the result of a recursive data series SUM. If you look, how SUM works, it adds and subtracts a value for every bar. So in case that SUM() should become 0, it carries an error of all the past additions and subtractions for the DataSeries. For a 1min chart with a lookback period of 65 days there are about 140,000 operations performed with all the errors from the float adding up. So if 1 operation yields an error of about 1 E-15, the recursive mechanism of SUM() increases this error hundred- or thousandfold to 1 E-12. I have actually tested this.

In case SUM(nom,Smooth) and SUM(den, Smooth) both should take the value 0, they may actually have a value of Close[0]*1 E-12. Checking for 0 then returns false, and the Stochastics may jump to +500 or below -300, as observed. So to be on the safe side, the formula for the Stochastics indicator should be modified, either by using an appropriate Almost Equal method which can be used to replace the offensive code, or by simply replacing line 57 with

K.Set(100 * SUM(nom, Smooth)[0] / (Math.Abs(SUM(den, Smooth)[0]) < Close[0]*Math.Pow(10.0,-11.0) ? 1.0 : SUM(den, Smooth)[0]))

Reply With Quote
  #5 (permalink)
 
traderTX's Avatar
 traderTX 
pittsburgh, pa
 
Experience: Intermediate
Platform: Ninjatrader, ensign, wave59
Broker: IB , AMP/ cqg
Trading: ES, CL
Posts: 154 since Mar 2010
Thanks Given: 54
Thanks Received: 47

thanks both of you for a reply.
yes, i would like to compare code. not sure if the ensign code is available.
may be i will just use the ninja stoch, it is pretty close..

Started this thread 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

This from an article from Ensign that can be found here: Ensign Software - Studies: Stochastic Fundamental Behavior. I have highlighted the information on stochastics smoothing in red. This can be implemented for NinjaTrader very quickly.

Formula

Raw stochastic is the percentage of where a price is in a range of highest high - lowest low over a set of bars. Some call the raw value Fast %K.
Raw Stochastic = 100 * (Last - LowestLow) / (HighestHigh - LowestLow).
Slow %K is an average of the Raw Stochastic. Some call this first average Fast %D.
Slow %D is an average of the Slow %K. This is the 2nd average.
Ensign Windows has 4 choices of which formula to use for calculating the averages. The average used for the original Stochastic work was an exponential moving average. However, variations using simple average, weighted average and smoothed average are also worthy and useful Stochastic calculations.

The smoothed average formula is very similar to the exponential formula. The difference is in how the Alpha decay factor is derived from the average parameter N. See these formulas:
Exponential = Previous Average + ((Current Value - Previous Average) / Alpha)
where Alpha = (N+1)/2
Smoothed = Previous Average + ((Current Value - Previous Average) / Alpha)
where Alpha = N
The parameter N is greater than or equal to 1. If the parameter entered is less than 1, then invert the parameter using N = 1 / parameter.
Ensign Windows does not do a 3rd average. If an average of the Slow %D is wanted, then put on a moving average study and set its Data Point to be the %D value of the Stochastic study.

Reply With Quote
  #7 (permalink)
 
traderTX's Avatar
 traderTX 
pittsburgh, pa
 
Experience: Intermediate
Platform: Ninjatrader, ensign, wave59
Broker: IB , AMP/ cqg
Trading: ES, CL
Posts: 154 since Mar 2010
Thanks Given: 54
Thanks Received: 47

Thanks Fat Tails,
i had seen that "Stochastics Studies on fundamental behavior" on Ensign before but re-reading it shed light on many things, it ties several trading topics together.

i received a great reply back from Howard at Ensign after submitting a well constructed question. his personal attention is one thing that keeps me a subscriber. if i read his answer correctly, he believes the calculations are different when using the value of (h+l+c)/3, ninja uses the higher high and lower low of the price data, and ensign is using the higher high and lower low of (h+l+c)/3 values.. and that is the difference if i understand his reply.
i paste his answer here, tell me if that is what you think?
I think their use of Typical being HLC/3 is that the C part of their Stochastic equation is replaced with HLC/3 and they continue
to use Highest High and Lowest Low based on bar highs and bar lows. That is why their typical is VERY similar to the regular Stochastic using C.

Sto =100 * (C - LL) / (HH - LL) where C is the price to use, HH is the Highest High in the period and LL is the Lowest Low in the period.

What happens in Ensign is this. When you have Close as the data point, then we do the above of C is the Close, HH is the Highest High, and LL is the Lowest Low.

For ALL OTHER DATA points, we change HH to the be the Highest DATA POINT, and LL is the Lowest DATA POINT in the period.
So our HH is the Highest HLC/3 value and LL is the Lowest HLC/3 value. HH from HLC/3 will be a lower value than HH from Highs, and LL from HLC/3 will be
a higher value than LL based on Lows. Therefore, our stochastic of HLC/3 can more readily approach 0% and 100%, and swing to the extremese
that their implementation will not.

so maybe you, eDanny, or somebody else knows an easy way to implement this method into ninja?

Started this thread 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

Hi traderTX,

that is an unorthodox implementation of the Stochastics, but it turns out a valid oscillator. Here is the implementation for NT 7. The formula uses the High and Low of the input value over the period, as explained by Howard.

Joined is a chart of CL 06-10 with the original and the modified indicator (for NT 7.0) , and the indicator file.

Attached Thumbnails
Click image for larger version

Name:	CL 06-10 (1 Min)  16_04_2010.jpg
Views:	269
Size:	115.0 KB
ID:	11438  
Attached Files
Elite Membership required to download: ModifiedStochastics.zip
Reply With Quote
Thanked by:
  #9 (permalink)
 
traderTX's Avatar
 traderTX 
pittsburgh, pa
 
Experience: Intermediate
Platform: Ninjatrader, ensign, wave59
Broker: IB , AMP/ cqg
Trading: ES, CL
Posts: 154 since Mar 2010
Thanks Given: 54
Thanks Received: 47

errrr,
i tried importing it but i am still on 6.5 and it didnt seem to import.
if i upgrade to 7.0, will i lose some of the indicators that i have now for 6.5 ?
or do most 6.5 indicators work on 7.0 but not vice versa?

or should i just ask if you can do the indicator so it will work on 6.5?

thanks

Started this thread Reply With Quote
  #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


Below is a version of the ModifiedStochastics for NT 6.5. It uses simple smoothing for the %D line (tell me if you prefer something different). You need to set it to Tpyical via indicator dialogue to get the stochastics indicator described by Howard. It also will give a different value with the close.

Many NT 6.5. indicators work on NT 7.0 and many do not. Each indicator needs to be tested for NT 7.0, as there is a number of code breaking changes that may prevent it from working properly. NT 7.0 indicators can generally not be used with NT 6.5.



traderTX View Post
errrr,
i tried importing it but i am still on 6.5 and it didnt seem to import.
if i upgrade to 7.0, will i lose some of the indicators that i have now for 6.5 ?
or do most 6.5 indicators work on 7.0 but not vice versa?

or should i just ask if you can do the indicator so it will work on 6.5?

thanks


Attached Files
Elite Membership required to download: ModifiedStochastics.zip
Reply With Quote
Thanked by:




Last Updated on April 20, 2010


© 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