Registered User Joined: 1/5/2008 Posts: 117

How would I create a scan condition for Hull Moving Average 21 that would identify the following:
1. When the average has changed from moving down to moving up on the last daily price bar.
2. When the average has changed from moving up to moving down on the last daily price bar.
Thanks in advance

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

I generally just check for the moving average to be crossing up or down through its own 2 period moving average (and I usually use exponential, but it probably doesn't matter that much).
So changing from moving down to moving up would be the following in TC2000 v17.
XUP(HAVGC21, XAVG(HAVGC21, 2))
And changing from moving up to moving down would be the following.
XDOWN(HAVGC21, XAVG(HAVGC21, 2))
You could also explicitly check for going one direction during the current bar and the other direction during the previous bar. So down to up would be:
HAVGC21 > HAVGC21.1 AND HAVGC21.1 < HAVGC21.2
And up to down would be:
HAVGC21 < HAVGC21.1 AND HAVGC21.1 > HAVGC21.2
Bruce Personal Criteria Formulas TC2000 Support Articles

Registered User Joined: 1/5/2008 Posts: 117

Thanks Bruce, really appreciate the quick response on a Saturday morning.

Registered User Joined: 6/26/2011 Posts: 128

Hi Bruce:
Could you tell me c0 such that havgc21=havgc21.1?

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

Please try the following.
(203 * C4 + 3330 * AVGC6.5 + 345 * C11 + 177 * C12 + 51 * C13  1075 * C1  612 * C2  186 * C3  33 * C14  525 * AVGC7.14  50 * C22  30 * C23  15 * C24  5 * C25) / 1575
Bruce Personal Criteria Formulas TC2000 Support Articles

Registered User Joined: 6/26/2011 Posts: 128

QUOTE (Bruce_L)
Please try the following.
(203 * C4 + 3330 * AVGC6.5 + 345 * C11 + 177 * C12 + 51 + C13  1075 * C1  612 * C2  186 * C3  33 * C14  525 * AVGC7.14  50 * C22  30 * C23  15 * C24  5 * C25) / 1575
Hmm. The formula seems to be too low most of the time  should be where havgc slope changes.

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

Well then maybe you can identify where the problem might be since I really don't have enough blood going to my brain today (and I mean that quite literally).
HAVGC21 = (1575 * C + 2650 * C1 + 3262 * C2 + 3448 * C3 + 3245 * C4 + 2690 * C5 + 2135 * C6 + 1580 * C7 + 1025 * C8 + 470 * C9  85 * C10  430 * C11  607 * C12  658 * C13  625 * C14  550 * C15  475 * C16  400 * C17  325 * C18  250 * C19  175 * C20  100 * C21  50 * C22  20 * C23  5 * C24) / 17325
You can test the above by overlaying it into the same pane and scale as an HAVGC21 applied to price.
And you want HAVGC21 = HAVGC21.1. So:
(1575 * C + 2650 * C1 + 3262 * C2 + 3448 * C3 + 3245 * C4 + 2690 * C5 + 2135 * C6 + 1580 * C7 + 1025 * C8 + 470 * C9  85 * C10  430 * C11  607 * C12  658 * C13  625 * C14  550 * C15  475 * C16  400 * C17  325 * C18  250 * C19  175 * C20  100 * C21  50 * C22  20 * C23  5 * C24) / 17325 = (1575 * C1 + 2650 * C2 + 3262 * C3 + 3448 * C4 + 3245 * C5 + 2690 * C6 + 2135 * C7 + 1580 * C8 + 1025 * C9 + 470 * C10  85 * C11  430 * C12  607 * C13  658 * C14  625 * C15  550 * C16  475 * C17  400 * C18  325 * C19  250 * C20  175 * C21  100 * C22  50 * C23  20 * C24  5 * C25) / 17325
We can get rid of the () / 17325 on both sides to get the following.
1575 * C + 2650 * C1 + 3262 * C2 + 3448 * C3 + 3245 * C4 + 2690 * C5 + 2135 * C6 + 1580 * C7 + 1025 * C8 + 470 * C9  85 * C10  430 * C11  607 * C12  658 * C13  625 * C14  550 * C15  475 * C16  400 * C17  325 * C18  250 * C19  175 * C20  100 * C21  50 * C22  20 * C23  5 * C24 = 1575 * C1 + 2650 * C2 + 3262 * C3 + 3448 * C4 + 3245 * C5 + 2690 * C6 + 2135 * C7 + 1580 * C8 + 1025 * C9 + 470 * C10  85 * C11  430 * C12  607 * C13  658 * C14  625 * C15  550 * C16  475 * C17  400 * C18  325 * C19  250 * C20  175 * C21  100 * C22  50 * C23  20 * C24  5 * C25
And move everything besides 1575 * C to the right side and combine terms.
1575 * C = 1075 * C1 + 612 * C2 + 186 * C3 + 203 * C4 + 555 * C5 + 555 * C6 + 555 * C7 + 555 * C8 + 555 * C9 + 555 * C10 + 345 * C11 + 177 * C12 + 51 * C13 + 33 * C14 + 75 * C15 + 75 * C16 + 75 * C17 + 75 * C18 + 75 * C19 + 75 * C20 + 75 * C21 + 50 * C22 + 30 * C23 + 15 * C24 + 5 * C25
And then divide everything by 1575.
C = (1075 * C1 + 612 * C2 + 186 * C3 + 203 * C4 + 555 * C5 + 555 * C6 + 555 * C7 + 555 * C8 + 555 * C9 + 555 * C10 + 345 * C11 + 177 * C12 + 51 * C13 + 33 * C14 + 75 * C15 + 75 * C16 + 75 * C17 + 75 * C18 + 75 * C19 + 75 * C20 + 75 * C21 + 50 * C22 + 30 * C23 + 15 * C24 + 5 * C25) / 1575
And rearrange everything and combine like factors to allow the use of AVGC and get the formula given earlier.
(203 * C4 + 3330 * AVGC6.5 + 345 * C11 + 177 * C12 + 51 C C13  1075 * C1  612 * C2  186 * C3  33 * C14  525 * AVGC7.14  50 * C22  30 * C23  15 * C24  5 * C25) / 1575
Note that C1 through C7 all have greater weight than C and C10 through C24 actually provide a negative contribution when calculating a 21 period Hull moving average, so that might be leading to counterintuitive results.
Bruce Personal Criteria Formulas TC2000 Support Articles

Registered User Joined: 6/26/2011 Posts: 128

Well done... Thank you. The second to last formula works fine. The main problem with the final formula is "51+c13" should be 51*c13". The two formulas
still produce slightly different numbers  may be due to floating point in avgc?.
Hope you feel better soon :)

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

I was hoping it was going to be something simple. I am happy to read you found it. It has been corrected above.
Bruce Personal Criteria Formulas TC2000 Support Articles
