Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Custom Indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
TheTechnician
Posted : Thursday, February 2, 2012 1:46:55 PM
Registered User
Joined: 7/24/2008
Posts: 55
Is it possible in TC2000 to create a custom indicator which takes the standard deviation of 20 log price changes?
Bruce_L
Posted : Thursday, February 2, 2012 1:50:01 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
SQR((LOG(C / C1) ^ 2 + LOG(C1 / C2) ^ 2 + LOG(C2 / C3) ^ 2 + LOG(C3 / C4) ^ 2 + LOG(C4 / C5) ^ 2 + LOG(C5 / C6) ^ 2 + LOG(C6 / C7) ^ 2 + LOG(C7 / C8) ^ 2 + LOG(C8 / C9) ^ 2 + LOG(C9 / C10) ^ 2 + LOG(C10 / C11) ^ 2 + LOG(C11 / C12) ^ 2 + LOG(C12 / C13) ^ 2 + LOG(C13 / C14) ^ 2 + LOG(C14 / C15) ^ 2 + LOG(C15 / C16) ^ 2 + LOG(C16 / C17) ^ 2 + LOG(C17 / C18) ^ 2 + LOG(C18 / C19) ^ 2 + LOG(C19 / C20) ^ 2 - (LOG(C / C20) ^ 2) / 20) / 20)

Historical Volatility (HV)
PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 2, 2012 1:56:08 PM
Registered User
Joined: 7/24/2008
Posts: 55
Can I also take the standard deviation value and multiply it by the close on day 21?  Then can I divide the day 22 price change by that value?
Bruce_L
Posted : Thursday, February 2, 2012 2:01:37 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (TheTechnician)
Can I also take the standard deviation value and multiply it by the close on day 21?

How does the Close of day 21 relate to the 20-Period Standard Deviation. Is it the last day of the Standard Deviation being calculated, the day after or something else?

QUOTE (TheTechnician)
Then can I divide the day 22 price change by that value?

Are you talking Net Change, Price Percent Change or something else?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 2, 2012 6:50:39 PM
Registered User
Joined: 7/24/2008
Posts: 55
I mean the net change, not percentage.  I multiply by the close on day 21 so I can find out the magnitude of a 1 standard deviation price change at the end of the window.
Bruce_L
Posted : Friday, February 3, 2012 8:05:59 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try the following:

(C - C22) / (C * SQR((LOG(C / C1) ^ 2 + LOG(C1 / C2) ^ 2 + LOG(C2 / C3) ^ 2 + LOG(C3 / C4) ^ 2 + LOG(C4 / C5) ^ 2 + LOG(C5 / C6) ^ 2 + LOG(C6 / C7) ^ 2 + LOG(C7 / C8) ^ 2 + LOG(C8 / C9) ^ 2 + LOG(C9 / C10) ^ 2 + LOG(C10 / C11) ^ 2 + LOG(C11 / C12) ^ 2 + LOG(C12 / C13) ^ 2 + LOG(C13 / C14) ^ 2 + LOG(C14 / C15) ^ 2 + LOG(C15 / C16) ^ 2 + LOG(C16 / C17) ^ 2 + LOG(C17 / C18) ^ 2 + LOG(C18 / C19) ^ 2 + LOG(C19 / C20) ^ 2 - (LOG(C / C20) ^ 2) / 20) / 20))

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Friday, February 3, 2012 10:58:51 AM
Registered User
Joined: 7/24/2008
Posts: 55
I would like to dsplay the information as a bar chart underneath my price chart in real-time perhaps using the closes for 2 or 5 minute bars.  The key is I want it to be a 20 period sliding window.  For example closes 1 to 21, closes 2 to 22, closes 3 to 23 and so on.  So after it outputs a value, the window slides forward until the close of trading.  The opening bar for the morning will be based on the 19 periods the day before.  So it is continuous and I do not have to wait for twenty bars in the morning for an output to be displayed.
Bruce_L
Posted : Friday, February 3, 2012 11:00:57 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You should be able to just use the formula in a Custom PCF Indicator. In TC2000 version 7, you would be limited to plotting the indicator as a line, but in TC2000 version 12, you can set the Plot Style to Histogram.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Friday, February 3, 2012 11:12:02 AM
Registered User
Joined: 7/24/2008
Posts: 55
So all I have to do is write that formula you put down and it is going to do everything I want?
Bruce_L
Posted : Friday, February 3, 2012 11:18:47 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If you do it in a Custom PCF Indicator set with a Histogram Plot Style, yes, it should (unless I'm misunderstanding something about your request).

- Select Add Indicator.
- Choose Custom PCF Indicator.
- Click on the Custom PCF Indicator and select Edit.
- Change the Plot Style to Histogram.
- Copy and Paste the formula into the Formula window (use ctrl-v to paste).
- Give it a label and change the colors if you want.
- Select OK.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Friday, February 3, 2012 11:22:43 AM
Registered User
Joined: 7/24/2008
Posts: 55
could you please explain how that formula works
Bruce_L
Posted : Friday, February 3, 2012 11:37:36 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The following portion represents a 22-Period Net Change:

(C - C22)

It is in parentheses to force an order of operations before the division:

/

The next section multiplies the current Price by the Standard Devation of the logarithm of price changes:

(C * SQR((LOG(C / C1) ^ 2 + LOG(C1 / C2) ^ 2 + LOG(C2 / C3) ^ 2 + LOG(C3 / C4) ^ 2 + LOG(C4 / C5) ^ 2 + LOG(C5 / C6) ^ 2 + LOG(C6 / C7) ^ 2 + LOG(C7 / C8) ^ 2 + LOG(C8 / C9) ^ 2 + LOG(C9 / C10) ^ 2 + LOG(C10 / C11) ^ 2 + LOG(C11 / C12) ^ 2 + LOG(C12 / C13) ^ 2 + LOG(C13 / C14) ^ 2 + LOG(C14 / C15) ^ 2 + LOG(C15 / C16) ^ 2 + LOG(C16 / C17) ^ 2 + LOG(C17 / C18) ^ 2 + LOG(C18 / C19) ^ 2 + LOG(C19 / C20) ^ 2 - (LOG(C / C20) ^ 2) / 20) / 20))

Note that this is also in parentheses to force an order of operations before the division. The current close is:

C

While the Standard Deviation of the twenty most recent log price changes:

SQR((LOG(C / C1) ^ 2 + LOG(C1 / C2) ^ 2 + LOG(C2 / C3) ^ 2 + LOG(C3 / C4) ^ 2 + LOG(C4 / C5) ^ 2 + LOG(C5 / C6) ^ 2 + LOG(C6 / C7) ^ 2 + LOG(C7 / C8) ^ 2 + LOG(C8 / C9) ^ 2 + LOG(C9 / C10) ^ 2 + LOG(C10 / C11) ^ 2 + LOG(C11 / C12) ^ 2 + LOG(C12 / C13) ^ 2 + LOG(C13 / C14) ^ 2 + LOG(C14 / C15) ^ 2 + LOG(C15 / C16) ^ 2 + LOG(C16 / C17) ^ 2 + LOG(C17 / C18) ^ 2 + LOG(C18 / C19) ^ 2 + LOG(C19 / C20) ^ 2 - (LOG(C / C20) ^ 2) / 20) / 20)

Now you may be asking yourself why it is the ratio of C / C1 instead of the Net Change of C - C1. If you ale asking yourself this, it is because taking the LOG of C - C1 does not make any sense as the logarithms of zero and below are undefined (a logarithm must be of a positive number).

Taking the standard devation of the logarithms of the ratios of prices is done when calculating Historical Volatility which is why I referenced the Historical Volatility (HV) topic in my first reply. There is significant discussion of the exact form of the formula. Modelling Bollinger Bands (& Standard Deviation) in a TC PCF is a more generalized topic on calculating standard devation.

The PCF Formula Descriptions topic, which was also referenced in my first reply, contains a fairly comprehensive list of the syntax which is valid in the Personal Criteria Formula Language.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Friday, February 3, 2012 11:45:06 AM
Registered User
Joined: 7/24/2008
Posts: 55
and it is going to slide forward after each 2 or 5 minute bar?
Bruce_L
Posted : Friday, February 3, 2012 11:49:27 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Unless I am misunderstanding what you mean by that phrase, yes. Custom PCF Indicators will calculate for every bar for which enough data is available to calculate. Try it.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Friday, February 3, 2012 12:07:16 PM
Registered User
Joined: 7/24/2008
Posts: 55
And will I be able to sort based on that indicator.  Like I would sorting for stocks with recent multiple high values.  Like in the last 10 bars 3 or more bars with values of 3 or more, something like that.
Bruce_L
Posted : Friday, February 3, 2012 12:14:20 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You can sort on value of the Custom PCF Indicator by clicking on it and selecting Add Column to WatchList.

You can create Conditions based on the Custom PCF Indicator by clicking on it and selecting Create Condition.

Indicators, Sorting & Scanning

While a wide variety of Conditions could be created, three of the most recent ten bars had values above three is not amongst them.

That said, you could create a Custom PCF % Indicator checking for the value to be at least 3:

(C - C22) / (C * SQR((LOG(C / C1) ^ 2 + LOG(C1 / C2) ^ 2 + LOG(C2 / C3) ^ 2 + LOG(C3 / C4) ^ 2 + LOG(C4 / C5) ^ 2 + LOG(C5 / C6) ^ 2 + LOG(C6 / C7) ^ 2 + LOG(C7 / C8) ^ 2 + LOG(C8 / C9) ^ 2 + LOG(C9 / C10) ^ 2 + LOG(C10 / C11) ^ 2 + LOG(C11 / C12) ^ 2 + LOG(C12 / C13) ^ 2 + LOG(C13 / C14) ^ 2 + LOG(C14 / C15) ^ 2 + LOG(C15 / C16) ^ 2 + LOG(C16 / C17) ^ 2 + LOG(C17 / C18) ^ 2 + LOG(C18 / C19) ^ 2 + LOG(C19 / C20) ^ 2 - (LOG(C / C20) ^ 2) / 20) / 20)) >= 3

Set the Period to 10 and the Average Type to Simple. You could then click on the Custom PCF % True Indicator to see if its Value was greater than 29 (since 30% would represent 3 of 10 bars).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Friday, February 3, 2012 1:14:33 PM
Registered User
Joined: 7/24/2008
Posts: 55

Thanks a lot, Bruce.  You are a very sharp man.

TheTechnician
Posted : Saturday, February 4, 2012 6:48:30 PM
Registered User
Joined: 7/24/2008
Posts: 55
Does TC2000 have an rsquared function or Pearson product-moment correlation coefficient function.  If not, can I create it in the PCF?
diceman
Posted : Saturday, February 4, 2012 8:29:27 PM
Registered User
Joined: 1/28/2005
Posts: 6,049
QUOTE (TheTechnician)
Does TC2000 have an rsquared function or Pearson product-moment correlation coefficient function.  If not, can I create it in the PCF?



See this:

http://forums.worden.com/default.aspx?g=posts&t=40969


Thanks
diceman
TheTechnician
Posted : Monday, February 6, 2012 1:01:28 AM
Registered User
Joined: 7/24/2008
Posts: 55
Bruce, is there a formula I can create like R-squared or Pearson's product-moment correlation coefficient that determines the strength of trends in real-time which I can use to sort stocks by?
Bruce_L
Posted : Monday, February 6, 2012 9:06:15 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You were referred to the correct topic by diceman (or at least to a topic which would have referred you to the correct topic). You can give it a read through to see how such formulas would be constructed, and it includes example formulas as well:

Need help writing a PCF for r-squared

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Monday, February 6, 2012 1:07:54 PM
Registered User
Joined: 7/24/2008
Posts: 55
How many stock price quotes can you input into Excel?  How much price data from TC2000 can you put into an Excel spreadsheet?  Thanks
Bruce_L
Posted : Monday, February 6, 2012 1:18:59 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
In TC2000 version 12, you can select the Export Chart Data icon (it looks like two barrels or two stacks of coins) to export the data for the Active Symbol for that chart to a text file. You could then use Excel's Import Wizard to bring the data into Excel. This is limited to a single symbol at a time and the 500-bars of data which are on the chart.

In TC2000 version 7, you can export data for either symbols or WatchLists by selecting Databank | Export to Text. Symbols can have up to 25 years of data available. You could again use Excel's Import Wizard to bring the data into Excel.

Exporting data to text format - comma, space or tab delimited

I am not aware of any limits on how much data Excel could handle, but we do not support third party products.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Monday, February 6, 2012 3:13:53 PM
Registered User
Joined: 7/24/2008
Posts: 55
can i import data from stockfinder intraday data for 25 years
Bruce_L
Posted : Monday, February 6, 2012 3:19:42 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
No. StockFinder starts with several months of intraday data and builds up its database as you continue to download.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Tuesday, February 7, 2012 1:57:46 PM
Registered User
Joined: 7/24/2008
Posts: 55
The data is version seven, the price quotes that go back 25 years, is that intraday or end of day?
Bruce_L
Posted : Tuesday, February 7, 2012 2:00:51 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It is end of day data.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 9, 2012 2:08:30 PM
Registered User
Joined: 7/24/2008
Posts: 55
Bruce, I tried that indicator you wrote and it doesn't look right.
Bruce_L
Posted : Thursday, February 9, 2012 2:21:29 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
What makes you think it is incorrect? To what are you comparing it?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 9, 2012 2:48:14 PM
Registered User
Joined: 7/24/2008
Posts: 55
I got it from a book and when I look at the charts in the book they do not match.  The frequency of the up and down moves does not look right.  In the book there are red and green bars up and down books.  The indicator you wrote just has a lot of green bars followed by a lot of red bars.
Bruce_L
Posted : Thursday, February 9, 2012 2:51:29 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
What is the indicator called?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 9, 2012 3:05:37 PM
Registered User
Joined: 7/24/2008
Posts: 55
It is from Jeff Augen's "The Volatility Edge in Options Trading".  Taking exactly from the book the three steps to calculate:

1.  Calculate the standard deviation of the 20 price changes immediately preceding the spike(days 1 to 21).  The vaue obtained is the one day volatility at the end of the 20 price change window.

2.  Multiply this number by the value of the close on day 21 to determine the magnitude of a 1 standard deviation price change at the end of the window.

3.  Divide the day 22 price change by this value to recast the change in standard deviations.

Bruce_L
Posted : Thursday, February 9, 2012 3:14:24 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try the following:

(C - C1) / (SQR(ABS((C1 - C2) ^ 2 + (C2 - C3) ^ 2 + (C3 - C4) ^ 2 + (C4 - C5) ^ 2 + (C5 - C6) ^ 2 + (C6 - C7) ^ 2 + (C7 - C8) ^ 2 + (C8 - C9) ^ 2 + (C9 - C10) ^ 2 + (C10 - C11) ^ 2 + (C11 - C12) ^ 2 + (C12 - C13) ^ 2 + (C13 - C14) ^ 2 + (C14 - C15) ^ 2 + (C15 - C16) ^ 2 + (C16 - C17) ^ 2 + (C17 - C18) ^ 2 + (C18 - C19) ^ 2 + (C19 - C20) ^ 2 + (C20 - C21) ^ 2 - 20 * AVGC20.1 ^ 2) / 20) * C1)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 9, 2012 3:17:43 PM
Registered User
Joined: 7/24/2008
Posts: 55
What do I put down for period, Bruce?
Bruce_L
Posted : Thursday, February 9, 2012 3:22:06 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The Period setting of a Custom Indicator is the period of an optional Moving Average being applied to the indicator. Since you want to return the actual value of the formula and not the value of a Moving Average of the formula, you would want to set the period to 1 (and when the Period setting is 1, the Average Type does not matter).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 9, 2012 3:25:21 PM
Registered User
Joined: 7/24/2008
Posts: 55
Looks great.  How do I set up the scale?  How do I label the graph?
Bruce_L
Posted : Thursday, February 9, 2012 3:32:41 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The graph should already be labeled with values (relatively small values I'm sure). You can click on the indicator and choose Scaling to adjust the scale if desired. You probably want the Scale Method set to either Auto or Center on 0, but the rest of the options would be entirely up to you.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TheTechnician
Posted : Thursday, February 9, 2012 3:38:55 PM
Registered User
Joined: 7/24/2008
Posts: 55
OK, one last thing.  In an earlier post you wrote how to sort based on that indicator.  How would I adjust that for this new one?
TheTechnician
Posted : Thursday, February 9, 2012 3:43:18 PM
Registered User
Joined: 7/24/2008
Posts: 55
how do i label the grid 1 2 3 and -1 -2 -3
TheTechnician
Posted : Thursday, February 9, 2012 4:00:41 PM
Registered User
Joined: 7/24/2008
Posts: 55
on the scaling it has 0 for all values.  I have it on auto arithmetic and centered on zero but i have no values on the scale
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.