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 |

Referencing and existing PCF Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
jztrader
Posted : Friday, December 7, 2018 3:01:35 PM
Platinum Customer Platinum Customer

Joined: 12/4/2016
Posts: 5

Good afternoon,

I have created a PCF that uses several COUNTTRUE functions together. 

Here is an example of part of the formula:

counttrue(c>c1 and h>h1 ad l>l1,5) + counttrue(c-o>=max(c-o,9),5) + -1*counttrue(c<c1 and h<h1 and l<l1,5) + -1*counttrue(o-c>=max(o-c,9),5)

I am attempting to create another PCF that will take the difference between today's value a yesterday's value. Could you provide me an example of how to do this?

Also, is there a way to reference an existing PCF in a new PCF without having to write the entire PCF out?

Thank you.  

Bruce_L
Posted : Friday, December 7, 2018 3:26:36 PM


Worden Trainer

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

There is not a way to reference another PCF from within a PCF.

Normally you would just subtract the 1 bar ago version from the current version.

CountTrue(C > C1 AND H > H1 AND L > L1, 5) + CountTrue(C - O >= MAX(C - O, 9), 5) - CountTrue(C < C1 AND H < H1 AND L < L1, 5) - CountTrue(O - C <= MAX(O - C, 9), 5) - CountTrue(C1 > C2 AND H1 > H2 AND L1 > L2, 5) - CountTrue(C1 - O1 >= MAX(C1 - O1, 9), 5) + CountTrue(C1 < C2 AND H1 < H2 AND L1 < L2, 5) + CountTrue(O1 - C1 <= MAX(O1 - C1, 9), 5)

But in this case, it would be more efficient to just check if the conditions are true for the current bar and 5 bars ago.

IIF(C > C1 AND H > H1 AND L > L1, 1, IIF(C < C1 AND H < H1 AND L < L1, -1, 0)) + IIF(C - O = MAX(C - O, 9), 1, IIF(O - C = MAX(O - C, 9), -1, 0)) - IIF(C5 > C6 AND H5 > H6 AND L5 > L6, 1, IIF(C5 < C6 AND H5 < H6 AND L6 < L6, -1, 0)) - IIF(C5 - O5 = MAX(C5 - O5, 9), 1, IIF(O5 - C5 = MAX(O5 - C5, 9), -1, 0))



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jztrader
Posted : Thursday, January 3, 2019 5:38:51 PM
Platinum Customer Platinum Customer

Joined: 12/4/2016
Posts: 5

Bruce,

I wanted to follow up and clarify what I am looking specifically for. 

The COUNTTRUE formula in my last post results in creating an oscillator with both positive and negative numbers.  That's the reason I have some of the COUNTTRUE statements starting with a -1 which produces a negative number which is what I want.  It may not be the ideal way to write the formula but it does work. 

What I am really looking for with this formula is the diffence between the current bars formula value versus the value from yesterday (or from 1 min ago, 2 min. ago, whatever time frame being used). So as an example, if the current bars formula value is 4 and yesterday's formula value is 1 then it would return a value of 3 (4-1).  Seems like a simple subtraction but with many formulas, I was not sure how to write it.

Since the formula produces negative values, I am looking for both the real difference (like in the example) and how to get the ABSOLUTE difference which would just produce a positive number.  Hope this makes sense. 

Also, with another software, I created this formula but used an 8 period exponential moving average instead of a the counttrue function for 5 periods (simple not exponential). Is there a way to produce this overall formula using the "xavg" function for each statement within the overall formula? I prefer a more weighted formula (exponential) versus a simple formula. 

Thanks for your help in advance.

John

 

Bruce_L
Posted : Tuesday, January 8, 2019 10:34:57 AM


Worden Trainer

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

If I am understanding correctly, we should be able to just use the ABS() function to get your first answer.

ABS(IIF(C > C1 AND H > H1 AND L > L1, 1, IIF(C < C1 AND H < H1 AND L < L1, -1, 0)) + IIF(C - O = MAX(C - O, 9), 1, IIF(O - C = MAX(O - C, 9), -1, 0)) - IIF(C5 > C6 AND H5 > H6 AND L5 > L6, 1, IIF(C5 < C6 AND H5 < H6 AND L6 < L6, -1, 0)) - IIF(C5 - O5 = MAX(C5 - O5, 9), 1, IIF(O5 - C5 = MAX(O5 - C5, 9), -1, 0)))

For the second part, we can start with the raw value.

IIF(C > C1 AND H > H1 AND L > L1, 1, IIF(C < C1 AND H < H1 AND L < L1, -1, 0)) + IIF(C - O = MAX(C - O, 9), 1, IIF(O - C = MAX(O - C, 9), -1, 0))

And get the difference between it and one bar ago.

IIF(C > C1 AND H > H1 AND L > L1, 1, IIF(C < C1 AND H < H1 AND L < L1, -1, 0)) + IIF(C - O = MAX(C - O, 9), 1, IIF(O - C = MAX(O - C, 9), -1, 0)) - IIF(C1 > C2 AND H1 > H2 AND L1 > L2, 1, IIF(C1 < C2 AND H1 < H2 AND L1 < L2, -1, 0)) - IIF(C1 - O1 = MAX(C1 - O1, 9), 1, IIF(O1 - C1 = MAX(O1 - C1, 9), -1, 0))

Then add an exponential moving average.

XAVG(IIF(C > C1 AND H > H1 AND L > L1, 1, IIF(C < C1 AND H < H1 AND L < L1, -1, 0)) + IIF(C - O = MAX(C - O, 9), 1, IIF(O - C = MAX(O - C, 9), -1, 0)) - IIF(C1 > C2 AND H1 > H2 AND L1 > L2, 1, IIF(C1 < C2 AND H1 < H2 AND L1 < L2, -1, 0)) - IIF(C1 - O1 = MAX(C1 - O1, 9), 1, IIF(O1 - C1 = MAX(O1 - C1, 9), -1, 0)), 8)

And take the absolute value.

ABS(XAVG(IIF(C > C1 AND H > H1 AND L > L1, 1, IIF(C < C1 AND H < H1 AND L < L1, -1, 0)) + IIF(C - O = MAX(C - O, 9), 1, IIF(O - C = MAX(O - C, 9), -1, 0)) - IIF(C1 > C2 AND H1 > H2 AND L1 > L2, 1, IIF(C1 < C2 AND H1 < H2 AND L1 < L2, -1, 0)) - IIF(C1 - O1 = MAX(C1 - O1, 9), 1, IIF(O1 - C1 = MAX(O1 - C1, 9), -1, 0)), 8))



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