Registered User Joined: 10/7/2004 Posts: 5
|
I've toyed for a while trying to create a custom indicator to graphically illustrate consecutive days Up/Down. Ideally, I want an indicator that rises above zero when counting consecutive days up and falls below zero when counting consecutive days down. I can do it in Excel, but I am not yet versed enough in TC to translate my Excel formulas into PCF coding. Although I can determine Up/Down days [abs(C>C1)+abs(C<C1)*-1], I can’t figure the logic to add consecutive days and have the count remain anchored to zero (I’ve come up w/all sorts of convoluted, nonsensical formulas as I’ve tried to make this work!).
I can use a modification of the above formula in the additive custom indicator tool; however, that is truly additive. If the price closes up 3 consecutive days, the result is 3. Next, if it closes down 2 consecutive days, the result is 1 (3-2=1), instead of the -2 that I want it to return. I'm sure I'm simply missing some finer point of logic/understanding to make this thing work. Can any of you seasoned TC vets help me figure this out?
I hope I’ve explained what I’m after well enough for someone to catch my vision and provide some guidance. If not, please ask clarifying questions. Any help would be greatly appreciated.
Thanks, -Mike.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try the following:
Select Chart Template | Add Indicator | Indicator. - Visible: Checked - Center Zero Line: Checked - Plot using price scale: Unchecked - Smoothing Average: 1 - Average Type: Doesn't matter (because the Smoothing Average is 1) - Indicator Formula: ( - 1) * (C > C1) * (1 - (C1 > C2) * (1 - (C2 > C3) * (1 - (C3 > C4) * (1 - (C4 > C5) * (1 - (C5 > C6) * (1 - (C6 > C7) * (1 - (C7 > C8) * (1 - (C8 > C9) * (1 - (C9 > C10) * (1 - (C10 > C11) * (1 - (C11 > C12) * (1 - (C12 > C13) * (1 - (C13 > C14) * (1 - (C14 > C15) * (1 - (C15 > C16) * (1 - (C16 > C17) * (1 - (C17 > C18) * (1 - (C18 > C19) * (1 - (C19 > C20) * (1 - (C20 > C21) * (1 - (C21 > C22) * (1 - (C22 > C23) * (1 - (C23 > C24) * (1 - (C24 > C25) * (1 - (C25 > C26) * (1 - (C26 > C27) * (1 - (C27 > C28) * (1 - (C28 > C29) * (1 - (C29 > C30) * (1 - (C30 > C31) * (1 - (C31 > C32) * (1 - (C32 > C33) * (1 - (C33 > C34) * (1 - (C34 > C35) * (1 - (C35 > C36) * (1 - (C36 > C37) * (1 - (C37 > C38) * (1 - (C38 > C39) * (1 - (C39 > C40) * (1 - (C40 > C41) * (1 - (C41 > C42) * (1 - (C42 > C43) * (1 - (C43 > C44) * (1 - (C44 > C45) * (1 - (C45 > C46) * (1 - (C46 > C47) * (1 - (C47 > C48) * (1 - (C48 > C49) * (1 - (C49 > C50)))))))))))))))))))))))))))))))))))))))))))))))))) + (C < C1) * (1 - (C1 < C2) * (1 - (C2 < C3) * (1 - (C3 < C4) * (1 - (C4 < C5) * (1 - (C5 < C6) * (1 - (C6 < C7) * (1 - (C7 < C8) * (1 - (C8 < C9) * (1 - (C9 < C10) * (1 - (C10 < C11) * (1 - (C11 < C12) * (1 - (C12 < C13) * (1 - (C13 < C14) * (1 - (C14 < C15) * (1 - (C15 < C16) * (1 - (C16 < C17) * (1 - (C17 < C18) * (1 - (C18 < C19) * (1 - (C19 < C20) * (1 - (C20 < C21) * (1 - (C21 < C22) * (1 - (C22 < C23) * (1 - (C23 < C24) * (1 - (C24 < C25) * (1 - (C25 < C26) * (1 - (C26 < C27) * (1 - (C27 < C28) * (1 - (C28 < C29) * (1 - (C29 < C30) * (1 - (C30 < C31) * (1 - (C31 < C32) * (1 - (C32 < C33) * (1 - (C33 < C34) * (1 - (C34 < C35) * (1 - (C35 < C36) * (1 - (C36 < C37) * (1 - (C37 < C38) * (1 - (C38 < C39) * (1 - (C39 < C40) * (1 - (C40 < C41) * (1 - (C41 < C42) * (1 - (C42 < C43) * (1 - (C43 < C44) * (1 - (C44 < C45) * (1 - (C45 < C46) * (1 - (C46 < C47) * (1 - (C47 < C48) * (1 - (C48 < C49) * (1 - (C49 < C50))))))))))))))))))))))))))))))))))))))))))))))))))
It maxes out at 50 consecutive days. You may wish to review the following:
Plotting Custom Indicators with Examples Handy PCF example formulas to help you learn the syntax of PCFs!
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 10/7/2004 Posts: 5
|
Bruce. Thank you for your help on this formula. It does yeild the output I'm after. I will seek to understand the logic involved. Thanks again.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|