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 |

Wide range days and narrow range days -- PCFs Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
rdhtci
Posted : Monday, July 30, 2007 12:26:03 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
Hi,

I would like to create a PCF to return the widest daily range in the last X days

Also, the narrowest daily range in the last X days

Where range = high minus low

I've tried using MAX in conjunction with H-L but this is clearly returning the highest high minus the highest low. And MAX will not seem to accept further brackets to control the calculation order.

Thanks,

Bob
Bruce_L
Posted : Monday, July 30, 2007 12:43:42 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The only way I can think of to do this using TeleChart would be the technique described in Min Max PCFs. An example formula for the last 8 days would be:

Minimum Range for Last 8-Periods:

(H - L + H1 - L1 - ABS(H - L - H1 + L1) + H2 - L2 + H3 - L3 - ABS(H2 - L2 - H3 + L3) - ABS(H - L + H1 - L1 - ABS(H - L - H1 + L1) - H2 + L2 - H3 + L3 + ABS(H2 - L2 - H3 + L3)) + H4 - L4 + H5 - L5 - ABS(H4 - L4 - H5 + L5) + H6 - L6 + H7 - L7 - ABS(H6 - L6 - H7 + L7) - ABS(H4 - L4 + H5 - L5 - ABS(H4 - L4 - H5 + L5) - H6 + L6 - H7 + L7 + ABS(H6 - L6 - H7 + L7)) - ABS(H - L + H1 - L1 - ABS(H - L - H1 + L1) + H2 - L2 + H3 - L3 - ABS(H2 - L2 - H3 + L3) - ABS(H - L + H1 - L1 - ABS(H - L - H1 + L1) - H2 + L2 - H3 + L3 + ABS(H2 - L2 - H3 + L3)) - H4 + L4 - H5 + L5 + ABS(H4 - L4 - H5 + L5) - H6 + L6 - H7 + L7 + ABS(H6 - L6 - H7 + L7) + ABS(H4 - L4 + H5 - L5 - ABS(H4 - L4 - H5 + L5) - H6 + L6 - H7 + L7 + ABS(H6 - L6 - H7 + L7)))) / 8

Maximum Range for Last 8-Periods:

(H - L + H1 - L1 + ABS(H - L - H1 + L1) + H2 - L2 + H3 - L3 + ABS(H2 - L2 - H3 + L3) + ABS(H - L + H1 - L1 + ABS(H - L - H1 + L1) - H2 + L2 - H3 + L3 - ABS(H2 - L2 - H3 + L3)) + H4 - L4 + H5 - L5 + ABS(H4 - L4 - H5 + L5) + H6 - L6 + H7 - L7 + ABS(H6 - L6 - H7 + L7) + ABS(H4 - L4 + H5 - L5 + ABS(H4 - L4 - H5 + L5) - H6 + L6 - H7 + L7 - ABS(H6 - L6 - H7 + L7)) + ABS(H - L + H1 - L1 + ABS(H - L - H1 + L1) + H2 - L2 + H3 - L3 + ABS(H2 - L2 - H3 + L3) + ABS(H - L + H1 - L1 + ABS(H - L - H1 + L1) - H2 + L2 - H3 + L3 - ABS(H2 - L2 - H3 + L3)) - H4 + L4 - H5 + L5 - ABS(H4 - L4 - H5 + L5) - H6 + L6 - H7 + L7 - ABS(H6 - L6 - H7 + L7) - ABS(H4 - L4 + H5 - L5 + ABS(H4 - L4 - H5 + L5) - H6 + L6 - H7 + L7 - ABS(H6 - L6 - H7 + L7)))) / 8

I do not see this method as practical beyond 32-Periods. It is fairly simple to do this using Blocks. You may wish to review the following:

How to create a Personal Criteria Forumula (PCF)
Handy PCF example formulas to help you learn the syntax of PCFs!
PCF Formula Descriptions

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rdhtci
Posted : Monday, July 30, 2007 12:48:49 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
Thanks, Bruce.

Could you enlarge on how to do this in Blocks?

Thnks,

Bob
Bruce_L
Posted : Monday, July 30, 2007 1:34:36 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You would:

- Run a Price Block into Bar High and Bar Low Blocks.
- Run the Bar High and Bar Low Blocks into a Difference Block.
- Run the Difference Block through either a Maximum or Minimum Block.
- Set the Period for the Maximum or Minimum Block to the desired value.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rdhtci
Posted : Monday, July 30, 2007 1:41:55 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
Thanks Bruce,

I'm not far enough along with Blocks to immdiately understand how to do that, I'll come back to it.

In the meantime, I am confused ref the implementation of your instructions at the 'Min Max PCFs' thread --
the instruction says:
Replace All PCF1 with ......
Replace All PCF2 with ......


Taking the first block:

(PCF1 + PCF2 - ABS(PCF1 - (PCF2))

in my range calcuation which you did above, you replace 'PCF1' with 'H - L' and you replace 'PCF2' with 'H1 - L1'

your implementation shows:

(H - L + H1 - L1 - ABS(H - L - H1 + L1 )

what puzzles me is that the first instance of 'PCF2' was replaced with 'H1 - L1' (note MINUS) but the second instance of 'PCF2' was replaced with 'H1 + L1' (note PLUS)

Does the fact that the second instance of PF2 is enclosed in brackets imply that the value is reversed?

Thanks,

Bob
Bruce_L
Posted : Monday, July 30, 2007 1:57:49 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I apologize for any confusion. The difference is the result of simplifying the formula beyond what was presented in the referenced topic. Using 2-Period Minimum and Maximum formulas as examples:

(H - L + H1 - L1 - ABS(H - L - (H1 - L1))) / 2

Produces the same results as:

(H - L + H1 - L1 - ABS(H - L - H1 + L1)) / 2

And:

(H - L + H1 - L1 + ABS(H - L - (H1 - L1))) / 2

Produces the same results as:

(H - L + H1 - L1 + ABS(H - L - H1 + L1)) / 2

As you've already noted, this is a result of the interaction of the parentheses with subtraction. It is generally easier for most users to create the first formula (with the extra parentheses) than the second. The first version can be done directly with the replace function of a text editor. The second cannot (at least not with the templates provided).

Using the exact technique presented in Min Max PCFs, the 8-Period formulas would be only slightly longer than what was originally presented:

Minimum Range for Last 8-Periods:

(H - L + H1 - L1 - ABS(H - L - (H1 - L1)) + H2 - L2 + H3 - L3 - ABS(H2 - L2 - (H3 - L3)) - ABS(H - L + H1 - L1 - ABS(H - L - (H1 - L1)) - (H2 - L2) - (H3 - L3) + ABS(H2 - L2 - (H3 - L3))) + H4 - L4 + H5 - L5 - ABS(H4 - L4 - (H5 - L5)) + H6 - L6 + H7 - L7 - ABS(H6 - L6 - (H7 - L7)) - ABS(H4 - L4 + H5 - L5 - ABS(H4 - L4 - (H5 - L5)) - (H6 - L6) - (H7 - L7) + ABS(H6 - L6 - (H7 - L7))) - ABS(H - L + H1 - L1 - ABS(H - L - (H1 - L1)) + H2 - L2 + H3 - L3 - ABS(H2 - L2 - (H3 - L3)) - ABS(H - L + H1 - L1 - ABS(H - L - (H1 - L1)) - (H2 - L2) - (H3 - L3) + ABS(H2 - L2 - (H3 - L3))) - (H4 - L4) - (H5 - L5) + ABS(H4 - L4 - (H5 - L5)) - (H6 - L6) - (H7 - L7) + ABS(H6 - L6 - (H7 - L7)) + ABS(H4 - L4 + H5 - L5 - ABS(H4 - L4 - (H5 - L5)) - (H6 - L6) - (H7 - L7) + ABS(H6 - L6 - (H7 - L7))))) / 8

Maximum Range for Last 8-Periods:

(H - L + H1 - L1 + ABS(H - L - (H1 - L1)) + H2 - L2 + H3 - L3 + ABS(H2 - L2 - (H3 - L3)) + ABS(H - L + H1 - L1 + ABS(H - L - (H1 - L1)) - (H2 - L2) - (H3 - L3) - ABS(H2 - L2 - (H3 - L3))) + H4 - L4 + H5 - L5 + ABS(H4 - L4 - (H5 - L5)) + H6 - L6 + H7 - L7 + ABS(H6 - L6 - (H7 - L7)) + ABS(H4 - L4 + H5 - L5 + ABS(H4 - L4 - (H5 - L5)) - (H6 - L6) - (H7 - L7) - ABS(H6 - L6 - (H7 - L7))) + ABS(H - L + H1 - L1 + ABS(H - L - (H1 - L1)) + H2 - L2 + H3 - L3 + ABS(H2 - L2 - (H3 - L3)) + ABS(H - L + H1 - L1 + ABS(H - L - (H1 - L1)) - (H2 - L2) - (H3 - L3) - ABS(H2 - L2 - (H3 - L3))) - (H4 - L4) - (H5 - L5) - ABS(H4 - L4 - (H5 - L5)) - (H6 - L6) - (H7 - L7) - ABS(H6 - L6 - (H7 - L7)) - ABS(H4 - L4 + H5 - L5 + ABS(H4 - L4 - (H5 - L5)) - (H6 - L6) - (H7 - L7) - ABS(H6 - L6 - (H7 - L7))))) / 8

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rdhtci
Posted : Monday, July 30, 2007 3:03:33 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
Thanks, Bruce, that clarifies it perfectly.

Bob
Bruce_L
Posted : Monday, July 30, 2007 3:37:43 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rdhtci
Posted : Tuesday, July 31, 2007 4:50:44 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
Hi,

I have a problem with running this in an EasyScan.

Using your formula below for
'Maximum Range for Last 8-Periods', I added '(H - L)>=' to the front to make the condition true where today's range is greater than or equal to the largest range of the last 8 days. Like this:

-----------------

(H - L)>=(H - L + H1 - L1 + ABS(H - L - H1 + L1 ) + H2 - L2 + H3 - L3 + ABS(H2 - L2 - H3 + L3 ) + ABS(H - L + H1 - L1 + ABS(H - L - H1 + L1 ) - H2 + L2 - H3 + L3 - ABS(H2 - L2 - H3 + L3 )) + H4 - L4 + H5 - L5 + ABS(H4 - L4 - H5 + L5 ) + H6 - L6 + H7 - L7 + ABS(H6 - L6 - H7 + L7 ) + ABS(H4 - L4 + H5 - L5 + ABS(H4 - L4 - H5 + L5 ) - H6 + L6 - H7 + L7 - ABS(H6 - L6 - H7 + L7 )) + ABS(H - L + H1 - L1 + ABS(H - L - H1 + L1 ) + H2 - L2 + H3 - L3 + ABS(H2 - L2 - H3 + L3 ) + ABS(H - L + H1 - L1 + ABS(H - L - H1 + L1 ) - H2 + L2 - H3 + L3 - ABS(H2 - L2 - H3 + L3 )) - H4 + L4 - H5 + L5 - ABS(H4 - L4 - H5 + L5 ) - H6 + L6 - H7 + L7 - ABS(H6 - L6 - H7 + L7 ) - ABS(H4 - L4 + H5 - L5 + ABS(H4 - L4 - H5 + L5 ) - H6 + L6 - H7 + L7 - ABS(H6 - L6 - H7 + L7 )))) / 8

--------------

The problem is, this is returning items where the condition was true yesterday, instead of today.

I am running this in TeleChart Platinum, and the top bar is showing "Streaming Real Time"

Looking for a solution...
Thanks,

Bob
Craig_S
Posted : Tuesday, July 31, 2007 4:53:19 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
You have to UPDATE and then calculate your PCFs. The PCFs are run on your downloaded data, not the streaming data.

- Craig
Here to Help!
rdhtci
Posted : Tuesday, July 31, 2007 4:54:07 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
...PS ...this is still happening after the market close, after I have closed and re-opened TC so that today should be the last day in the database.

The criteria are still being evaluated on yesterday

Bob
Bruce_L
Posted : Tuesday, July 31, 2007 4:55:02 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Personal Criteria Formulas and EasyScans are based on Daily Data. You will need to do a delayed update by selecting Databank | Update via Internet | Update with Update Personal Criteria following download checked.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rdhtci
Posted : Tuesday, July 31, 2007 4:58:13 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
Craig,

Thanks for the help, but the update was down when I closed and re-opened as above -- I have also updated manually again to be certain, but it is visually obvious that the day matching the criteria was yesterday...

Thanks

Bob
rdhtci
Posted : Tuesday, July 31, 2007 4:59:09 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
should read 'update was done...'
rdhtci
Posted : Tuesday, July 31, 2007 5:05:38 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
OK, I've updated again and it is running properly.

Thanks, Craig and Bruce, for the help.

Bob
rdhtci
Posted : Tuesday, July 31, 2007 5:06:35 PM
Gold Customer Gold Customer

Joined: 7/23/2007
Posts: 20
PS -- you guys do a great job...
Bruce_L
Posted : Tuesday, July 31, 2007 5:08:23 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
rdhtci,
You're welcome. Our pleasure. I'm happy to read it is working correctly for you now.

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