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 |

OBV Unstable? Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
jfh123
Posted : Friday, December 17, 2004 10:07:28 AM
Registered User
Joined: 12/17/2004
Posts: 143
I have been programming TC2000 for a couple of years, but this is my first post to Worden's online disc. bd. I think I have detected a problem with OBV (or maybe I just don't understand how it works ): I created 2 PCFs.

THe first is just OBV9.0-OBV9.0

The second is OBV9.0-OBV9.1

But, when I test them (Using yesrerday's (12/16/04) closing data, on BCON (nothing special about it; the problem appears on many stocks ... lik IBM), I get:

For the first: 9861-9861.

For the second: 14071-29033.

How can subtracting something different from OBV9.0 change OBV9.0?

Thanks for any help you can offer.
Craig_S
Posted : Friday, December 17, 2004 10:25:43 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
The explaination for this is the same why MoneyStream will give different values for the same day in PCF. Read this thread on MoneyStream in a PCF as it also applies to OBV:

PCF using MS

- Craig
Here to Help!
jfh123
Posted : Friday, December 17, 2004 11:06:03 AM
Registered User
Joined: 12/17/2004
Posts: 143
I read the whole thread you referred me to. While it effectively tells me "don't divide by a negative" and "relying on what MS appears to be, using the Y axis, is dangerous", and both of these I understand, it doesn't address why OBV changes when I subtract something different from it than itself. Can you help with this question? Thanks.
Craig_S
Posted : Friday, December 17, 2004 11:17:33 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
The starting number used to calculate a cumulative indicator can change from calculation to calculation. The actual values are meaningless. What does matter us how the values compare to each other over time. Divide your two numbers you gave and you will find they return the same ratio.

Does this help?

- Craig
Here to Help!
StockGuy
Posted : Friday, December 17, 2004 11:21:22 AM

Administration

Joined: 9/30/2004
Posts: 9,187
The value of OBV depends on where you start the calculation. The actual value isn't significant. But OBV9-OBV9.1 will give you the difference between OBV9 today and OBV9 yesterday.
jfh123
Posted : Friday, December 17, 2004 11:26:35 AM
Registered User
Joined: 12/17/2004
Posts: 143
Maybe. The uncertainty you mention makes it VERY hard to vet an OBV PCF. I think I found a more transparent way to do my OBV calculations: use OBV1 + obv1.1 + ... obv1.8 instead of obv9.0. This gives me "standard obv" not "tc2000 obv" (which can be hard to vet). Thanks.
Craig_S
Posted : Friday, December 17, 2004 11:32:22 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
The thread on MS PCFs should help you in writing your PCFs. Adding or subtracting should be avoided, in my opinion, because the difference or the sum of OBV returns meaningless values. When you read OBV, a move is significant or not because of the value of the move (the number) but how that move compares other moves on the chart. What you are seeing is not a different calculation of OBV (there is no "TC2000 OBV). We calculate OBV using the standard formula. It is a cumulative indicator so the starting number of the calculation can change and is meaningless.

What are you trying to scan for with OBV? What action on the chart are you trying to isolate?

- Craig
Here to Help!
jfh123
Posted : Friday, December 17, 2004 11:40:25 AM
Registered User
Joined: 12/17/2004
Posts: 143
Thanks for your input, Stock Guy. I guess I need to ask what OBV9 is. I thought it was a 9-pd avg of OBV. Maybe it'd be simpler to understand OBV1.0 vs obv1.1? A PCF of just obv1.0 gives me an answer I recognize: today's volume if today's close is above yesterday's. But, when I add it to OBV1.1, I no longer recognize how either number was calculated; I guess we're supposed to take it on faith that these figures are the cumulative OBV components from the start of trading until now, but ... I'm trying to create an indicator, and don't see how I can ensure it's right if I can't ensure parts of the PCF are performing as desired. Is there any way to just get yesterday's volume multiplied by -1 if it was a down day?
StockGuy
Posted : Friday, December 17, 2004 11:50:52 AM

Administration

Joined: 9/30/2004
Posts: 9,187
You've found what looks like a bug in the PCF editor and calc engine. I'll report this to the development team.
jfh123
Posted : Friday, December 17, 2004 12:07:29 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Craig_S)
The thread on MS PCFs should help you in writing your PCFs. Adding or subtracting should be avoided, in my opinion, because the difference or the sum of OBV returns meaningless values. When you read OBV, a move is significant or not because of the value of the move (the number) but how that move compares other moves on the chart. What you are seeing is not a different calculation of OBV (there is no "TC2000 OBV). We calculate OBV using the standard formula. It is a cumulative indicator so the starting number of the calculation can change and is meaningless.

I got the idea that there was such a thing as a TC2000 OBV from many discussions with tech support. TC2k does exponetial MA's a bit non-standard (understandably) and so I figured the fact that OBV in TC2k wasn't conforming to what I expected was due to a similar decision to do it differently.

What are you trying to scan for with OBV? What action on the chart are you trying to isolate?


I am trying to create an oscillator. If every day in these 10 days is down vs the previous day, it would read -100. Using obv1.0-obv1.1 got me yeserday's volume isolated. obv1.0-obv1.2 got me 2 days' volume isolated and added appropriately. Worked until I got to obv1.0-obv1.6, which gave me the same value as obv1.0-obv1.5. Can you help me write a pcf which multiplies the volume 5 days back by -1 if that day closes below the previous day?
jfh123
Posted : Friday, December 17, 2004 12:12:08 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (StockGuy)
You've found what looks like a bug in the PCF editor and calc engine. I'll report this to the development team.


Thank you, Stock Guy!!! TC2000 is better than anything else out there, but it DOES have bugs. In the meantime, can we get around this bug?
Craig_S
Posted : Friday, December 17, 2004 12:18:25 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Try this:

V1.5 * (C5 < C6)

This will return 0 if C5>C6 and will return the volume 5 days ago * -1 if C5>C6

Does this do it for you?

- Craig
Here to Help!
jfh123
Posted : Friday, December 17, 2004 12:18:47 PM
Registered User
Joined: 12/17/2004
Posts: 143
[quote=Craig_S]The thread on MS PCFs should help you in writing your PCFs. Adding or subtracting should be avoided, in my opinion, because the difference or the sum of OBV returns meaningless values. When you read OBV, a move is significant or not because of the value of the move (the number) but how that move compares other moves on the chart. What you are seeing is not a different calculation of OBV (there is no &quot;TC2000 OBV). We calculate OBV using the standard formula. It is a cumulative indicator so the starting number of the calculation can change and is meaningless.quote]

obv2.0 gives me:

yesterday's volume x (1 if it was an up day; -1 if it was a down day)

+

today's volume, divided by 2, then x (1 if it was an up day; -1 if it was a down day)

Is this part of the bug?
Craig_S
Posted : Friday, December 17, 2004 12:21:56 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Let's take OBV out of this completely. Can you explain how you want your indicator to work relative to Price and Volume? Let me play with that. I understand what you are trying to do by using OBV but think there may be an easier way.

- Craig
Here to Help!
jfh123
Posted : Friday, December 17, 2004 12:29:43 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Craig_S)
Try this:

V1.5 * (C5 &lt; C6)

This will return 0 if C5&gt;C6 and will return the volume 5 days ago * -1 if C5&gt;C6

Does this do it for you?


It does help a lot. Now I see TC2k does offer boolean capabilities? Awesome. Not yet sure I know how to use them, but ... very encouraging. Now I like TC2k even more!

I think your approach will get around the obv bug, and give me endless flexivility (even if it means longer PCFs). The only problem with this is, I want the volume regardless, I just want it positive if it was an up day and negative if it was a down day. May I have a formula for that?
jfh123
Posted : Friday, December 17, 2004 12:34:21 PM
Registered User
Joined: 12/17/2004
Posts: 143
I think the following will do it (I am trying to learn to fish ), but am still checking it:

V1.5 * (C5 > C6)+V1.5 * (C5 < C6)
Craig_S
Posted : Friday, December 17, 2004 12:40:05 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Keep us updated on your progress. I love that you are looking to do it on your own vs. me spouting out formulas to you.

- Craig
Here to Help!
jfh123
Posted : Friday, December 17, 2004 1:38:36 PM
Registered User
Joined: 12/17/2004
Posts: 143
V3*(C3>C4)*(-1)+V3*(C3<C4)

Finally worked, but it's a bit ugly. I am guessing at how to use what appears to be boolean in what you gave me. The help function provided nothing useful when I put "boolean" in search and index. Would you refer me to a tutorial on using the "(c3>c4)" function? Thanks.
Craig_S
Posted : Friday, December 17, 2004 1:44:33 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Can't... its not documented! If you use it alone it will return a true/false. In an equation it will equal -1,0

- Craig
Here to Help!
testOP2
Posted : Monday, December 20, 2004 4:57:58 PM

Administration

Joined: 10/7/2004
Posts: 378
Ok. here is the skiiny on OBV and other cumulative indicators and how PCFs are calced in TeleChart. Cumulative indicators start at the value of the oldest point calculated. Each point after that is added to the total and becomes the value for that point.

So if we have a series like this:
500 25 -100 10 -300 our cumulative values would be
500 525 425 435 135 assuming I can still add.

I am going to use a shorter average period to make things a little easier.

When we compile a formula we determine the maximum amount of data we need for the whole formula. So if you have a OBV2 we know we only need 2 obv values for this formula. So if the value are from oldest to newest:

-100 500
-100 400 Then as a cumulative value

N/A 150 Then OBV2 which is the average would be


Now if we change the formula to OBV2 - OBV2.1 we need three points. 2 for the average and one additional to get the value yesterday So we will add a number to the beggining of the calc for the raw obv value 3 days ago.

600 -100 500
600 500 0 Then as a cumulative value

Than taking the 2 period average gives

OBV2.1 OBV2
N/A 550 250


Notice OBV2 is different than the first value we found. Now the importatnt thing to understand is that TeleChart computes enough data to satisfy all components in the formula which means that their relative (i.e. subtracted or added or percentile) values are valid, but their raw values are meaningless. OBV9 on its own really tells you nothing, but compared to a previous date is meaningfull. To satisfy you curiosity try the following:

Compare the values for the formulas

OBV9-OBV9.1

and

OBV9-OBV9.1 +OBV9.50 - OBV9.50

You will notice that the values for OBV9 and OBV9.1 are very different between each of the values, but their relative values are the same.

Hope this helps
Ole
Tanstaafl
Posted : Tuesday, December 21, 2004 7:37:23 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, JFH:

Ole's response is thorough ... straight from the horse's mouth ... the only other comment I might add is that cumulative indicators such as OBV (or MS or many others) for all practical purposes MUST be handled the way that TC does them. If they were based on a FULL set of historical bars, the software would run too slowly, and the result would not be any more accurate or useful.

Regarding the boolean operations, MUCH has been written and discussed about this. You might try my "ATR Two Ways" June 6, 2003 Worden Report as a starting point with some practical benefit.

Regarding your formula:
V1.5 * (C5 > C6)+V1.5 * (C5 < C6)

The result of this formula will be equal to the simpler formula
-V1.5
UNLESS C5 is precisely equal to C6.

In TC, any boolean expression (i.e. using >=<AndOr) can be converted to algebraic values of -1 (true) or 0 (false) by enclosing it in paren's and making it a part of a value-based calculation.

For example,
H>=L
returns a value of "True" when used as a PCF, for all bars of all stocks, and
H<L
returns a value of "False" in all cases, while
C>O
only is true for up-bars.

If you create a PCF:
(C>O)*(O-C) + (C<=O)*(L-H)
Then you will get one of two different answers:
1) if the Close is greater than the Open, then the result will be the Close minus the Open = the Body of the candle (a positive number)
2) if the Close is NOT greater than the Open, then the result will be the High minus the Low = the Range of the candle (a positive number)

Studying that example a while will make it clear to you that to overcome the "True= -1" multiplier effect, the related value must be made negative.

Also, you will come to realize that this approach offers a crude but serviceable, and RELIABLE means of doing "If..Then..Else" statements in PCF-eze.

There are many, many things you can do with this simple technique.

I hope this helps.

Jim Dean


Kuf
Posted : Tuesday, December 21, 2004 9:55:24 AM


Administration

Joined: 9/18/2004
Posts: 3,522
QUOTE (Tanstaafl)
Also, you will come to realize that this approach offers a crude but serviceable, and RELIABLE means of doing &quot;If..Then..Else&quot; statements in PCF-eze.


And actually it's a technique a lot of assembly programmers use to speed up code :)

Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
jfh123
Posted : Tuesday, December 21, 2004 1:50:08 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (testOP2)
Ok. here is the skiiny on OBV and other cumulative indicators and how PCFs are calced in TeleChart. Cumulative indicators start at the value of the oldest point calculated. Each point after that is added to the total and becomes the value for that point.

So if we have a series like this:
500 25 -100 10 -300 our cumulative values would be
500 525 425 435 135 assuming I can still add.

I am going to use a shorter average period to make things a little easier.

When we compile a formula we determine the maximum amount of data we need for the whole formula. So if you have a OBV2 we know we only need 2 obv values for this formula. So if the value are from oldest to newest:

-100 500
-100 400 Then as a cumulative value

N/A 150 Then OBV2 which is the average would be


Now if we change the formula to OBV2 - OBV2.1 we need three points. 2 for the average and one additional to get the value yesterday So we will add a number to the beggining of the calc for the raw obv value 3 days ago.

600 -100 500
600 500 0 Then as a cumulative value

Than taking the 2 period average gives

OBV2.1 OBV2
N/A 550 250


Notice OBV2 is different than the first value we found. Now the importatnt thing to understand is that TeleChart computes enough data to satisfy all components in the formula which means that their relative (i.e. subtracted or added or percentile) values are valid, but their raw values are meaningless. OBV9 on its own really tells you nothing, but compared to a previous date is meaningfull. To satisfy you curiosity try the following:

Compare the values for the formulas

OBV9-OBV9.1

and

OBV9-OBV9.1 +OBV9.50 - OBV9.50

You will notice that the values for OBV9 and OBV9.1 are very different between each of the values, but their relative values are the same.

Hope this helps
Ole


Ole,

Thanks for a detailed response. Not sure I understand every bit of it, but I think your point is that adding a day causes OBV2 to change it's absolute, but not relative, value vs other dates.

If so, that's not my concern. My concern was/is that, a PCF of "obv9.0" gives a different value that a pcf of "obv9.0-obv9.0". Is this a bug, or am I still missing something in how obv works?

J
jfh123
Posted : Tuesday, December 21, 2004 1:53:59 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Tanstaafl)
Hi, JFH:

Ole's response is thorough ... straight from the horse's mouth ... the only other comment I might add is that cumulative indicators such as OBV (or MS or many others) for all practical purposes MUST be handled the way that TC does them. If they were based on a FULL set of historical bars, the software would run too slowly, and the result would not be any more accurate or useful.

Regarding the boolean operations, MUCH has been written and discussed about this. You might try my &quot;ATR Two Ways&quot; June 6, 2003 Worden Report as a starting point with some practical benefit.

Regarding your formula:
V1.5 * (C5 &gt; C6)+V1.5 * (C5 &lt; C6)

The result of this formula will be equal to the simpler formula
-V1.5
UNLESS C5 is precisely equal to C6.

In TC, any boolean expression (i.e. using &gt;=&lt;AndOr) can be converted to algebraic values of -1 (true) or 0 (false) by enclosing it in paren's and making it a part of a value-based calculation.

For example,
H&gt;=L
returns a value of &quot;True&quot; when used as a PCF, for all bars of all stocks, and
H&lt;L
returns a value of &quot;False&quot; in all cases, while
C&gt;O
only is true for up-bars.

If you create a PCF:
(C&gt;O)*(O-C) + (C&lt;=O)*(L-H)
Then you will get one of two different answers:
1) if the Close is greater than the Open, then the result will be the Close minus the Open = the Body of the candle (a positive number)
2) if the Close is NOT greater than the Open, then the result will be the High minus the Low = the Range of the candle (a positive number)

Studying that example a while will make it clear to you that to overcome the &quot;True= -1&quot; multiplier effect, the related value must be made negative.

Also, you will come to realize that this approach offers a crude but serviceable, and RELIABLE means of doing &quot;If..Then..Else&quot; statements in PCF-eze.

There are many, many things you can do with this simple technique.

I hope this helps.

Jim Dean


Jim,

This is very helpful. Thank you! Not sure why they chose to make true be -1, and not 1. But, now that I know, TC2K has so much more potential. Best to you.
testOP2
Posted : Tuesday, December 21, 2004 2:06:04 PM

Administration

Joined: 10/7/2004
Posts: 378
on some random stock I show

Formula OBV9.0 - OBV9.0
42364.78 - 42364.78
Result = 0

Formula OBV9.0
42364.78
Result = 42364.78

Looks right to me. Hmmm dunno

Ole
jfh123
Posted : Tuesday, December 21, 2004 2:54:25 PM
Registered User
Joined: 12/17/2004
Posts: 143
Looks right to me also. I think we have to wait until EoD to test this, so we know our PCs are working off the same data. One of the admin. guys (Stock Guy) agreed this was a bug, but they may have fixed it since then (12/17/04)? I will try to do a test after the close, then report my findings here. Thanks!
StockGuy
Posted : Tuesday, December 21, 2004 3:39:57 PM

Administration

Joined: 9/30/2004
Posts: 9,187
No, jfh123, I was wrong...misinterpreting what I was seeing. Here's what I tested using IBM as the test symbol.

OBV1 = 33185 (which is also equal to today's volume since that is all that's needed to find the absolute value of OBV for today)

OBV1 - OBV1.1 = 80844 - 47699 = 33185

I think the change in OBV is what is throwing you (and me) off. OBV1 (today) is now 80844 because two days of data are used in the formula calculation since you're subtracting OBV1.1 (yesterday). Today's volume 33185 + yesterday's volume 47699 = 80884 (today's OBV value using only the last two days for the calculation.)

The change in OBV from yesterday to today remains the same, 33185 (today's volume). That's why we've been saying that the value of OBV on any one day is a meaningless number, but the difference from a previous date is what is significant.
jfh123
Posted : Wednesday, December 22, 2004 2:05:52 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (StockGuy)
No, jfh123, I was wrong...misinterpreting what I was seeing. Here's what I tested using IBM as the test symbol.

OBV1 = 33185 (which is also equal to today's volume since that is all that's needed to find the absolute value of OBV for today)

OBV1 - OBV1.1 = 80844 - 47699 = 33185

I think the change in OBV is what is throwing you (and me<img src="/training/images/emoticons/smile006.gif"/>) off. OBV1 (today) is now 80844 because two days of data are used in the formula calculation since you're subtracting OBV1.1 (yesterday). Today's volume 33185 + yesterday's volume 47699 = 80884 (today's OBV value using only the last two days for the calculation.)

The change in OBV from yesterday to today remains the same, 33185 (today's volume). That's why we've been saying that the value of OBV on any one day is a meaningless number, but the difference from a previous date is what is significant.


Seems the problem I found has been fixed. The other things I wanted to do with volume were easier if I just used boolean statements and volume, so I'm no longer trying to figure out OBV's idiosyncacies. Thanks for your help.
jfh123
Posted : Wednesday, December 22, 2004 2:31:25 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (jfh123)
[quote=Tanstaafl]Hi, JFH:

Regarding the boolean operations, MUCH has been written and discussed about this. You might try my &amp;quot;ATR Two Ways&amp;quot; June 6, 2003 Worden Report as a starting point with some practical benefit.

Regarding your formula:
V1.5 * (C5 &amp;gt; C6)+V1.5 * (C5 &amp;lt; C6)

The result of this formula will be equal to the simpler formula
-V1.5
UNLESS C5 is precisely equal to C6.

In TC, any boolean expression (i.e. using &amp;gt;=&amp;lt;AndOr) can be converted to algebraic values of -1 (true) or 0 (false) by enclosing it in paren's and making it a part of a value-based calculation.

For example,
H&amp;gt;=L
returns a value of &amp;quot;True&amp;quot; when used as a PCF, for all bars of all stocks, and
H&amp;lt;L
returns a value of &amp;quot;False&amp;quot; in all cases, while
C&amp;gt;O
only is true for up-bars.

If you create a PCF:
(C&amp;gt;O)*(O-C) + (C&amp;lt;=O)*(L-H)
Then you will get one of two different answers:
1) if the Close is greater than the Open, then the result will be the Close minus the Open = the Body of the candle (a positive number)
2) if the Close is NOT greater than the Open, then the result will be the High minus the Low = the Range of the candle (a positive number)

Studying that example a while will make it clear to you that to overcome the &amp;quot;True= -1&amp;quot; multiplier effect, the related value must be made negative.

Also, you will come to realize that this approach offers a crude but serviceable, and RELIABLE means of doing &amp;quot;If..Then..Else&amp;quot; statements in PCF-eze.

There are many, many things you can do with this simple technique.

I hope this helps.

Jim Dean


Jim,

I read your 6/6/03 contribution, and even understood it . How do I know? Because I was able to write a PCF which finds the minimum and maximum of a custom indicator for the past 16 days, then where today falls within that range (a very simplified oscillator). I did so, by using your "abs" technique to tell me whether today or yesrerday has the lower CI reading, then used another statement to find the lower of 2 days ago (2da) vs 3da. Then a 3rd statement told me which was the minimum of day 0&1 vs day 2&3. 3 more statements gave me the min. of days 4-7. A 7th statement gave me the min. of days 0-7. 7 more statements gave me the min. of days 8-15. A 15th statement gave me the 16-day minimum. Another 15 statements gave me the max. (Today - min) divided by (max-min) gave me the simplified oscillator reading. Unfortunately, the PCF required to do all this was quite large, and I need to do this for at least 30 days, not just one. Any ideas how I can find a 16-pd max or min of a custom indicator without 30 abs statements?

Tanstaafl
Posted : Wednesday, December 22, 2004 4:37:54 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, JFH:

CONGRATULATIONS! You're on your way!

I sure do wish there was a *better* way. But I'm afraid that until/unless some major revamping is done on the PCF language, we are destined to live with Looong formulae in order to accomplish "looping" related tasks such as this.

If it's any consolation, I've written and regularly use some PCF's which even after algebraic optimization, etc are thousands of characters long.

Suggestion: if you are adept with Excel, you can use it to automate the development (and debugging) of stuff like this. Write an Excel equation that creates the string for a single bar's formula-component, then copy that formula down a column with appropriate increments for each new bar. Concatenate all those strings with a formula at the top of the column.

Copy the final results to NotePad (or to the TC edit window) ... don't use Wordpad as the target or the formula-string will get truncated.

This is a method that I've used for several years now to solve a huge number of seemingly-impossible or impractical tasks in PCF-eze.

Even tho the formulae are long, the PCF interpreter can and will reliably deal with them.

Have fun!

Jim Dean

jfh123
Posted : Thursday, December 23, 2004 5:40:26 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Tanstaafl)
Hi, JFH:

CONGRATULATIONS! You're on your way!

I sure do wish there was a *better* way. But I'm afraid that until/unless some major revamping is done on the PCF language, we are destined to live with Looong formulae in order to accomplish &quot;looping&quot; related tasks such as this.

If it's any consolation, I've written and regularly use some PCF's which even after algebraic optimization, etc are thousands of characters long.

Suggestion: if you are adept with Excel, you can use it to automate the development (and debugging) of stuff like this. Write an Excel equation that creates the string for a single bar's formula-component, then copy that formula down a column with appropriate increments for each new bar. Concatenate all those strings with a formula at the top of the column.

Copy the final results to NotePad (or to the TC edit window) ... don't use Wordpad as the target or the formula-string will get truncated.

This is a method that I've used for several years now to solve a huge number of seemingly-impossible or impractical tasks in PCF-eze.

Even tho the formulae are long, the PCF interpreter can and will reliably deal with them.

Have fun!

Jim Dean


Hmm. I'm at 27k characters, with no spaces. My guess is TC2K will be unable to handle 16x that, no? I know that, many times in the past, it has said "not responding", but that meant it was thinking. What's the limit (# of characters, or whatever applies) which you've found, if any? Will it be much faster if I delete my other PCFs (about 30), chart templates (about 20), and/or easyscans (about 20)?
Tanstaafl
Posted : Thursday, December 23, 2004 6:16:19 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, JFH:

I've never received an answer to that question when I've asked before ... I've done 50k strings without the system crashing ... but the recalc time was ridiculous.

HOWEVER ... I think that you need to step back a bit from your work and think about the algebra first. I'm not completely clear what you are trying to do ... but I doubt that 27k char's are required.

If you'd like to lay out the logic here, with some sample code (nicely formatted), PRECEDED by an english-language explanation, then mebbe jest mebbe I can help you shorten it up.

Or maybe not :~)

Jim Dean

jfh123
Posted : Friday, December 24, 2004 11:16:55 AM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Tanstaafl)
Hi, JFH:

I've never received an answer to that question when I've asked before ... I've done 50k strings without the system crashing ... but the recalc time was ridiculous.

HOWEVER ... I think that you need to step back a bit from your work and think about the algebra first. I'm not completely clear what you are trying to do ... but I doubt that 27k char's are required.

If you'd like to lay out the logic here, with some sample code (nicely formatted), PRECEDED by an english-language explanation, then mebbe jest mebbe I can help you shorten it up.

Or maybe not :~)

Jim Dean


Jim,

Thanks for your offer. I accept.

Here's the formula for the lowest close in the past 16 days; it's 1800+ characters. I described it earlier in this thread (first find the low of today vs yesterday, then 2da vs 3da, etc.). The highest close would be another 1800. Today minus the lowest would be another 1800. Replacing the close with a custom indicator means each 2-3 character string ("c00" or "c3") becomes ... 27k. I will work on grouping like items, but I'd guess the absolute statements make it not very compressible, no? Please respond, but don't take time to compress this for me; I want to save your time and candlepower for when I really need it!

((((((((c00+c01-abs(c00-c01))/2)+((c02+c3-abs(c02-c3))/2)-abs(((c00+c01-abs(c00-c01))/2)-((c02+c3-abs(c02-c3))/2)))/2)+((((c4+c5-abs(c4- c5))/2)+((c6+c7-abs(c6-c7))/2)-abs(((c4+c5-abs(c4-c5))/2)-((c6+c7-abs(c6-c7))/2)))/2)-abs(((((c00+c01-abs(c00- c01))/2)+((c02+c3-abs(c02-c3))/2)-abs(((c00+c01-abs(c00- c01))/2)-((c02+c3-abs(c02-c3))/2)))/2)-((((c4+c5-abs(c4- c5))/2)+((c6+c7-abs(c6-c7))/2)-abs(((c4+c5-abs(c4- c5))/2)-((c6+c7-abs(c6-c7))/2)))/2)))/2)+ ((((((c8+c9-abs(c8-c9))/2)+((c10+c11-abs(c10-c11))/2)-abs(((c8+c9-abs(c8-c9))/2)-((c10+c11-abs(c10-c11))/2)))/2)+((((c12+c13-abs(c12- c13))/2)+((c14+c15-abs(c14-c15))/2)-abs(((c12+c13-abs(c12-c13))/2)-((c14+c15-abs(c14-c15))/2)))/2)-abs(((((c8+c9-abs(c8- c9))/2)+((c10+c11-abs(c10-c11))/2)-abs(((c8+c9-abs(c8- c9))/2)-((c10+c11-abs(c10-c11))/2)))/2)-((((c12+c13-abs(c12- c13))/2)+((c14+c15-abs(c14-c15))/2)-abs(((c12+c13-abs(c12- c13))/2)-((c14+c15-abs(c14-c15))/2)))/2)))/2)-abs(((((((c00+c01-abs(c00-c01))/2)+((c02+c3-abs(c02-c3))/2)-abs(((c00+c01-abs(c00-c01))/2)-((c02+c3-abs(c02-c3))/2)))/2)+((((c4+c5-abs(c4- c5))/2)+((c6+c7-abs(c6-c7))/2)-abs(((c4+c5-abs(c4-c5))/2)-((c6+c7-abs(c6-c7))/2)))/2)-abs(((((c00+c01-abs(c00- c01))/2)+((c02+c3-abs(c02-c3))/2)-abs(((c00+c01-abs(c00- c01))/2)-((c02+c3-abs(c02-c3))/2)))/2)-((((c4+c5-abs(c4- c5))/2)+((c6+c7-abs(c6-c7))/2)-abs(((c4+c5-abs(c4- c5))/2)-((c6+c7-abs(c6-c7))/2)))/2)))/2)- ((((((c8+c9-abs(c8-c9))/2)+((c10+c11-abs(c10-c11))/2)-abs(((c8+c9-abs(c8-c9))/2)-((c10+c11-abs(c10-c11))/2)))/2)+((((c12+c13-abs(c12- c13))/2)+((c14+c15-abs(c14-c15))/2)-abs(((c12+c13-abs(c12-c13))/2)-((c14+c15-abs(c14-c15))/2)))/2)-abs(((((c8+c9-abs(c8- c9))/2)+((c10+c11-abs(c10-c11))/2)-abs(((c8+c9-abs(c8- c9))/2)-((c10+c11-abs(c10-c11))/2)))/2)-((((c12+c13-abs(c12- c13))/2)+((c14+c15-abs(c14-c15))/2)-abs(((c12+c13-abs(c12- c13))/2)-((c14+c15-abs(c14-c15))/2)))/2)))/2)))/2)

J
Bruce_L
Posted : Friday, December 24, 2004 12:11:41 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jfh123,
Maybe I'm misunderstanding what's going on, but try this:

MINC16

It seems to produce the same results as your formula. And here's the point.

If you want to produce a general formula to show the Minimum or Maximum value for any Custom Indicator over 16 days, it is certainly possible. It is usually better to optimize the formula based on the specific Custom Indicator (in this case 'C') you are using however.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jfh123
Posted : Friday, December 24, 2004 12:42:52 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Bruce_L)
jfh123,
Maybe I'm misunderstanding what's going on, but try this:

MINC16

It seems to produce the same results as your formula.


It does, but I can't replace the "C16" in "Minc16" with a custom indicator, like "avgc12-avgc26" (macd). I did the simple formula on the close, to ensure I did it properly, then did a "find and replace" in word to insert my custom indicator. So ... maybe I should have asked if you have a shorter PCF which tells me where, within the past 16 days' range, is today's MACD. If we can do that, then I can probably get from there to my custom indicator.
Bruce_L
Posted : Friday, December 24, 2004 12:57:30 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jfh123,
The optimal formula will change based on the specific Custom Indicator, so the optimal solution for MACD, while longer, would probably not be any more usable as a general formula than MINC16. I'll write up a general formula for the minimum value of a Custom Indicator over the last 16 days if Tanstaafl doesn't respond to your request first (since the original request was directed to him specifically).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jfh123
Posted : Friday, December 24, 2004 3:09:35 PM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Bruce_L)
jfh123,
The optimal formula will change based on the specific Custom Indicator, so the optimal solution for MACD, while longer, would probably not be any more usable as a general formula than MINC16. Not sure i understand why, but it'll probably be clearer once I see your formula. I'll write up a general formula for the minimum value of a Custom Indicator over the last 16 days if Tanstaafl doesn't respond to your request first (since the original request was directed to him specifically).

That's exactly what I'm hoping for. Thanks!
Tanstaafl
Posted : Friday, December 24, 2004 3:15:04 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, JFH:

I think that somehow we might have gotten off track, here. I was hoping you would write out the actual logic you wanted from the CI, rather than a "hard way" example of MinC16. However, by looking back to an earlier post in the thread, it appears that you are trying to output an oscillator which expresses where the current OBV value is in comparison to the Min-to-Max range during the last 16 days.

This is actually pretty easy to do, if you get a CLEAR idea of how OBV is calc'd. Long story short, here is the PCF for that oscillator:

100* (OBV-Min(OBV,16)) / (Max(OBV,16) - Min(OBV,16))

In order to explain this (hopefully, clearly and thoroughly), I've written up a full article about OBV and MS PCF-ing, and interpreting their "values". It has not been "vetted" by W, but I'm pretty sure it is correct, as far as it goes.

If you have any further comments or questions about OBV-related stuff, please reply to that new thread, at this URL:
http://www.worden.com/training/default.aspx?g=posts&m=3095&#3095

I hope this helps!

Jim Dean

Bruce_L
Posted : Friday, December 24, 2004 9:26:00 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jfh123,
You can get a 30% reduction in your formula size by pretty much just eliminating some unnecessary parenthesis:

(C+C1-ABS(C-C1)+C2+C3-ABS(C2-C3)-ABS(C+C1-ABS(C-C1)-C2-C3+ABS(C2-C3))+C4+C5-ABS(C4-C5)+C6+C7-ABS(C6-C7)-ABS(C4+C5-ABS(C4-C5)-C6-C7+ABS(C6-C7))-ABS(C+C1-ABS(C-C1)+C2+C3-ABS(C2-C3)-ABS(C+C1-ABS(C-C1)-C2-C3+ABS(C2-C3))-C4-C5+ABS(C4-C5)-C6-C7+ABS(C6-C7)+ABS(C4+C5-ABS(C4-C5)-C6-C7+ABS(C6-C7)))+C8+C9-ABS(C8-C9)+C10+C11-ABS(C10-C11)-ABS(C8+C9-ABS(C8-C9)-C10-C11+ABS(C10-C11))+C12+C13-ABS(C12-C13)+C14+C15-ABS(C14-C15)-ABS(C12+C13-ABS(C12-C13)-C14-C15+ABS(C14-C15))-ABS(C8+C9-ABS(C8-C9)+C10+C11-ABS(C10-C11)-ABS(C8+C9-ABS(C8-C9)-C10-C11+ABS(C10-C11))-C12-C13+ABS(C12-C13)-C14-C15+ABS(C14-C15)+ABS(C12+C13-ABS(C12-C13)-C14-C15+ABS(C14-C15)))-ABS(C+C1-ABS(C-C1)+C2+C3-ABS(C2-C3)-ABS(C+C1-ABS(C-C1)-C2-C3+ABS(C2-C3))+C4+C5-ABS(C4-C5)+C6+C7-ABS(C6-C7)-ABS(C4+C5-ABS(C4-C5)-C6-C7+ABS(C6-C7))-ABS(C+C1-ABS(C-C1)+C2+C3-ABS(C2-C3)-ABS(C+C1-ABS(C-C1)-C2-C3+ABS(C2-C3))-C4-C5+ABS(C4-C5)-C6-C7+ABS(C6-C7)+ABS(C4+C5-ABS(C4-C5)-C6-C7+ABS(C6-C7)))-C8-C9+ABS(C8-C9)-C10-C11+ABS(C10-C11)+ABS(C8+C9-ABS(C8-C9)-C10-C11+ABS(C10-C11))-C12-C13+ABS(C12-C13)-C14-C15+ABS(C14-C15)+ABS(C12+C13-ABS(C12-C13)-C14-C15+ABS(C14-C15))+ABS(C8+C9-ABS(C8-C9)+C10+C11-ABS(C10-C11)-ABS(C8+C9-ABS(C8-C9)-C10-C11+ABS(C10-C11))-C12-C13+ABS(C12-C13)-C14-C15+ABS(C14-C15)+ABS(C12+C13-ABS(C12-C13)-C14-C15+ABS(C14-C15)))))/16

I haven't re-arranged the formula to see if I can combine terms, but unless I'm thinking about this wrong (which is certainly possible), I doubt any significant additional size reduction would result. Since PCFs aren't iterative, it seems like C, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14 & C15 would each have to appear at least fifteen times to make all the required comparisons (and they are only appearing sixteen each now).

Any big reductions in formula size are going to be a result of taking advantage of quirks in your CI that allow you to combine terms or take advantage of a function already built into the PCF language. For example, even ignoring MINC16, you don’t have to look too hard at the formula to figure out 16*AVGC16 could be used to replace sixteen of its terms.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jfh123
Posted : Friday, December 24, 2004 9:38:14 PM
Registered User
Joined: 12/17/2004
Posts: 143
Bruce,

Thanks for the reduction! I agree it's not going to get much simpler, and don't think (though I could be wrong; I've certainly learned a lot using this discussion board in the past few days) I can apply the avgc16 concept to a macd-type CI. But, I will think about it. Thanks!
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.