Subscription & data-feed pricing Class schedule

Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.

 Change CountTrue to 1-Ago and to 2-Ago Rate this Topic:
 Previous Topic · Next Topic Watch this topic · Print this topic ·
 Posted : Tuesday, October 09, 2018 4:52:55 PM
Registered User
Joined: 10/7/2004
Posts: 1,178

Below is the formula you provided me today:

CountTrue(O + H + L + C = O1 + H1 + L1 + C1, 390) - CountTrue(V1 = 0, 390)

I would like to change it to 1-Ago (keeping it as 390 minutes).  Is this correct?

CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 390) - CountTrue(V2 = 0, 390)

Also 2-Ago?

CountTrue(O2 + H2 + L2 + C2 = O3 + H3 + L3 + C3, 390) - CountTrue(V23= 0, 390)

And finally is the below correct?

CountTrue(O + H + L + C = O1 + H1 + L1 + C1, 390) - CountTrue(V1 = 0, 390)>CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 390) - CountTrue(V2 = 0, 390)

Thanks, Bruce.  What would I and we do without you?

Bruce_L
 Posted : Tuesday, October 09, 2018 5:00:00 PM

Worden Trainer

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

Your first conversion looks correct. Your second conversion has V23 where it should have V3.

Your last formula looks correct, but you should be able to make it a lot more efficient by counting a single bar on each side of the inequality instead of 390 bars on each side of the inequality (because all of the other bars being counted should be the same on both sides).

`CountTrue(O + H + L + C = O1 + H1 + L1 + C1, 1) - CountTrue(V1 = 0, 1) > CountTrue(O390 + H390 + L390 + C390 = O391 + H391 + L391 + C391, 1) - CountTrue(V391 = 0, 1)`

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
 Posted : Tuesday, October 09, 2018 5:12:33 PM
Registered User
Joined: 10/7/2004
Posts: 1,178

Thanks for noticing my typo--and for suggesting an improvement in efficiency in the longer final formula.  I wish I understood the math, but with your help I am learning gradually!

Bruce_L
 Posted : Wednesday, October 10, 2018 8:46:19 AM

Worden Trainer

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

In this case the math behind the simplification is a lot simpler than it might seem on the surface.

The part before the > sign in your version looks at the most recent 390 bars and counts how many times the formula is true.

`CountTrue(O + H + L + C = O1 + H1 + L1 + C1, 390) - CountTrue(V1 = 0, 390)`

And the part after the > sign does the same but for the 390 bars ending 1-bar ago.

`CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 390) - CountTrue(V2 = 0, 390)`

So 389 of the bars are being counted in both formulas. Those 389 bars will come up with the same result in both formulas. You could break down the first formula into the following.

`CountTrue(O + H + L + C = O1 + H1 + L1 + C1, 1) - CountTrue(V1 = 0, 1) + CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 389) - CountTrue(V2 = 0, 389)`

And the second part into the following.

`CountTrue(O390 + H390 + L390 + C390 = O391 + H391 + L391 + C391, 1) - CountTrue(V391 = 0, 1) + CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 389) - CountTrue(V2 = 0, 389)`

Note that this section is the same in both.

`CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 389) - CountTrue(V2 = 0, 389)`

So we can eliminate it from both sides of the inequality to get the more efficient version.

`CountTrue(O + H + L + C = O1 + H1 + L1 + C1, 1) - CountTrue(V1 = 0, 1) > CountTrue(O390 + H390 + L390 + C390 = O391 + H391 + L391 + C391, 1) - CountTrue(V391 = 0, 1)`

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
 Posted : Wednesday, October 10, 2018 2:31:45 PM
Registered User
Joined: 10/7/2004
Posts: 1,178

Thanks for the explanation.  I need some time to study and absorb this.

In the meantime, please convert the below to your more efficient formula:

CountTrue(O2 + H2 + L2 + C2 = O3 + H3 + L3 + C3, 390) - CountTrue(V2= 0, 390)<CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 390) - CountTrue(V1=0, 390)

Bruce_L
 Posted : Wednesday, October 10, 2018 2:46:46 PM

Worden Trainer

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

`CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 1) - CountTrue(V1 = 0, 1) > CountTrue(O391 + H391 + L391 + C391 = O392 + H392 + L392 + C392, 1) - CountTrue(V391 = 0, 1)`

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
 Posted : Thursday, October 11, 2018 12:33:44 PM
Registered User
Joined: 10/7/2004
Posts: 1,178

I am testing the efficient PCF from yesterday representing the # Anchors 2-Ago < # Anchors 1-Ago.  See it below:

`CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 1) - CountTrue(V1 = 0, 1) > CountTrue(O391 + H391 + L391 + C391 = O392 + H392 + L392 + C392, 1) - CountTrue(V391 = 0, 1)`

Now, please change this PCF to represent # Anchors 2-Ago > # Anchors 1-Ago.

Bruce_L
 Posted : Thursday, October 11, 2018 12:41:53 PM

Worden Trainer

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

`CountTrue(O1 + H1 + L1 + C1 = O2 + H2 + L2 + C2, 1) - CountTrue(V1 = 0, 1) < CountTrue(O391 + H391 + L391 + C391 = O392 + H392 + L392 + C392, 1) - CountTrue(V391 = 0, 1)`