Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Rate of Change - PCF Calculation Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Robin Hood
Posted : Thursday, April 27, 2006 9:09:05 PM
Gold Customer Gold Customer

Joined: 11/25/2004
Posts: 10
A recent PCF that I am attempting to develop rquires the calculation of a moving average of a rate of change calculation to provide some smoothing. This is best described by an example.

On a tab with proces in the upper window, select the middle window and add a 34 day TSV. Now add a 13 day Rate of Change" of the above 34 day TSV. Now add a 13 day moving average of this "Rate of Change". So far so good.

Now the objective is to create a PCF to exactly match the above 13 day moving average of the "Rate of Change"

Both of the following give identical results:

AVG(TSV34,13)-AVG(TSV34.12,13)

or (by brute force)

((TSV34-TSV34.12) +(TSV34.1-TSV34.13) +(TSV34.2-TSV34.14) +(TSV34.3-TSV34.15) +(TSV34.4-TSV34.16) +(TSV34.5-TSV34.17) +(TSV34.6-TSV34.18) +(TSV34.7-TSV34.19) +(TSV34.8-TSV34.20) +(TSV34.9-TSV34.21) +(TSV34.10-TSV34.22) +(TSV34.11-TSV34.23) +(TSV34.12-TSV34.24))/13

However, either of these do not exactly match the resulting plot of the moving average plotted by TC2000. The curve has both greater max and mins and is shifted approximately 6 days to the right of the TC2000 curve.

What am I doing wrong. I understand that ROC is typically calculated as the present indicator value minus the indicator valve 12 days earlier (or 13) this effects the numerical value but does not impact the genral shape etc. of the plot.

I am sure that I am missing something simple.

Robin Hood
Bruce_L
Posted : Thursday, April 27, 2006 9:39:18 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The formula is off slightly because the days ago parameter resulting from the Rate of Change of change should use 13 instead of 12. Make sure Center Zero Line is plotted on the Custom Indicator and try the following Indicator Formula instead:

AVG(TSV34,13) - AVG(TSV34.13,13)

But I don't think that's the primary issue. There could be differences between what the formula represents and what is actually being charted. The formula represents a 34-Period TSV with an Average Type of Simple. So if the TSV is Exponential, the results will not match. The formula also represents a 13-Period Simple Moving Average, so if the Moving Average is Exponential, the results will not match. The 6-Period Shift could also mean that Shift Left is selected in the Moving Average. At least one of these things probably doesn't match if the Maxes and Mins are shifted.

But even if all of these match and the curve lines up, the peaks and valleys on the Custom Indicator will be more extreme than on the plotted Moving Average. The Custom Indicator will be drawn on its own scale while the Moving Average will be drawn on the same scale as the Rate of Change. This means the the Custom Indicator should hit either the top or bottom edge of the chart section while the Moving Average will fall short.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rmr1976
Posted : Thursday, April 27, 2006 9:51:59 PM
Registered User
Joined: 12/19/2004
Posts: 457
Hello,

Your first formula isn't equivalent to a 13 day average of the 13 day ROC. It is actually a rate of change of the moving average, which is something different.

When I plot your indicator, I'm able to find a nearly identical curve (except for the size of the swings) with the following formula:

Custom Indicator:
TSV34-TSV34.13 Smoothed by a 13 period average.

Compare this to your ROC settings described above.

The directional changes in the averages are the same, as are the values, but it appears that the scale for the Worden ROC is different from the scale on the custom indicator.

When you smooth a custom indicator, it changes the y axis on the scale, and makes the swings in the custom indicator more visible, even if the values are the same.

When the moving average is a child of the raw indicator, it is plotted on the scale of the parent indicator.

Say you have an indicator that fluctuates between +100 and -100. If you plot a moving average along with that indicator, the scale will still be of the raw data, with extremes at +100 and -100.

Now, if you plot only a smoothed version of that indicator, the extremes will be closer together, say maybe to +90 and -90. Plot them in the same window, and the custom indicator will have the same shape, but will have wider swings.

Does that make sense? If you are sorting for numerical values, then the formula I used should give you what you want.
rmr1976
Posted : Thursday, April 27, 2006 9:53:13 PM
Registered User
Joined: 12/19/2004
Posts: 457
Oops! It seems like Bruce beat me to it.
Robin Hood
Posted : Friday, April 28, 2006 5:40:17 PM
Gold Customer Gold Customer

Joined: 11/25/2004
Posts: 10
Gentlemen:

I am having a heck of a time with the posting. Both last night and this evening, I am losing my reply before, I am finished typing it.

I am trying again.

rmr1976:

You are correct, the formula AVG(TSV34,13) - AVG(TSV34.13,13)is not a 13 DMA of ROC of TSV34 but is the 13 day ROC of the 13 DMA of TSV34. I noticed this last night just after I sent it.

Bruce, You are also correct. The correct entries are to use 13 not 12 as in the formula directly above.

In any case using the built in indicator, ROC and moving average functions of TC2000, I created a plot of TSV34 in a window, then the 13 day "ROC" of this TSV34 and then in the same window, the 13 DMA of this "ROC".

I am still attempting to write a PCF to produce this "13 DMA of the "ROC" of TSV34.

Both the AVG(TSV34,13) - AVG(TSV34.13,13) and

((TSV34-TSV34.13) +(TSV34.1-TSV34.14) +(TSV34.2-TSV34.15) +(TSV34.3-TSV34.16) +(TSV34.4-TSV34.17) +(TSV34.5-TSV34.18) +(TSV34.6-TSV34.19) +(TSV34.7-TSV34.20) +(TSV34.8-TSV34.21) +(TSV34.9-TSV34.22) +(TSV34.10-TSV34.23) +(TSV34.11-TSV34.24) +(TSV34.12-TSV34.25))/13

give the exact same curve when the following is done using the built in functions:

Plot TSV34 then same window
Plot 13 DMA of TSV34 then in same window
Plot 13 day "ROC" of the 13 DMA of TSV34

I want the 13 DMA of the ROC not the ROC of the 13 DMA!

rmr1976, I did try the smoothing on the original and it shifted to the right (not desired), but this is a mute point since all of the formulas above appear to give the ROC of the MA.

Thank you both for your help! Hope you see this post
I'll continue working on this, any other suggestions are welcome.
Perhaps, I misunderstand the guidance. My final objective is to compare the MA of the ROC today vs. yesterday. Perhaps, I am making this more complex than necessary.

Robin Hood
Bruce_L
Posted : Friday, April 28, 2006 6:06:28 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (Robin Hood)
I want the 13 DMA of the ROC not the ROC of the 13 DMA!

The x-Period Moving Average of the y-Period Rate of Change equals the y-Period Rate of Change of the x-Period Moving Average because:

AVG( x - y ) = AVG( x ) - AVG( y )

The value returned by:

AVG(TSV34,13) - AVG(TSV34.13,13)

Matches (as it should) the results of both:

Time Segmented Volume - 34 bars - Simple
-Moving Average - 13 bars - Simple
--Rate of Change - 13 bars

And:

Time Segmented Volume - 34 bars - Simple
-Rate of Change - 13 bars
--Moving Average - 13 bars - Simple

QUOTE (Robin Hood)
I am losing my reply before, I am finished typing it.

I have no idea why this would be happening, but you might wish to try typing your reply in a program other than your internet browser and then paste it into the forums.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
diceman
Posted : Friday, April 28, 2006 8:30:58 PM
Registered User
Joined: 1/28/2005
Posts: 6,049
I have also lost replies. It happens when I leave to check other posts.

I now type replies in my email and copy them here.

It also allows me to spell check.

Either the spell checker here does not work or I am doing something wrong.

Thanks
Robin Hood
Posted : Friday, April 28, 2006 8:45:06 PM
Gold Customer Gold Customer

Joined: 11/25/2004
Posts: 10
Bruce:

Thank you forthe feedback. I am impressed. I can see by both your replies and reading some of the other discussions that there is some heavy math at times going on here. I think I better brush up on my Differential Calculus.

Anyway, Your answer is clear enough. Ok, have you actuallly using the built in functions plotted the 13 DMA of the 13 day ROC or vice versa. The curves of TC2000's final 13 DMA of ROC does not match the AVG(TSV34,13)-AVG(TSV34.13,13), when created under the "Indicator" function, even though, I was careful during all of my analysis last night to use only simple moving averages. I guess that I am still missing the point.

You did a great job! Oh, I took your advice and created this and pasted here.
Robin Hood
Bruce_L
Posted : Friday, April 28, 2006 8:53:50 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Robin Hood,
Unless I'm missing something (I've plotted it both ways), it is basically the same scaling issue I mentioned in my Thursday, April 27, 2006 9:39:18 PM post. Moving Averages are child indicators drawn on the same scale as their parent indicator but it doesn't make sense to Plot the Rate of Change on the scale of its parent and it is drawn on its own scale. Scaling aside, they return the same values.

With:

Time Segmented Volume - 34 bars - Simple
-Rate of Change - 13 bars
--Moving Average - 13 bars - Simple

The Moving Average is a Child Indicator of the Rate of Change drawn on the scale of the Rate of Change (which does not inherit the TSV scale).

With:

Time Segmented Volume - 34 bars - Simple
-Moving Average - 13 bars - Simple
--Rate of Change - 13 bars

The Moving Average is drawn on the scale of the Time Segmented Volume, but the Rate of Change is drawn on its own scale.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Robin Hood
Posted : Friday, April 28, 2006 9:03:41 PM
Gold Customer Gold Customer

Joined: 11/25/2004
Posts: 10
Bruce:

OK, I 'll buy the scaling position. You are mre of an expert on these issues than I am. The higher peaks and valley's I can understand. However, why wouldn't the inflection points be essentially on the same day?

Robin Hood
Bruce_L
Posted : Friday, April 28, 2006 9:12:55 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The inflection points should be at the same locations in time (they are when I do it). If you have already checked all of the possible issues mentioned in my Thursday, April 27, 2006 9:39:18 PM post, I have two more possibilties to check.

1. Make sure the ROC and MA are indented as you go down and not lined up directly below each other (if they are, they are both child indicators of the TSV, not of each other).

2. Make sure you are comparing the final child indicator in each case. You may wish to uncheck visible on the other indicators just to make sure:

With:

Time Segmented Volume - 34 bars - Simple (Uncheck Visible)
-Rate of Change - 13 bars (Uncheck Visible)
--Moving Average - 13 bars - Simple

With:

Time Segmented Volume - 34 bars - Simple (Uncheck Visible)
-Moving Average - 13 bars - Simple (Uncheck Visible)
--Rate of Change - 13 bars

You can always re-check visible on the indicators you wish to display when you are done.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Robin Hood
Posted : Friday, April 28, 2006 9:30:11 PM
Gold Customer Gold Customer

Joined: 11/25/2004
Posts: 10
Bruce:

I apologize. I went back to my origional tab and rechecked. the TSV34 13 DMA. It WAS checked "Shift Left". I hate to waste someones time especially when I make stupid mistakes myself. I had unchecked another time period MA. That was also on the chart!

Maybe, I'll stick to 2+2 = 4

I am soory for the resistance, but you stood your ground. Touche


Robin Hood

Bruce_L
Posted : Friday, April 28, 2006 9:38:29 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
We're here to help. It's was an easy thing to miss. I'm glad you were able to figure it out!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.