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 |

Help with writing a scan Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
barrycoe
Posted : Thursday, December 9, 2004 2:20:14 PM
Registered User
Joined: 12/9/2004
Posts: 4
I would appreciate your help in writing a scan.
Here are the parameters: Using the Bollinger Bands and Keltner Channels.
I would like to have a scan that will return a hit when the Bollinger Bands (BB) go INSIDE the Keltner Channel.

The Bollinger Bands, Keltner Channel and time frame would be user definable.

Thank you for your help.

Barry Coe
Doug_H
Posted : Thursday, December 9, 2004 11:25:40 PM


Worden Trainer

Joined: 10/1/2004
Posts: 4,308
barrycoe:

Keltner Channels are not included on TeleChart's list of indicators. However, I've done some research (I had never heard of them before), and I've figured out how to plot them. I'm still working on a way to identify stocks where the Bollinger Bands go inside the Keltner Channel.

I'll get back to you with the formula and (I hope) some help with identifying relationships between the channels and bands.

- Doug
Teaching Online!
Doug_H
Posted : Thursday, December 9, 2004 11:56:11 PM


Worden Trainer

Joined: 10/1/2004
Posts: 4,308
Because I don't know much about the formula behind Bollinger Bands, I'm running into a roadblock trying to find a way to find stocks where the BB's drop inside the Keltner Channels. So...for now, let me give you the information about how I plotted the Keltner Channels, and perhaps someone more knowledgeable than I can help put the rest of the puzzle together for you.

To plot the Keltner Channel, add a Custom Channel Indicator to the Price window. Use the following formulas:

Indicator Line Formula
((C+H+L)/3 + (C1+H1+L1)/3 + (C2+H2+L2)/3 + (C3+H3+L3)/3 + (C4+H4+L4)/3 + (C5+H5+L5)/3 + (C6+H6+L6)/3 + (C7+H7+L7)/3 + (C8+H8+L8)/3 + (C9+H9+L9)/3) / 10

Channel Width Formula
AVGH10 - AVGL10

To get the value that matches the actual calculation for each line, make sure to set your Width Multiplier to 10.

These formulas, as you can probably figure out, use a period of ten days. They could be expanded or altered to cover a larger period.

Anyone out there care to provide some help identifying when the top Bollinger Band crosses down through the top Keltner Channel Line, or when the
bottom BB crosses up through the lower Keltner Channel Line?


- Doug
Teaching Online!
Bruce_L
Posted : Friday, December 10, 2004 12:24:37 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Try this:

((AVGC10 + SQR(((C - AVGC10) ^ 2 + (C1 - AVGC10) ^ 2 + (C2 - AVGC10) ^ 2 + (C3 - AVGC10) ^ 2 + (C4 - AVGC10) ^ 2 + (C5 - AVGC10) ^ 2 + (C6 - AVGC10) ^ 2 + (C7 - AVGC10) ^ 2 + (C8 - AVGC10) ^ 2 + (C9 - AVGC10) ^ 2) / 9)) < (((AVGC10 + AVGH10 + AVGL10) / 3) + (AVGH10 - AVGL10)) AND (AVGC10.1 + SQR(((C1 - AVGC10.1) ^ 2 + (C2 - AVGC10.1) ^ 2 + (C3 - AVGC10.1) ^ 2 + (C4 - AVGC10.1) ^ 2 + (C5 - AVGC10.1) ^ 2 + (C6 - AVGC10.1) ^ 2 + (C7 - AVGC10.1) ^ 2 + (C8 - AVGC10.1) ^ 2 + (C9 - AVGC10.1) ^ 2 + (C10 - AVGC10.1) ^ 2) / 9)) >= (((AVGC10.1 + AVGH10.1 + AVGL10.1) / 3) + (AVGH10.1 - AVGL10.1))) OR ((AVGC10 - SQR(((C - AVGC10) ^ 2 + (C1 - AVGC10) ^ 2 + (C2 - AVGC10) ^ 2 + (C3 - AVGC10) ^ 2 + (C4 - AVGC10) ^ 2 + (C5 - AVGC10) ^ 2 + (C6 - AVGC10) ^ 2 + (C7 - AVGC10) ^ 2 + (C8 - AVGC10) ^ 2 + (C9 - AVGC10) ^ 2) / 9)) > (((AVGC10 + AVGH10 + AVGL10) / 3) - (AVGH10 - AVGL10)) AND (AVGC10.1 - SQR(((C1 - AVGC10.1) ^ 2 + (C2 - AVGC10.1) ^ 2 + (C3 - AVGC10.1) ^ 2 + (C4 - AVGC10.1) ^ 2 + (C5 - AVGC10.1) ^ 2 + (C6 - AVGC10.1) ^ 2 + (C7 - AVGC10.1) ^ 2 + (C8 - AVGC10.1) ^ 2 + (C9 - AVGC10.1) ^ 2 + (C10 - AVGC10.1) ^ 2) / 9)) <= (((AVGC10.1 + AVGH10.1 + AVGL10.1) / 3) - (AVGH10.1 - AVGL10.1)))

The PCF will return True if either the Upper or Lower Bollinger Band was outside the Keltner Channel yesterday, but matches or is inside today. The Period and Channel Width for both Bollinger Bands and Keltner Channels are set to 10 each.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Doug_H
Posted : Friday, December 10, 2004 12:35:32 PM


Worden Trainer

Joined: 10/1/2004
Posts: 4,308
barrycoe:

Bruce and I emailed a few times about a solution to your request. Bruce is a PCF whiz...and he came up with this one, which is likely to do what you're looking for.

Let us know if this works for you!

- Doug
Teaching Online!
Doug_H
Posted : Friday, December 10, 2004 1:15:31 PM


Worden Trainer

Joined: 10/1/2004
Posts: 4,308
Barry:

The information you emailed me was hard to read because of resolution, however, it looked like it was the very site I had gone to to get my calculation.

You can plot the channels using my instructions above. You can also try Bruce's formula above to find the BB interaction you were looking for.

You can probably reach me more directly through these forums rather than through the support email system. You can post links here as well. I'm on the forums regularly, and I get an email notification when a new post is made.

- Doug
Teaching Online!
barrycoe
Posted : Friday, December 10, 2004 3:48:31 PM
Registered User
Joined: 12/9/2004
Posts: 4
Thank you both, Doug and Bruce. I will give this a try and let you know the results. Your services are fantastic, and again, thanks.

Barry Coe
Doug_H
Posted : Friday, December 10, 2004 4:19:45 PM


Worden Trainer

Joined: 10/1/2004
Posts: 4,308
You're welcome, Barry. I hope it all works like you were hoping!

- Doug
Teaching Online!
Tanstaafl
Posted : Friday, December 10, 2004 11:51:16 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, guys:

There is a tighter, more efficient PCF formula for the Bollinger Bands which I recommend you use instead of the one that Bruce posted. It is 100% mathematically correct. It avoids the use of the "^" operator which is not very reliable in the current release of TC. And it is easier to understand and modify for other input parameters.

General Bollinger Band formula
BB(Pds,SDs)= SMA(Pds) +/- SDs*StdDev
Add/Subtract the final term to get Top/Bot BB
Middle BB line = SMA(Pds)

Standard Deviation PCF (precisely matches TC plot)
SQR( ( ( C*C + C1*C1 + ...+ Cn*Cn )
- ( p * AvgCp * AvgCp ) ) / n )
where p = SMAPds and n = Pds-1

Example: Pds = 10 days, 2x SD Top BB
TC requires 2x to be input as "20"

BB(10,2) = AvgC10 + 2 * SQR((( C*C +C1*C1
+C2*C2 +C3*C3 +C4*C4 +C5*C5 +C6*C6
+C7*C7 +C8*C8 +C9*C9 ) - ( 10 * AvgC10 *
AvgC10 ) ) / 9 )

Example: Pds = 20 days, 1x SD Bot BB
TC requires 1x to be input as "10"

BB(20,1) = AvgC20 - 1 * SQR((( C*C +C1*C1
+C2*C2 +C3*C3 +C4*C4 +C5*C5 +C6*C6
+C7*C7 +C8*C8 +C9*C9 +C10*C10
+C11*C11 +C12*C12 +C13*C13 +C14*C14
+C15*C15 +C16*C16 +C17*C17 +C18*C18
+C19*C19 ) - ( 20 * AvgC20*AvgC20 ) ) / 19 )

Of course you can substitute any valid TC price or function in place of the root "C" (such as RSI or TSV or whatever) ... and the equation can be expanded to include more complex "roots"

I hope this helps. I'll post a second reply re Keltner channels.



Tanstaafl
Posted : Saturday, December 11, 2004 12:02:55 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Re Keltner channels.

There is not a universal agreement on how these are calculated. I'll discuss the original version ... but others (such as Rashke's EMA + ATR variant) are also possible in PCF's. Do a Google on it and you will find a wealth of info.

------ From the ArbTrading.com site: ---------

Construction of Keltner Channels is simple. You have a mid band based on the average of the high, low and closing price with a band on each side formed from the 10 moving average of the daily high minus the daily low. This would be represented as:

Average Price = (C+H+L)/3
Band Moving Average = 10 Day Simple Moving Average (SMA)
of (High – Low)
Middle Moving Average = 10 Day SMA of AP
Upper Band = Middle Moving Average + Band MA
Lower Band = Middle Moving Average – Band MA

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

In PCF-eze, the middle-band 10-day Simple Moving Average of the (H+L+C)/3 price (actually this calc is generally referred to as the "Typical" price):
(AvgH10+AvgL10+AvgC10)/3

The envelope width is the simple MA of the High-Low range, or:
(AvgH10-AvgL10)

You can choose to multiply this envelope by whatever width you wish. I'll use a 2x multiplier below, for illustration.

So, the Keltner upper band is:
(AvgH10+AvgL10+AvgC10)/3 + 2*(AvgH10-AvgL10)

And the Keltner lower band is:
(AvgH10+AvgL10+AvgC10)/3 - 2*(AvgH10-AvgL10)

These can be simplified to:
Upper Keltner = 7/3*AvgH10 - 5/3*AvgL10 + AvgC10/3
Upper Keltner = 7/3*AvgL10 - 5/3*AvgH10 + AvgC10/3

The formulae for the EMA-based centerline with an ATR-based width is also PCF-able, but is probably not what was originally being requested, so I'll save that answer till another time.


Tanstaafl
Posted : Saturday, December 11, 2004 12:46:35 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Oops my prior post had a small error. The last formula provided is for the LOWER Keltner, not the upper.

Moving on with it ...

Barry requested a Scan that identifies when the Keltner channels go Inside the BB's (without specifying parameters). I presume that means he wants a T/F PCF that can be used in an EasyScan (or in a WL tab column).

This is pretty easy to do, using the BB and KC formulae presented in the prior two postings. But the PCF is sorta long.

Let's presume, to keep the PCF short, that the KC is a 5-day, 1x width, and that the BB is a 10-day, 2x width. Barry wanted replaceable param's ... the prior formulae make it pretty clear, I think, how to adapt this.

The logic is:

Today's KC is totally inside today's BB
and
Yesterday's KC is NOT totally inside yesterday's BB

more specifically:

KCupper0 < BBupper0 and KClower0 > BBlower0
and
(KCupper1 >= BBupper1 or KClower1 <= BBlower1)

where:

KCupper0 = 7/3*AvgH10 - 5/3*AvgL10 + AvgC10/3
KClower0 = 7/3*AvgL10 - 5/3*AvgH10 + AvgC10/3

KCupper1 = 7/3*AvgH10.1 - 5/3*AvgL10.1 + AvgC10.1/3
KClower1 = 7/3*AvgL10.1 - 5/3*AvgH10.1 + AvgC10.1/3

BBupper0 = AvgC10 + 2 * SQR((( C*C +C1*C1
+C2*C2 +C3*C3 +C4*C4 +C5*C5 +C6*C6
+C7*C7 +C8*C8 +C9*C9 ) - ( 10 * AvgC10 *
AvgC10 ) ) / 9 )
BBlower0 = AvgC10 - 2 * SQR((( C*C +C1*C1
+C2*C2 +C3*C3 +C4*C4 +C5*C5 +C6*C6
+C7*C7 +C8*C8 +C9*C9 ) - ( 10 * AvgC10 *
AvgC10 ) ) / 9 )

BBupper1 = AvgC10.1 + 2 * SQR((( C1*C1
+C2*C2 +C3*C3 +C4*C4 +C5*C5 +C6*C6
+C7*C7 +C8*C8 +C9*C9 +C10*C10) - ( 10 *
AvgC10.1 * AvgC10.1 ) ) / 9 )
BBlower1 = AvgC10.1 - 2 * SQR((( C1*C1
+C2*C2 +C3*C3 +C4*C4 +C5*C5 +C6*C6
+C7*C7 +C8*C8 +C9*C9 +C10*C10) - ( 10 *
AvgC10.1 * AvgC10.1 ) ) / 9 )

I'll leave it to you, Barry, to plug and chug
:D

barrycoe
Posted : Monday, December 13, 2004 3:43:14 PM
Registered User
Joined: 12/9/2004
Posts: 4
Tanstaafl, that is terrific, thank you very much.

I am still in 101. How do I tie this all together for a scan. I imagine it has to be broken up into several steps but I just don't know (yet) what those steps are and would appreciate your help if possible.

Barry
barrycoe
Posted : Wednesday, December 15, 2004 9:50:30 PM
Registered User
Joined: 12/9/2004
Posts: 4
To: Tanstaafl

Hello Jim,

Any chance I could get some help from you on this. Please let me know if I can contact you.





Thanks,

Barry Coe

ksoong
Posted : Monday, July 17, 2006 1:52:46 AM
Registered User
Joined: 4/3/2006
Posts: 44
How do you write:
1. a PCF that returns True if either the Upper or Lower Bollinger Band was outside the Keltner Channel yesterday, but is inside today
2. a PCF that returns True if either the Upper or Lower Bollinger Band was inside the Keltner Channel yesterday, but is outside today


setting: BB (20,15) and Keltner Channels (20,20)

thanks in advance
Craig_S
Posted : Monday, July 17, 2006 10:12:13 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Are your bollinger bands simple or exponential?

- Craig
Here to Help!
ksoong
Posted : Monday, July 17, 2006 11:36:32 AM
Registered User
Joined: 4/3/2006
Posts: 44
simple. thanks
Bruce_L
Posted : Monday, July 17, 2006 12:13:15 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The following is based on TTM Squeeze Indicator:

QUOTE (ksoong)
a PCF that returns True if either the Upper or Lower Bollinger Band was outside the Keltner Channel yesterday, but is inside today

SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 20) * 4 / 3 / ((AVGH20 - AVGL20) / 2 + (ABS(H - C1) + ABS(L - C1) + ABS(H1 - C2) + ABS(L1 - C2) + ABS(H2 - C3) + ABS(L2 - C3) + ABS(H3 - C4) + ABS(L3 - C4) + ABS(H4 - C5) + ABS(L4 - C5) + ABS(H5 - C6) + ABS(L5 - C6) + ABS(H6 - C7) + ABS(L6 - C7) + ABS(H7 - C8) + ABS(L7 - C8) + ABS(H8 - C9) + ABS(L8 - C9) + ABS(H9 - C10) + ABS(L9 - C10) + ABS(H10 - C11) + ABS(L10 - C11) + ABS(H11 - C12) + ABS(L11 - C12) + ABS(H12 - C13) + ABS(L12 - C13) + ABS(H13 - C14) + ABS(L13 - C14) + ABS(H14 - C15) + ABS(L14 - C15) + ABS(H15 - C16) + ABS(L15 - C16) + ABS(H16 - C17) + ABS(L16 - C17) + ABS(H17 - C18) + ABS(L17 - C18) + ABS(H18 - C19) + ABS(L18 - C19) + ABS(H19 - C20) + ABS(L19 - C20)) / 40 + .000001) < 1 AND SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20) * 4 / 3 / ((AVGH20.1 - AVGL20.1) / 2 + (ABS(H1 - C2) + ABS(L1 - C2) + ABS(H2 - C3) + ABS(L2 - C3) + ABS(H3 - C4) + ABS(L3 - C4) + ABS(H4 - C5) + ABS(L4 - C5) + ABS(H5 - C6) + ABS(L5 - C6) + ABS(H6 - C7) + ABS(L6 - C7) + ABS(H7 - C8) + ABS(L7 - C8) + ABS(H8 - C9) + ABS(L8 - C9) + ABS(H9 - C10) + ABS(L9 - C10) + ABS(H10 - C11) + ABS(L10 - C11) + ABS(H11 - C12) + ABS(L11 - C12) + ABS(H12 - C13) + ABS(L12 - C13) + ABS(H13 - C14) + ABS(L13 - C14) + ABS(H14 - C15) + ABS(L14 - C15) + ABS(H15 - C16) + ABS(L15 - C16) + ABS(H16 - C17) + ABS(L16 - C17) + ABS(H17 - C18) + ABS(L17 - C18) + ABS(H18 - C19) + ABS(L18 - C19) + ABS(H19 - C20) + ABS(L19 - C20) + ABS(H20 - C21) + ABS(L20 - C21)) / 40 + .000001) > 1

QUOTE (ksoong)
a PCF that returns True if either the Upper or Lower Bollinger Band was inside the Keltner Channel yesterday, but is outside today

SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 20) * 4 / 3 / ((AVGH20 - AVGL20) / 2 + (ABS(H - C1) + ABS(L - C1) + ABS(H1 - C2) + ABS(L1 - C2) + ABS(H2 - C3) + ABS(L2 - C3) + ABS(H3 - C4) + ABS(L3 - C4) + ABS(H4 - C5) + ABS(L4 - C5) + ABS(H5 - C6) + ABS(L5 - C6) + ABS(H6 - C7) + ABS(L6 - C7) + ABS(H7 - C8) + ABS(L7 - C8) + ABS(H8 - C9) + ABS(L8 - C9) + ABS(H9 - C10) + ABS(L9 - C10) + ABS(H10 - C11) + ABS(L10 - C11) + ABS(H11 - C12) + ABS(L11 - C12) + ABS(H12 - C13) + ABS(L12 - C13) + ABS(H13 - C14) + ABS(L13 - C14) + ABS(H14 - C15) + ABS(L14 - C15) + ABS(H15 - C16) + ABS(L15 - C16) + ABS(H16 - C17) + ABS(L16 - C17) + ABS(H17 - C18) + ABS(L17 - C18) + ABS(H18 - C19) + ABS(L18 - C19) + ABS(H19 - C20) + ABS(L19 - C20)) / 40 + .000001) > 1 AND SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20) * 4 / 3 / ((AVGH20.1 - AVGL20.1) / 2 + (ABS(H1 - C2) + ABS(L1 - C2) + ABS(H2 - C3) + ABS(L2 - C3) + ABS(H3 - C4) + ABS(L3 - C4) + ABS(H4 - C5) + ABS(L4 - C5) + ABS(H5 - C6) + ABS(L5 - C6) + ABS(H6 - C7) + ABS(L6 - C7) + ABS(H7 - C8) + ABS(L7 - C8) + ABS(H8 - C9) + ABS(L8 - C9) + ABS(H9 - C10) + ABS(L9 - C10) + ABS(H10 - C11) + ABS(L10 - C11) + ABS(H11 - C12) + ABS(L11 - C12) + ABS(H12 - C13) + ABS(L12 - C13) + ABS(H13 - C14) + ABS(L13 - C14) + ABS(H14 - C15) + ABS(L14 - C15) + ABS(H15 - C16) + ABS(L15 - C16) + ABS(H16 - C17) + ABS(L16 - C17) + ABS(H17 - C18) + ABS(L17 - C18) + ABS(H18 - C19) + ABS(L18 - C19) + ABS(H19 - C20) + ABS(L19 - C20) + ABS(H20 - C21) + ABS(L20 - C21)) / 40 + .000001) < 1

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bustermu
Posted : Monday, July 17, 2006 2:08:59 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (Craig_S)
Are your bollinger bands simple or exponential?


Craig,

Will you please tell us what you mean by exponential Bollinger Bands?

Can you lead us to a reference for them?

Thanks,
Jim Murphy
Craig_S
Posted : Monday, July 17, 2006 2:20:40 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
I was thinking of envelope channels. I have no reference, it was a mistake on my part.

- Craig
Here to Help!
bustermu
Posted : Monday, July 17, 2006 2:47:46 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
Thanks,
Jim Murphy
ksoong
Posted : Monday, July 17, 2006 3:15:34 PM
Registered User
Joined: 4/3/2006
Posts: 44
Thanks Bruce, you're the man among men... though there is a little problem
QUOTE (Bruce_L)


QUOTE (ksoong)
a PCF that returns True if either the Upper or Lower Bollinger Band was outside the Keltner Channel yesterday, but is inside today

SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 20) * 4 / 3 / ((AVGH20 - AVGL20) / 2 + (ABS(H - C1) + ABS(L - C1) + ABS(H1 - C2) + ABS(L1 - C2) + ABS(H2 - C3) + ABS(L2 - C3) + ABS(H3 - C4) + ABS(L3 - C4) + ABS(H4 - C5) + ABS(L4 - C5) + ABS(H5 - C6) + ABS(L5 - C6) + ABS(H6 - C7) + ABS(L6 - C7) + ABS(H7 - C8) + ABS(L7 - C8) + ABS(H8 - C9) + ABS(L8 - C9) + ABS(H9 - C10) + ABS(L9 - C10) + ABS(H10 - C11) + ABS(L10 - C11) + ABS(H11 - C12) + ABS(L11 - C12) + ABS(H12 - C13) + ABS(L12 - C13) + ABS(H13 - C14) + ABS(L13 - C14) + ABS(H14 - C15) + ABS(L14 - C15) + ABS(H15 - C16) + ABS(L15 - C16) + ABS(H16 - C17) + ABS(L16 - C17) + ABS(H17 - C18) + ABS(L17 - C18) + ABS(H18 - C19) + ABS(L18 - C19) + ABS(H19 - C20) + ABS(L19 - C20)) / 40 + .000001) &lt; 1 AND SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20) * 4 / 3 / ((AVGH20.1 - AVGL20.1) / 2 + ABS(H1 - C2) + ABS(L1 - C2) + ABS(H2 - C3) + ABS(L2 - C3) + ABS(H3 - C4) + ABS(L3 - C4) + ABS(H4 - C5) + ABS(L4 - C5) + ABS(H5 - C6) + ABS(L5 - C6) + ABS(H6 - C7) + ABS(L6 - C7) + ABS(H7 - C8) + ABS(L7 - C8) + ABS(H8 - C9) + ABS(L8 - C9) + ABS(H9 - C10) + ABS(L9 - C10) + ABS(H10 - C11) + ABS(L10 - C11) + ABS(H11 - C12) + ABS(L11 - C12) + ABS(H12 - C13) + ABS(L12 - C13) + ABS(H13 - C14) + ABS(L13 - C14) + ABS(H14 - C15) + ABS(L14 - C15) + ABS(H15 - C16) + ABS(L15 - C16) + ABS(H16 - C17) + ABS(L16 - C17) + ABS(H17 - C18) + ABS(L17 - C18) + ABS(H18 - C19) + ABS(L18 - C19) + ABS(H19 - C20) + ABS(L19 - C20) + (ABS(H20 - C11) + ABS(L20 - C21)) / 40 + .000001) &gt; 1



I didn't get any %True on the daily SPY plot. This is weird.

By the way, to make life easy, I only need signal from the "Upper" BB Band. That is:
1. a PCF that returns True if the Upper Bollinger Band was outside the Keltner Channel yesterday, but is inside today
2. a PCF that returns True if the Upper Bollinger Band was inside the Keltner Channel yesterday, but is outside today

Thanks again.



Bruce_L
Posted : Monday, July 17, 2006 4:36:45 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
As has already been indicated in this thread, there is no universal agreement on how Keltner bands are calculated. The formulas supplied were based on the discussions in TTM Squeeze Indicator. This was done in part because the supplied settings matched those in that topic (and I thought this might be more than coincidence). These appear to be standard settings used in a third party program and the formula is designed to match these external results.

In any case, if you wish to match the results of my Friday, December 10, 2004 post, you may wish to try the following instead:

QUOTE (ksoong)
a PCF that returns True if either the Upper or Lower Bollinger Band was outside the Keltner Channel yesterday, but is inside today

(AVGC20 + 1.5 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 19) < (AVGC20 + AVGH20 + AVGL20) / 3 + 2 * (AVGH20 - AVGL20) AND AVGC20.1 + 1.5 * SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 19) >= (AVGC20.1 + AVGH20.1 + AVGL20.1) / 3 + 2 * (AVGH20.1 - AVGL20.1)) OR (AVGC20 - 1.5 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 19) > (AVGC20 + AVGH20 + AVGL20) / 3 - 2 * (AVGH20 - AVGL20) AND AVGC20.1 - 1.5 * SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 19) <= (AVGC20.1 + AVGH20.1 + AVGL20.1) / 3 - 2 * (AVGH20.1 - AVGL20.1))

QUOTE (ksoong)
a PCF that returns True if either the Upper or Lower Bollinger Band was inside the Keltner Channel yesterday, but is outside today

(AVGC20 + 1.5 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 19) > (AVGC20 + AVGH20 + AVGL20) / 3 + 2 * (AVGH20 - AVGL20) AND AVGC20.1 + 1.5 * SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 19) <= (AVGC20.1 + AVGH20.1 + AVGL20.1) / 3 + 2 * (AVGH20.1 - AVGL20.1)) OR (AVGC20 - 1.5 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 19) < (AVGC20 + AVGH20 + AVGL20) / 3 - 2 * (AVGH20 - AVGL20) AND AVGC20.1 - 1.5 * SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 19) >= (AVGC20.1 + AVGH20.1 + AVGL20.1) / 3 - 2 * (AVGH20.1 - AVGL20.1))

These can be shortened if you are only interested in the Upper Bollinger Band:

QUOTE (ksoong)
a PCF that returns True if the Upper Bollinger Band was outside the Keltner Channel yesterday, but is inside today


AVGC20 + 1.5 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 19) < (AVGC20 + AVGH20 + AVGL20) / 3 + 2 * (AVGH20 - AVGL20) AND AVGC20.1 + 1.5 * SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 19) >= (AVGC20.1 + AVGH20.1 + AVGL20.1) / 3 + 2 * (AVGH20.1 - AVGL20.1)

QUOTE (ksoong)
a PCF that returns True if the Upper Bollinger Band was inside the Keltner Channel yesterday, but is outside today

AVGC20 + 1.5 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 19) > (AVGC20 + AVGH20 + AVGL20) / 3 + 2 * (AVGH20 - AVGL20) AND AVGC20.1 + 1.5 * SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 19) <= (AVGC20.1 + AVGH20.1 + AVGL20.1) / 3 + 2 * (AVGH20.1 - AVGL20.1)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ksoong
Posted : Monday, July 17, 2006 4:43:27 PM
Registered User
Joined: 4/3/2006
Posts: 44
Thanks for your effort...
Bruce_L
Posted : Monday, July 17, 2006 5:18:50 PM


Worden Trainer

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

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Eternum
Posted : Tuesday, September 12, 2006 9:52:51 PM
Registered User
Joined: 8/6/2005
Posts: 40
QUOTE (Tanstaafl)

The formulae for the EMA-based centerline with an ATR-based width is also PCF-able, but is probably not what was originally being requested, so I'll save that answer till another time.


Tanstaafl,

Could you please provide PCF for LBR version of Keltner Channels, which is EMA(20) +- ATR(2.5)?

Appreciate your help!
Eternum
Posted : Tuesday, September 12, 2006 10:11:51 PM
Registered User
Joined: 8/6/2005
Posts: 40
Sorry, I made a mistake. Formulae should be EMA(20) +- 2.5 * ATR(14).
Bruce_L
Posted : Tuesday, September 12, 2006 10:36:05 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Eternum,
Please try the following Personal Criteria Formulas based on a Wilder's Smoothed Average True Range:

LBR Keltner Channel Upper Band (EMA20 + 2.5 * ATR14):

XAVGC20 + 2.5 * (XAVGH27 - XAVGL27 + .0357480060263825 * (ABS(H - C1) + ABS(L - C1) - H + L + 13 / 14 * (ABS(H1 - C2) + ABS(L1 - C2) - H1 + L1 + 13 / 14 * (ABS(H2 - C3) + ABS(L2 - C3) - H2 + L2 + 13 / 14 * (ABS(H3 - C4) + ABS(L3 - C4) - H3 + L3 + 13 / 14 * (ABS(H4 - C5) + ABS(L4 - C5) - H4 + L4 + 13 / 14 * (ABS(H5 - C6) + ABS(L5 - C6) - H5 + L5 + 13 / 14 * (ABS(H6 - C7) + ABS(L6 - C7) - H6 + L6 + 13 / 14 * (ABS(H7 - C8) + ABS(L7 - C8) - H7 + L7 + 13 / 14 * (ABS(H8 - C9) + ABS(L8 - C9) - H8 + L8 + 13 / 14 * (ABS(H9 - C10) + ABS(L9 - C10) - H9 + L9 + 13 / 14 * (ABS(H10 - C11) + ABS(L10 - C11) - H10 + L10 + 13 / 14 * (ABS(H11 - C12) + ABS(L11 - C12) - H11 + L11 + 13 / 14 * (ABS(H12 - C13) + ABS(L12 - C13) - H12 + L12 + 13 / 14 * (ABS(H13 - C14) + ABS(L13 - C14) - H13 + L13 + 13 / 14 * (ABS(H14 - C15) + ABS(L14 - C15) - H14 + L14 + 13 / 14 * (ABS(H15 - C16) + ABS(L15 - C16) - H15 + L15 + 13 / 14 * (ABS(H16 - C17) + ABS(L16 - C17) - H16 + L16 + 13 / 14 * (ABS(H17 - C18) + ABS(L17 - C18) - H17 + L17 + 13 / 14 * (ABS(H18 - C19) + ABS(L18 - C19) - H18 + L18 + 13 / 14 * (ABS(H19 - C20) + ABS(L19 - C20) - H19 + L19 + 13 / 14 * (ABS(H20 - C21) + ABS(L20 - C21) - H20 + L20 + 13 / 14 * (ABS(H21 - C22) + ABS(L21 - C22) - H21 + L21 + 13 / 14 * (ABS(H22 - C23) + ABS(L22 - C23) - H22 + L22 + 13 / 14 * (ABS(H23 - C24) + ABS(L23 - C24) - H23 + L23 + 13 / 14 * (ABS(H24 - C25) + ABS(L24 - C25) - H24 + L24 + 13 / 14 * (ABS(H25 - C26) + ABS(L25 - C26) - H25 + L25 + 13 / 14 * (ABS(H26 - C27) + ABS(L26 - C27) - H26 + L26 + 13 / 14 * (ABS(H27 - C28) + ABS(L27 - C28) - H27 + L27 + 13 / 14 * (ABS(H28 - C29) + ABS(L28 - C29) - H28 + L28 + 13 / 14 * (ABS(H29 - C30) + ABS(L29 - C30) - H29 + L29 + 13 / 14 * (ABS(H30 - C31) + ABS(L30 - C31) - H30 + L30 + 13 / 14 * (ABS(H31 - C32) + ABS(L31 - C32) - H31 + L31 + 13 / 14 * (ABS(H32 - C33) + ABS(L32 - C33) - H32 + L32 + 13 / 14 * (ABS(H33 - C34) + ABS(L33 - C34) - H33 + L33 + 13 / 14 * (ABS(H34 - C35) + ABS(L34 - C35) - H34 + L34 + 13 / 14 * (ABS(H35 - C36) + ABS(L35 - C36) - H35 + L35 + 13 / 14 * (ABS(H36 - C37) + ABS(L36 - C37) - H36 + L36 + 13 / 14 * (ABS(H37 - C38) + ABS(L37 - C38) - H37 + L37 + 13 / 14 * (ABS(H38 - C39) + ABS(L38 - C39) - H38 + L38 + 13 / 14 * (ABS(H39 - C40) + ABS(L39 - C40) - H39 + L39 + 13 / 14 * (ABS(H40 - C41) + ABS(L40 - C41) - H40 + L40 + 13 / 14 * (ABS(H41 - C42) + ABS(L41 - C42) - H41 + L41 + 13 / 14 * (ABS(H42 - C43) + ABS(L42 - C43) - H42 + L42 + 13 / 14 * (ABS(H43 - C44) + ABS(L43 - C44) - H43 + L43 + 13 / 14 * (ABS(H44 - C45) + ABS(L44 - C45) - H44 + L44 + 13 / 14 * (ABS(H45 - C46) + ABS(L45 - C46) - H45 + L45 + 13 / 14 * (ABS(H46 - C47) + ABS(L46 - C47) - H46 + L46 + 13 / 14 * (ABS(H47 - C48) + ABS(L47 - C48) - H47 + L47 + 13 / 14 * (ABS(H48 - C49) + ABS(L48 - C49) - H48 + L48 + 13 / 14 * (ABS(H49 - C50) + ABS(L49 - C50) - H49 + L49 + 13 / 14 * (ABS(H50 - C51) + ABS(L50 - C51) - H50 + L50 + 13 / 14 * (ABS(H51 - C52) + ABS(L51 - C52) - H51 + L51 + 13 / 14 * (ABS(H52 - C53) + ABS(L52 - C53) - H52 + L52 + 13 / 14 * (ABS(H53 - C54) + ABS(L53 - C54) - H53 + L53 + 13 / 14 * (ABS(H54 - C55) + ABS(L54 - C55) - H54 + L54 + 13 / 14 * (ABS(H55 - C56) + ABS(L55 - C56) - H55 + L55 + 13 / 14 * (ABS(H56 - C57) + ABS(L56 - C57) - H56 + L56 + 13 / 14 * (ABS(H57 - C58) + ABS(L57 - C58) - H57 + L57 + 13 / 14 * (ABS(H58 - C59) + ABS(L58 - C59) - H58 + L58 + 13 / 14 * (ABS(H59 - C60) + ABS(L59 - C60) - H59 + L59 + 13 / 14 * (ABS(H60 - C61) + ABS(L60 - C61) - H60 + L60 + 13 / 14 * (ABS(H61 - C62) + ABS(L61 - C62) - H61 + L61 + 13 / 14 * (ABS(H62 - C63) + ABS(L62 - C63) - H62 + L62 + 13 / 14 * (ABS(H63 - C64) + ABS(L63 - C64) - H63 + L63 + 13 / 14 * (ABS(H64 - C65) + ABS(L64 - C65) - H64 + L64 + 13 / 14 * (ABS(H65 - C66) + ABS(L65 - C66) - H65 + L65 + 13 / 14 * (ABS(H66 - C67) + ABS(L66 - C67) - H66 + L66 + 13 / 14 * (ABS(H67 - C68) + ABS(L67 - C68) - H67 + L67 + 13 / 14 * (ABS(H68 - C69) + ABS(L68 - C69) - H68 + L68 + 13 / 14 * (ABS(H69 - C70) + ABS(L69 - C70) - H69 + L69 + 13 / 14 * (ABS(H70 - C71) + ABS(L70 - C71) - H70 + L70 + 13 / 14 * (ABS(H71 - C72) + ABS(L71 - C72) - H71 + L71 + 13 / 14 * (ABS(H72 - C73) + ABS(L72 - C73) - H72 + L72 + 13 / 14 * (ABS(H73 - C74) + ABS(L73 - C74) - H73 + L73 + 13 / 14 * (ABS(H74 - C75) + ABS(L74 - C75) - H74 + L74 + 13 / 14 * (ABS(H75 - C76) + ABS(L75 - C76) - H75 + L75 + 13 / 14 * (ABS(H76 - C77) + ABS(L76 - C77) - H76 + L76 + 13 / 14 * (ABS(H77 - C78) + ABS(L77 - C78) - H77 + L77 + 13 / 14 * (ABS(H78 - C79) + ABS(L78 - C79) - H78 + L78 + 13 / 14 * (ABS(H79 - C80) + ABS(L79 - C80) - H79 + L79 + 13 / 14 * (ABS(H80 - C81) + ABS(L80 - C81) - H80 + L80 + 13 / 14 * (ABS(H81 - C82) + ABS(L81 - C82) - H81 + L81 + 13 / 14 * (ABS(H82 - C83) + ABS(L82 - C83) - H82 + L82 + 13 / 14 * (ABS(H83 - C84) + ABS(L83 - C84) - H83 + L83 + 13 / 14 * (ABS(H84 - C85) + ABS(L84 - C85) - H84 + L84 + 13 / 14 * (ABS(H85 - C86) + ABS(L85 - C86) - H85 + L85 + 13 / 14 * (ABS(H86 - C87) + ABS(L86 - C87) - H86 + L86 + 13 / 14 * (ABS(H87 - C88) + ABS(L87 - C88) - H87 + L87 + 13 / 14 * (ABS(H88 - C89) + ABS(L88 - C89) - H88 + L88 + 13 / 14 * (ABS(H89 - C90) + ABS(L89 - C90) - H89 + L89 + 13 / 14 * (ABS(H90 - C91) + ABS(L90 - C91) - H90 + L90 + 13 / 14 * (ABS(H91 - C92) + ABS(L91 - C92) - H91 + L91 + 13 / 14 * (ABS(H92 - C93) + ABS(L92 - C93) - H92 + L92 + 13 / 14 * (ABS(H93 - C94) + ABS(L93 - C94) - H93 + L93)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

LBR Keltner Channel Lower Band (EMA20 - 2.5 * ATR14):

XAVGC20 - 2.5 * (XAVGH27 - XAVGL27 + .0357480060263825 * (ABS(H - C1) + ABS(L - C1) - H + L + 13 / 14 * (ABS(H1 - C2) + ABS(L1 - C2) - H1 + L1 + 13 / 14 * (ABS(H2 - C3) + ABS(L2 - C3) - H2 + L2 + 13 / 14 * (ABS(H3 - C4) + ABS(L3 - C4) - H3 + L3 + 13 / 14 * (ABS(H4 - C5) + ABS(L4 - C5) - H4 + L4 + 13 / 14 * (ABS(H5 - C6) + ABS(L5 - C6) - H5 + L5 + 13 / 14 * (ABS(H6 - C7) + ABS(L6 - C7) - H6 + L6 + 13 / 14 * (ABS(H7 - C8) + ABS(L7 - C8) - H7 + L7 + 13 / 14 * (ABS(H8 - C9) + ABS(L8 - C9) - H8 + L8 + 13 / 14 * (ABS(H9 - C10) + ABS(L9 - C10) - H9 + L9 + 13 / 14 * (ABS(H10 - C11) + ABS(L10 - C11) - H10 + L10 + 13 / 14 * (ABS(H11 - C12) + ABS(L11 - C12) - H11 + L11 + 13 / 14 * (ABS(H12 - C13) + ABS(L12 - C13) - H12 + L12 + 13 / 14 * (ABS(H13 - C14) + ABS(L13 - C14) - H13 + L13 + 13 / 14 * (ABS(H14 - C15) + ABS(L14 - C15) - H14 + L14 + 13 / 14 * (ABS(H15 - C16) + ABS(L15 - C16) - H15 + L15 + 13 / 14 * (ABS(H16 - C17) + ABS(L16 - C17) - H16 + L16 + 13 / 14 * (ABS(H17 - C18) + ABS(L17 - C18) - H17 + L17 + 13 / 14 * (ABS(H18 - C19) + ABS(L18 - C19) - H18 + L18 + 13 / 14 * (ABS(H19 - C20) + ABS(L19 - C20) - H19 + L19 + 13 / 14 * (ABS(H20 - C21) + ABS(L20 - C21) - H20 + L20 + 13 / 14 * (ABS(H21 - C22) + ABS(L21 - C22) - H21 + L21 + 13 / 14 * (ABS(H22 - C23) + ABS(L22 - C23) - H22 + L22 + 13 / 14 * (ABS(H23 - C24) + ABS(L23 - C24) - H23 + L23 + 13 / 14 * (ABS(H24 - C25) + ABS(L24 - C25) - H24 + L24 + 13 / 14 * (ABS(H25 - C26) + ABS(L25 - C26) - H25 + L25 + 13 / 14 * (ABS(H26 - C27) + ABS(L26 - C27) - H26 + L26 + 13 / 14 * (ABS(H27 - C28) + ABS(L27 - C28) - H27 + L27 + 13 / 14 * (ABS(H28 - C29) + ABS(L28 - C29) - H28 + L28 + 13 / 14 * (ABS(H29 - C30) + ABS(L29 - C30) - H29 + L29 + 13 / 14 * (ABS(H30 - C31) + ABS(L30 - C31) - H30 + L30 + 13 / 14 * (ABS(H31 - C32) + ABS(L31 - C32) - H31 + L31 + 13 / 14 * (ABS(H32 - C33) + ABS(L32 - C33) - H32 + L32 + 13 / 14 * (ABS(H33 - C34) + ABS(L33 - C34) - H33 + L33 + 13 / 14 * (ABS(H34 - C35) + ABS(L34 - C35) - H34 + L34 + 13 / 14 * (ABS(H35 - C36) + ABS(L35 - C36) - H35 + L35 + 13 / 14 * (ABS(H36 - C37) + ABS(L36 - C37) - H36 + L36 + 13 / 14 * (ABS(H37 - C38) + ABS(L37 - C38) - H37 + L37 + 13 / 14 * (ABS(H38 - C39) + ABS(L38 - C39) - H38 + L38 + 13 / 14 * (ABS(H39 - C40) + ABS(L39 - C40) - H39 + L39 + 13 / 14 * (ABS(H40 - C41) + ABS(L40 - C41) - H40 + L40 + 13 / 14 * (ABS(H41 - C42) + ABS(L41 - C42) - H41 + L41 + 13 / 14 * (ABS(H42 - C43) + ABS(L42 - C43) - H42 + L42 + 13 / 14 * (ABS(H43 - C44) + ABS(L43 - C44) - H43 + L43 + 13 / 14 * (ABS(H44 - C45) + ABS(L44 - C45) - H44 + L44 + 13 / 14 * (ABS(H45 - C46) + ABS(L45 - C46) - H45 + L45 + 13 / 14 * (ABS(H46 - C47) + ABS(L46 - C47) - H46 + L46 + 13 / 14 * (ABS(H47 - C48) + ABS(L47 - C48) - H47 + L47 + 13 / 14 * (ABS(H48 - C49) + ABS(L48 - C49) - H48 + L48 + 13 / 14 * (ABS(H49 - C50) + ABS(L49 - C50) - H49 + L49 + 13 / 14 * (ABS(H50 - C51) + ABS(L50 - C51) - H50 + L50 + 13 / 14 * (ABS(H51 - C52) + ABS(L51 - C52) - H51 + L51 + 13 / 14 * (ABS(H52 - C53) + ABS(L52 - C53) - H52 + L52 + 13 / 14 * (ABS(H53 - C54) + ABS(L53 - C54) - H53 + L53 + 13 / 14 * (ABS(H54 - C55) + ABS(L54 - C55) - H54 + L54 + 13 / 14 * (ABS(H55 - C56) + ABS(L55 - C56) - H55 + L55 + 13 / 14 * (ABS(H56 - C57) + ABS(L56 - C57) - H56 + L56 + 13 / 14 * (ABS(H57 - C58) + ABS(L57 - C58) - H57 + L57 + 13 / 14 * (ABS(H58 - C59) + ABS(L58 - C59) - H58 + L58 + 13 / 14 * (ABS(H59 - C60) + ABS(L59 - C60) - H59 + L59 + 13 / 14 * (ABS(H60 - C61) + ABS(L60 - C61) - H60 + L60 + 13 / 14 * (ABS(H61 - C62) + ABS(L61 - C62) - H61 + L61 + 13 / 14 * (ABS(H62 - C63) + ABS(L62 - C63) - H62 + L62 + 13 / 14 * (ABS(H63 - C64) + ABS(L63 - C64) - H63 + L63 + 13 / 14 * (ABS(H64 - C65) + ABS(L64 - C65) - H64 + L64 + 13 / 14 * (ABS(H65 - C66) + ABS(L65 - C66) - H65 + L65 + 13 / 14 * (ABS(H66 - C67) + ABS(L66 - C67) - H66 + L66 + 13 / 14 * (ABS(H67 - C68) + ABS(L67 - C68) - H67 + L67 + 13 / 14 * (ABS(H68 - C69) + ABS(L68 - C69) - H68 + L68 + 13 / 14 * (ABS(H69 - C70) + ABS(L69 - C70) - H69 + L69 + 13 / 14 * (ABS(H70 - C71) + ABS(L70 - C71) - H70 + L70 + 13 / 14 * (ABS(H71 - C72) + ABS(L71 - C72) - H71 + L71 + 13 / 14 * (ABS(H72 - C73) + ABS(L72 - C73) - H72 + L72 + 13 / 14 * (ABS(H73 - C74) + ABS(L73 - C74) - H73 + L73 + 13 / 14 * (ABS(H74 - C75) + ABS(L74 - C75) - H74 + L74 + 13 / 14 * (ABS(H75 - C76) + ABS(L75 - C76) - H75 + L75 + 13 / 14 * (ABS(H76 - C77) + ABS(L76 - C77) - H76 + L76 + 13 / 14 * (ABS(H77 - C78) + ABS(L77 - C78) - H77 + L77 + 13 / 14 * (ABS(H78 - C79) + ABS(L78 - C79) - H78 + L78 + 13 / 14 * (ABS(H79 - C80) + ABS(L79 - C80) - H79 + L79 + 13 / 14 * (ABS(H80 - C81) + ABS(L80 - C81) - H80 + L80 + 13 / 14 * (ABS(H81 - C82) + ABS(L81 - C82) - H81 + L81 + 13 / 14 * (ABS(H82 - C83) + ABS(L82 - C83) - H82 + L82 + 13 / 14 * (ABS(H83 - C84) + ABS(L83 - C84) - H83 + L83 + 13 / 14 * (ABS(H84 - C85) + ABS(L84 - C85) - H84 + L84 + 13 / 14 * (ABS(H85 - C86) + ABS(L85 - C86) - H85 + L85 + 13 / 14 * (ABS(H86 - C87) + ABS(L86 - C87) - H86 + L86 + 13 / 14 * (ABS(H87 - C88) + ABS(L87 - C88) - H87 + L87 + 13 / 14 * (ABS(H88 - C89) + ABS(L88 - C89) - H88 + L88 + 13 / 14 * (ABS(H89 - C90) + ABS(L89 - C90) - H89 + L89 + 13 / 14 * (ABS(H90 - C91) + ABS(L90 - C91) - H90 + L90 + 13 / 14 * (ABS(H91 - C92) + ABS(L91 - C92) - H91 + L91 + 13 / 14 * (ABS(H92 - C93) + ABS(L92 - C93) - H92 + L92 + 13 / 14 * (ABS(H93 - C94) + ABS(L93 - C94) - H93 + L93)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Tanstaafl
Posted : Wednesday, September 13, 2006 9:17:07 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Thanks for your help, Bruce. I'm pretty swamped right now.

Jim

sheana
Posted : Tuesday, March 10, 2009 9:29:17 AM
Registered User
Joined: 10/7/2004
Posts: 84

I have several questions about this topic. First off, how do you go about naming a custom formula?

When I input the Indicator Line Formula after r-clicking and selecting Custom Formula, I only got one line plotted on the price chart. I also got a Formula Error at the top left hand corner of the price chart saying "FORMULA ERROR!!!NO CALC) 1 period.

Can you please tell me the steps to input the formulas into Telechart? The simple example given in the program help file didn't explain any of this. Thanks in advance,

sheana

sheana
Posted : Tuesday, March 10, 2009 10:32:00 AM
Registered User
Joined: 10/7/2004
Posts: 84
For that matter, I don't even know how the user that responded to this topic managed to get a cigarette icon after his name. Feeling utterly bewildered,

sheana
Bruce_L
Posted : Tuesday, March 10, 2009 11:20:59 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
sheana,
This is a really old topic and the interface for entering posts has changed since ksoong included a cigar in his Monday, July 17, 2006 4:43:27 PM ET post. One of the changes is that the list of available "smilies" is different.

There are basically three different types of Custom Indicators and they utilize different types of formulas. A Custom Percent True Indicator takes a Boolean (True or False) formula in the Boolean Formula section.

Visually Backtesting Specific Symbols

A Custom Indicator takes a Value based formula in its Indicator Formula section.

Plotting Custom Indicators with Examples

A Custom Price Channel Indicator takes two Value based formulas, one for the centerline goes in the Indicator Line Formula section, while the other for the distance from the centerline goes in the Channel Width Formula section.

Finally, the Custom Cumulative Indicator takes both Boolean and Value based formulas. The two Boolean formulas go in the Up Condition and Down Condition sections while the Value to Add/Subtract section accepts a Value based formula.

You will receive errors if you put a Boolean formula where a Value based formula is required or a Value based formula where a Boorean formula is required. You will also receive error messages if the calculations themselves result in a division by zero or overflow or if the formulas do not use valid syntax.

PCF Formula Descriptions

In general, you are only going to put the formula itself in each of these sections as anything beyond this is not valid formula syntax. It is possible to start the formula with the "name" however. You can even put the "name" on the first line and have the formula on the second line (although this requires writing the formula in another program and pasting it into the formula window).

This is not supported however (meaning it could stop working at any time) and great care must be taken in constructing the name. If it contains reserved symbols or words, TeleChart will see it as a formula and attempt to evaluate the name. This will normally result in an error of some sort, but could result in a mis-calculation instead.

label middle/bottom panels in telechart
How to Label my PCFs

If you provide more information on what formula you were attempting to use where, we can probably give some more specific advice.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
cwbwin
Posted : Tuesday, October 4, 2016 11:17:41 PM
Registered User
Joined: 12/3/2004
Posts: 7
Location: New York City

Is therre a way to create a PCF for Keltner channel (10 EMA, 10 ATR, 1.5 ) formula in TC2007 that duplicates the one built into TC2000? Research shows that the EMA form is preferred to the SMA form.

Bruce_L
Posted : Wednesday, October 5, 2016 8:21:00 AM


Worden Trainer

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

The Upper Keltner Channel (10 EMA, 10 ATR, 1.5) can be written as follows.

(XAVGH10 + XAVGL10 + XAVGC10) / 3 + 1.5 * (XAVGH10 - XAVGL10 + .18198028 * ((H < C1) * (H - C1) + (C1 < L) * (C1 - L) + 9 / 11 * ((H1 < C2) * (H1 - C2) + (C2 < L1) * (C2 - L1) + 9 / 11 * ((H2 < C3) * (H2 - C3) + (C3 < L2) * (C3 - L2) + 9 / 11 * ((H3 < C4) * (H3 - C4) + (C4 < L3) * (C4 - L3) + 9 / 11 * ((H4 < C5) * (H4 - C5) + (C5 < L4) * (C5 - L4) + 9 / 11 * ((H5 < C6) * (H5 - C6) + (C6 < L5) * (C6 - L5) + 9 / 11 * ((H6 < C7) * (H6 - C7) + (C7 < L6) * (C7 - L6) + 9 / 11 * ((H7 < C8) * (H7 - C8) + (C8 < L7) * (C8 - L7) + 9 / 11 * ((H8 < C9) * (H8 - C9) + (C9 < L8) * (C9 - L8) + 9 / 11 * ((H9 < C10) * (H9 - C10) + (C10 < L9) * (C10 - L9) + 9 / 11 * ((H10 < C11) * (H10 - C11) + (C11 < L10) * (C11 - L10) + 9 / 11 * ((H11 < C12) * (H11 - C12) + (C12 < L11) * (C12 - L11) + 9 / 11 * ((H12 < C13) * (H12 - C13) + (C13 < L12) * (C13 - L12) + 9 / 11 * ((H13 < C14) * (H13 - C14) + (C14 < L13) * (C14 - L13) + 9 / 11 * ((H14 < C15) * (H14 - C15) + (C15 < L14) * (C15 - L14) + 9 / 11 * ((H15 < C16) * (H15 - C16) + (C16 < L15) * (C16 - L15) + 9 / 11 * ((H16 < C17) * (H16 - C17) + (C17 < L16) * (C17 - L16) + 9 / 11 * ((H17 < C18) * (H17 - C18) + (C18 < L17) * (C18 - L17) + 9 / 11 * ((H18 < C19) * (H18 - C19) + (C19 < L18) * (C19 - L18) + 9 / 11 * ((H19 < C20) * (H19 - C20) + (C20 < L19) * (C20 - L19) + 9 / 11 * ((H20 < C21) * (H20 - C21) + (C21 < L20) * (C21 - L20) + 9 / 11 * ((H21 < C22) * (H21 - C22) + (C22 < L21) * (C22 - L21) + 9 / 11 * ((H22 < C23) * (H22 - C23) + (C23 < L22) * (C23 - L22) + 9 / 11 * ((H23 < C24) * (H23 - C24) + (C24 < L23) * (C24 - L23) + 9 / 11 * ((H24 < C25) * (H24 - C25) + (C25 < L24) * (C25 - L24) + 9 / 11 * ((H25 < C26) * (H25 - C26) + (C26 < L25) * (C26 - L25) + 9 / 11 * ((H26 < C27) * (H26 - C27) + (C27 < L26) * (C27 - L26) + 9 / 11 * ((H27 < C28) * (H27 - C28) + (C28 < L27) * (C28 - L27) + 9 / 11 * ((H28 < C29) * (H28 - C29) + (C29 < L28) * (C29 - L28) + 9 / 11 * ((H29 < C30) * (H29 - C30) + (C30 < L29) * (C30 - L29) + 9 / 11 * ((H30 < C31) * (H30 - C31) + (C31 < L30) * (C31 - L30) + 9 / 11 * ((H31 < C32) * (H31 - C32) + (C32 < L31) * (C32 - L31) + 9 / 11 * ((H32 < C33) * (H32 - C33) + (C33 < L32) * (C33 - L32) + 9 / 11 * ((H33 < C34) * (H33 - C34) + (C34 < L33) * (C34 - L33) + 9 / 11 * ((H34 < C35) * (H34 - C35) + (C35 < L34) * (C35 - L34)))))))))))))))))))))))))))))))))))))

The Lower Keltner Channel (10 EMA, 10 ATR, 1.5) can be written as follows.

(XAVGH10 + XAVGL10 + XAVGC10) / 3 - 1.5 * (XAVGH10 - XAVGL10 + .18198028 * ((H < C1) * (H - C1) + (C1 < L) * (C1 - L) + 9 / 11 * ((H1 < C2) * (H1 - C2) + (C2 < L1) * (C2 - L1) + 9 / 11 * ((H2 < C3) * (H2 - C3) + (C3 < L2) * (C3 - L2) + 9 / 11 * ((H3 < C4) * (H3 - C4) + (C4 < L3) * (C4 - L3) + 9 / 11 * ((H4 < C5) * (H4 - C5) + (C5 < L4) * (C5 - L4) + 9 / 11 * ((H5 < C6) * (H5 - C6) + (C6 < L5) * (C6 - L5) + 9 / 11 * ((H6 < C7) * (H6 - C7) + (C7 < L6) * (C7 - L6) + 9 / 11 * ((H7 < C8) * (H7 - C8) + (C8 < L7) * (C8 - L7) + 9 / 11 * ((H8 < C9) * (H8 - C9) + (C9 < L8) * (C9 - L8) + 9 / 11 * ((H9 < C10) * (H9 - C10) + (C10 < L9) * (C10 - L9) + 9 / 11 * ((H10 < C11) * (H10 - C11) + (C11 < L10) * (C11 - L10) + 9 / 11 * ((H11 < C12) * (H11 - C12) + (C12 < L11) * (C12 - L11) + 9 / 11 * ((H12 < C13) * (H12 - C13) + (C13 < L12) * (C13 - L12) + 9 / 11 * ((H13 < C14) * (H13 - C14) + (C14 < L13) * (C14 - L13) + 9 / 11 * ((H14 < C15) * (H14 - C15) + (C15 < L14) * (C15 - L14) + 9 / 11 * ((H15 < C16) * (H15 - C16) + (C16 < L15) * (C16 - L15) + 9 / 11 * ((H16 < C17) * (H16 - C17) + (C17 < L16) * (C17 - L16) + 9 / 11 * ((H17 < C18) * (H17 - C18) + (C18 < L17) * (C18 - L17) + 9 / 11 * ((H18 < C19) * (H18 - C19) + (C19 < L18) * (C19 - L18) + 9 / 11 * ((H19 < C20) * (H19 - C20) + (C20 < L19) * (C20 - L19) + 9 / 11 * ((H20 < C21) * (H20 - C21) + (C21 < L20) * (C21 - L20) + 9 / 11 * ((H21 < C22) * (H21 - C22) + (C22 < L21) * (C22 - L21) + 9 / 11 * ((H22 < C23) * (H22 - C23) + (C23 < L22) * (C23 - L22) + 9 / 11 * ((H23 < C24) * (H23 - C24) + (C24 < L23) * (C24 - L23) + 9 / 11 * ((H24 < C25) * (H24 - C25) + (C25 < L24) * (C25 - L24) + 9 / 11 * ((H25 < C26) * (H25 - C26) + (C26 < L25) * (C26 - L25) + 9 / 11 * ((H26 < C27) * (H26 - C27) + (C27 < L26) * (C27 - L26) + 9 / 11 * ((H27 < C28) * (H27 - C28) + (C28 < L27) * (C28 - L27) + 9 / 11 * ((H28 < C29) * (H28 - C29) + (C29 < L28) * (C29 - L28) + 9 / 11 * ((H29 < C30) * (H29 - C30) + (C30 < L29) * (C30 - L29) + 9 / 11 * ((H30 < C31) * (H30 - C31) + (C31 < L30) * (C31 - L30) + 9 / 11 * ((H31 < C32) * (H31 - C32) + (C32 < L31) * (C32 - L31) + 9 / 11 * ((H32 < C33) * (H32 - C33) + (C33 < L32) * (C33 - L32) + 9 / 11 * ((H33 < C34) * (H33 - C34) + (C34 < L33) * (C34 - L33) + 9 / 11 * ((H34 < C35) * (H34 - C35) + (C35 < L34) * (C35 - L34)))))))))))))))))))))))))))))))))))))



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