Registered User Joined: 3/17/2016 Posts: 48
|
Hi,
I want to know when two moving averages crossed each other, i.e. on Daily Chart, I want to have a column as part of easy scan that shows me when the crossover happened (see below), is there anyway to return a value from the PCF indicator to tell me this. Currently, I have to make atleast 5-10 different easy scans and conditions; MA5 xOver MA10 - 1 Bar Ago, 2 Bar Ago, 3 Bars Ago, etc.... you get the idea
I want to make one single scan that uses the condition AVGC5 > AVGC10 (MA5 is above MA10) and then have a column to show me the crossover time, I then want to sort accordingly to view the crossover periods:
i.e. See below for sample easy scan result:
Ticker | MA5 xOver MA10 - X Bars Ago
INSY | 4
AAPL | 3
XYZA | 4
TRIP | 14
...... | ....
Anyway to achieve this?
If this is not possible, Worden can you please look into in future builds.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If you create your EasyScan for the 5 period simple moving average being above the 10 period simple moving average, then you could use the following Indicator Formula as a WatchList Column to count the number of bars since it crossed up (it will max out at 50 bars ago).
How to create and save an Indicator (PCF) Formula
How to Create an EasyScan and save it to the Library
How to add a column to a WatchList
Days Since Last Peak (or other day-counting needs)
ABS(AVGC5.1 > AVGC10.1) * (ABS(AVGC5.2 <= AVGC10.2) + ABS(AVGC5.2 > AVGC10.2) * (ABS(AVGC5.3 <= AVGC10.3) * 2 + ABS(AVGC5.3 > AVGC10.3) * (ABS(AVGC5.4 <= AVGC10.4) * 3 + ABS(AVGC5.4 > AVGC10.4) * (ABS(AVGC5.5 <= AVGC10.5) * 4 + ABS(AVGC5.5 > AVGC10.5) * (ABS(AVGC5.6 <= AVGC10.6) * 5 + ABS(AVGC5.6 > AVGC10.6) * (ABS(AVGC5.7 <= AVGC10.7) * 6 + ABS(AVGC5.7 > AVGC10.7) * (ABS(AVGC5.8 <= AVGC10.8) * 7 + ABS(AVGC5.8 > AVGC10.8) * (ABS(AVGC5.9 <= AVGC10.9) * 8 + ABS(AVGC5.9 > AVGC10.9) * (ABS(AVGC5.10 <= AVGC10.10) * 9 + ABS(AVGC5.10 > AVGC10.10) * (ABS(AVGC5.11 <= AVGC10.11) * 10 + ABS(AVGC5.11 > AVGC10.11) * (ABS(AVGC5.12 <= AVGC10.12) * 11 + ABS(AVGC5.12 > AVGC10.12) * (ABS(AVGC5.13 <= AVGC10.13) * 12 + ABS(AVGC5.13 > AVGC10.13) * (ABS(AVGC5.14 <= AVGC10.14) * 13 + ABS(AVGC5.14 > AVGC10.14) * (ABS(AVGC5.15 <= AVGC10.15) * 14 + ABS(AVGC5.15 > AVGC10.15) * (ABS(AVGC5.16 <= AVGC10.16) * 15 + ABS(AVGC5.16 > AVGC10.16) * (ABS(AVGC5.17 <= AVGC10.17) * 16 + ABS(AVGC5.17 > AVGC10.17) * (ABS(AVGC5.18 <= AVGC10.18) * 17 + ABS(AVGC5.18 > AVGC10.18) * (ABS(AVGC5.19 <= AVGC10.19) * 18 + ABS(AVGC5.19 > AVGC10.19) * (ABS(AVGC5.20 <= AVGC10.20) * 19 + ABS(AVGC5.20 > AVGC10.20) * (ABS(AVGC5.21 <= AVGC10.21) * 20 + ABS(AVGC5.21 > AVGC10.21) * (ABS(AVGC5.22 <= AVGC10.22) * 21 + ABS(AVGC5.22 > AVGC10.22) * (ABS(AVGC5.23 <= AVGC10.23) * 22 + ABS(AVGC5.23 > AVGC10.23) * (ABS(AVGC5.24 <= AVGC10.24) * 23 + ABS(AVGC5.24 > AVGC10.24) * (ABS(AVGC5.25 <= AVGC10.25) * 24 + ABS(AVGC5.25 > AVGC10.25) * (ABS(AVGC5.26 <= AVGC10.26) * 25 + ABS(AVGC5.26 > AVGC10.26) * (ABS(AVGC5.27 <= AVGC10.27) * 26 + ABS(AVGC5.27 > AVGC10.27) * (ABS(AVGC5.28 <= AVGC10.28) * 27 + ABS(AVGC5.28 > AVGC10.28) * (ABS(AVGC5.29 <= AVGC10.29) * 28 + ABS(AVGC5.29 > AVGC10.29) * (ABS(AVGC5.30 <= AVGC10.30) * 29 + ABS(AVGC5.30 > AVGC10.30) * (ABS(AVGC5.31 <= AVGC10.31) * 30 + ABS(AVGC5.31 > AVGC10.31) * (ABS(AVGC5.32 <= AVGC10.32) * 31 + ABS(AVGC5.32 > AVGC10.32) * (ABS(AVGC5.33 <= AVGC10.33) * 32 + ABS(AVGC5.33 > AVGC10.33) * (ABS(AVGC5.34 <= AVGC10.34) * 33 + ABS(AVGC5.34 > AVGC10.34) * (ABS(AVGC5.35 <= AVGC10.35) * 34 + ABS(AVGC5.35 > AVGC10.35) * (ABS(AVGC5.36 <= AVGC10.36) * 35 + ABS(AVGC5.36 > AVGC10.36) * (ABS(AVGC5.37 <= AVGC10.37) * 36 + ABS(AVGC5.37 > AVGC10.37) * (ABS(AVGC5.38 <= AVGC10.38) * 37 + ABS(AVGC5.38 > AVGC10.38) * (ABS(AVGC5.39 <= AVGC10.39) * 38 + ABS(AVGC5.39 > AVGC10.39) * (ABS(AVGC5.40 <= AVGC10.40) * 39 + ABS(AVGC5.40 > AVGC10.40) * (ABS(AVGC5.41 <= AVGC10.41) * 40 + ABS(AVGC5.41 > AVGC10.41) * (ABS(AVGC5.42 <= AVGC10.42) * 41 + ABS(AVGC5.42 > AVGC10.42) * (ABS(AVGC5.43 <= AVGC10.43) * 42 + ABS(AVGC5.43 > AVGC10.43) * (ABS(AVGC5.44 <= AVGC10.44) * 43 + ABS(AVGC5.44 > AVGC10.44) * (ABS(AVGC5.45 <= AVGC10.45) * 44 + ABS(AVGC5.45 > AVGC10.45) * (ABS(AVGC5.46 <= AVGC10.46) * 45 + ABS(AVGC5.46 > AVGC10.46) * (ABS(AVGC5.47 <= AVGC10.47) * 46 + ABS(AVGC5.47 > AVGC10.47) * (ABS(AVGC5.48 <= AVGC10.48) * 47 + ABS(AVGC5.48 > AVGC10.48) * (ABS(AVGC5.49 <= AVGC10.49) * 48 + ABS(AVGC5.49 > AVGC10.49) * (ABS(AVGC5.50 <= AVGC10.50) * 49 + ABS(AVGC5.50 > AVGC10.50) * 50)))))))))))))))))))))))))))))))))))))))))))))))))
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/17/2016 Posts: 48
|
Thanks Bruce... I can get rid of so many easy scans now.
Also, I want to create a column showing me when closing price crossed moving average 5. i.e. "Close Crossed Up MA5 - X Bars Ago". Exactly the same as above but now I want Close Price and MA5 instead of MA5 and MA10.
I will create a condition that shows Close Above MA5 and have a column showing the Close xOver MA5 (x bars back):
Please can you provide the indicator formula for:
When: closing price xOver Moving Average 5 (X Bars Back)
I will then use your implementation to make :
Close xOver MA10
Close xOver MA20
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Note that I didn't actually create an Indicator Formula for the number of bars since a crossover. The reason is that part of the work is already done checking for the moving averages being on the correct sides by the EasyScan. So all I did was count the number of bars since the moving averages were on the opposite sides of each other.
So I just did a replace in a text editor of AVGC5. with C and then AVGC5 with AVGC10 to produce the following for you price vs 5 period moving average formula out of the 5 period moving average vs 10 period moving average formula.
ABS(C1 > AVGC5.1) * (ABS(C2 <= AVGC5.2) + ABS(C2 > AVGC5.2) * (ABS(C3 <= AVGC5.3) * 2 + ABS(C3 > AVGC5.3) * (ABS(C4 <= AVGC5.4) * 3 + ABS(C4 > AVGC5.4) * (ABS(C5 <= AVGC5.5) * 4 + ABS(C5 > AVGC5.5) * (ABS(C6 <= AVGC5.6) * 5 + ABS(C6 > AVGC5.6) * (ABS(C7 <= AVGC5.7) * 6 + ABS(C7 > AVGC5.7) * (ABS(C8 <= AVGC5.8) * 7 + ABS(C8 > AVGC5.8) * (ABS(C9 <= AVGC5.9) * 8 + ABS(C9 > AVGC5.9) * (ABS(C10 <= AVGC5.10) * 9 + ABS(C10 > AVGC5.10) * (ABS(C11 <= AVGC5.11) * 10 + ABS(C11 > AVGC5.11) * (ABS(C12 <= AVGC5.12) * 11 + ABS(C12 > AVGC5.12) * (ABS(C13 <= AVGC5.13) * 12 + ABS(C13 > AVGC5.13) * (ABS(C14 <= AVGC5.14) * 13 + ABS(C14 > AVGC5.14) * (ABS(C15 <= AVGC5.15) * 14 + ABS(C15 > AVGC5.15) * (ABS(C16 <= AVGC5.16) * 15 + ABS(C16 > AVGC5.16) * (ABS(C17 <= AVGC5.17) * 16 + ABS(C17 > AVGC5.17) * (ABS(C18 <= AVGC5.18) * 17 + ABS(C18 > AVGC5.18) * (ABS(C19 <= AVGC5.19) * 18 + ABS(C19 > AVGC5.19) * (ABS(C20 <= AVGC5.20) * 19 + ABS(C20 > AVGC5.20) * (ABS(C21 <= AVGC5.21) * 20 + ABS(C21 > AVGC5.21) * (ABS(C22 <= AVGC5.22) * 21 + ABS(C22 > AVGC5.22) * (ABS(C23 <= AVGC5.23) * 22 + ABS(C23 > AVGC5.23) * (ABS(C24 <= AVGC5.24) * 23 + ABS(C24 > AVGC5.24) * (ABS(C25 <= AVGC5.25) * 24 + ABS(C25 > AVGC5.25) * (ABS(C26 <= AVGC5.26) * 25 + ABS(C26 > AVGC5.26) * (ABS(C27 <= AVGC5.27) * 26 + ABS(C27 > AVGC5.27) * (ABS(C28 <= AVGC5.28) * 27 + ABS(C28 > AVGC5.28) * (ABS(C29 <= AVGC5.29) * 28 + ABS(C29 > AVGC5.29) * (ABS(C30 <= AVGC5.30) * 29 + ABS(C30 > AVGC5.30) * (ABS(C31 <= AVGC5.31) * 30 + ABS(C31 > AVGC5.31) * (ABS(C32 <= AVGC5.32) * 31 + ABS(C32 > AVGC5.32) * (ABS(C33 <= AVGC5.33) * 32 + ABS(C33 > AVGC5.33) * (ABS(C34 <= AVGC5.34) * 33 + ABS(C34 > AVGC5.34) * (ABS(C35 <= AVGC5.35) * 34 + ABS(C35 > AVGC5.35) * (ABS(C36 <= AVGC5.36) * 35 + ABS(C36 > AVGC5.36) * (ABS(C37 <= AVGC5.37) * 36 + ABS(C37 > AVGC5.37) * (ABS(C38 <= AVGC5.38) * 37 + ABS(C38 > AVGC5.38) * (ABS(C39 <= AVGC5.39) * 38 + ABS(C39 > AVGC5.39) * (ABS(C40 <= AVGC5.40) * 39 + ABS(C40 > AVGC5.40) * (ABS(C41 <= AVGC5.41) * 40 + ABS(C41 > AVGC5.41) * (ABS(C42 <= AVGC5.42) * 41 + ABS(C42 > AVGC5.42) * (ABS(C43 <= AVGC5.43) * 42 + ABS(C43 > AVGC5.43) * (ABS(C44 <= AVGC5.44) * 43 + ABS(C44 > AVGC5.44) * (ABS(C45 <= AVGC5.45) * 44 + ABS(C45 > AVGC5.45) * (ABS(C46 <= AVGC5.46) * 45 + ABS(C46 > AVGC5.46) * (ABS(C47 <= AVGC5.47) * 46 + ABS(C47 > AVGC5.47) * (ABS(C48 <= AVGC5.48) * 47 + ABS(C48 > AVGC5.48) * (ABS(C49 <= AVGC5.49) * 48 + ABS(C49 > AVGC5.49) * (ABS(C50 <= AVGC5.50) * 49 + ABS(C50 > AVGC5.50) * 50)))))))))))))))))))))))))))))))))))))))))))))))))
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/17/2016 Posts: 48
|
Great, thanks a lot for the help.
I have two more requests:
1) First:
I'm using 4 SMA's for my charts, 5, 10, 20, 50.
I have two easy scans; Price Above SMA(5,10,20) and Price xUP SMA (5, 10, 20)
I want to create an "indicator Column" showing the "Price xUP SMA(5,10,20) - X Bars Back"; this will go with Price Above SMA(5,10,20) Easy Scan, and column to show me the crossover time.
I will then use your formula to add/remove/modify more SMA's if needed for future needs.
2) Secondly, a column for "Slow Stochastic K Crossover D - X Bars Back"
The Slow Stochastic (14,3) K Crossover D - X Bars Back
Formula Im using for K: STOC14.3
Formula Im using for D: AVG(STOC14.3,3)
Once again your help is deeply appreciated.
|
|
Registered User Joined: 3/17/2016 Posts: 48
|
QUOTE (usmansajid)
I have two easy scans; Price Above SMA(5,10,20) and Price xUP SMA (5, 10, 20)
For further information
My condition for Price XUp MA5,10,20 is:
(C > AVGC5 AND C> AVGC10 AND C> AVGC20) AND (AVGC20.1 >= C1)
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Are you looking for the %K being above the %D?
The following will check for how many bars ago price was at or below either the 5, 10 or 20 SMA will max at at 30 bars.
ABS(C1 > AVGC5.1 AND C1 > AVGC10.1 AND C1 > AVGC20.1) * (ABS(C2 <= AVGC5.2 OR C2 <= AVGC10.2 OR C2 <= AVGC20.2) + ABS(C2 > AVGC5.2 AND C2 > AVGC10.2 AND C2 > AVGC20.2) * (ABS(C3 <= AVGC5.3 OR C3 <= AVGC10.3 OR C3 <= AVGC20.3) * 2 + ABS(C3 > AVGC5.3 AND C3 > AVGC10.3 AND C3 > AVGC20.3) * (ABS(C4 <= AVGC5.4 OR C4 <= AVGC10.4 OR C4 <= AVGC20.4) * 3 + ABS(C4 > AVGC5.4 AND C4 > AVGC10.4 AND C4 > AVGC20.4) * (ABS(C5 <= AVGC5.5 OR C5 <= AVGC10.5 OR C5 <= AVGC20.5) * 4 + ABS(C5 > AVGC5.5 AND C5 > AVGC10.5 AND C5 > AVGC20.5) * (ABS(C6 <= AVGC5.6 OR C6 <= AVGC10.6 OR C6 <= AVGC20.6) * 5 + ABS(C6 > AVGC5.6 AND C6 > AVGC10.6 AND C6 > AVGC20.6) * (ABS(C7 <= AVGC5.7 OR C7 <= AVGC10.7 OR C7 <= AVGC20.7) * 6 + ABS(C7 > AVGC5.7 AND C7 > AVGC10.7 AND C7 > AVGC20.7) * (ABS(C8 <= AVGC5.8 OR C8 <= AVGC10.8 OR C8 <= AVGC20.8) * 7 + ABS(C8 > AVGC5.8 AND C8 > AVGC10.8 AND C8 > AVGC20.8) * (ABS(C9 <= AVGC5.9 OR C9 <= AVGC10.9 OR C9 <= AVGC20.9) * 8 + ABS(C9 > AVGC5.9 AND C9 > AVGC10.9 AND C9 > AVGC20.9) * (ABS(C10 <= AVGC5.10 OR C10 <= AVGC10.10 OR C10 <= AVGC20.10) * 9 + ABS(C10 > AVGC5.10 AND C10 > AVGC10.10 AND C10 > AVGC20.10) * (ABS(C11 <= AVGC5.11 OR C11 <= AVGC10.11 OR C11 <= AVGC20.11) * 10 + ABS(C11 > AVGC5.11 AND C11 > AVGC10.11 AND C11 > AVGC20.11) * (ABS(C12 <= AVGC5.12 OR C12 <= AVGC10.12 OR C12 <= AVGC20.12) * 11 + ABS(C12 > AVGC5.12 AND C12 > AVGC10.12 AND C12 > AVGC20.12) * (ABS(C13 <= AVGC5.13 OR C13 <= AVGC10.13 OR C13 <= AVGC20.13) * 12 + ABS(C13 > AVGC5.13 AND C13 > AVGC10.13 AND C13 > AVGC20.13) * (ABS(C14 <= AVGC5.14 OR C14 <= AVGC10.14 OR C14 <= AVGC20.14) * 13 + ABS(C14 > AVGC5.14 AND C14 > AVGC10.14 AND C14 > AVGC20.14) * (ABS(C15 <= AVGC5.15 OR C15 <= AVGC10.15 OR C15 <= AVGC20.15) * 14 + ABS(C15 > AVGC5.15 AND C15 > AVGC10.15 AND C15 > AVGC20.15) * (ABS(C16 <= AVGC5.16 OR C16 <= AVGC10.16 OR C16 <= AVGC20.16) * 15 + ABS(C16 > AVGC5.16 AND C16 > AVGC10.16 AND C16 > AVGC20.16) * (ABS(C17 <= AVGC5.17 OR C17 <= AVGC10.17 OR C17 <= AVGC20.17) * 16 + ABS(C17 > AVGC5.17 AND C17 > AVGC10.17 AND C17 > AVGC20.17) * (ABS(C18 <= AVGC5.18 OR C18 <= AVGC10.18 OR C18 <= AVGC20.18) * 17 + ABS(C18 > AVGC5.18 AND C18 > AVGC10.18 AND C18 > AVGC20.18) * (ABS(C19 <= AVGC5.19 OR C19 <= AVGC10.19 OR C19 <= AVGC20.19) * 18 + ABS(C19 > AVGC5.19 AND C19 > AVGC10.19 AND C19 > AVGC20.19) * (ABS(C20 <= AVGC5.20 OR C20 <= AVGC10.20 OR C20 <= AVGC20.20) * 19 + ABS(C20 > AVGC5.20 AND C20 > AVGC10.20 AND C20 > AVGC20.20) * (ABS(C21 <= AVGC5.21 OR C21 <= AVGC10.21 OR C21 <= AVGC20.21) * 20 + ABS(C21 > AVGC5.21 AND C21 > AVGC10.21 AND C21 > AVGC20.21) * (ABS(C22 <= AVGC5.22 OR C22 <= AVGC10.22 OR C22 <= AVGC20.22) * 21 + ABS(C22 > AVGC5.22 AND C22 > AVGC10.22 AND C22 > AVGC20.22) * (ABS(C23 <= AVGC5.23 OR C23 <= AVGC10.23 OR C23 <= AVGC20.23) * 22 + ABS(C23 > AVGC5.23 AND C23 > AVGC10.23 AND C23 > AVGC20.23) * (ABS(C24 <= AVGC5.24 OR C24 <= AVGC10.24 OR C24 <= AVGC20.24) * 23 + ABS(C24 > AVGC5.24 AND C24 > AVGC10.24 AND C24 > AVGC20.24) * (ABS(C25 <= AVGC5.25 OR C25 <= AVGC10.25 OR C25 <= AVGC20.25) * 24 + ABS(C25 > AVGC5.25 AND C25 > AVGC10.25 AND C25 > AVGC20.25) * (ABS(C26 <= AVGC5.26 OR C26 <= AVGC10.26 OR C26 <= AVGC20.26) * 25 + ABS(C26 > AVGC5.26 AND C26 > AVGC10.26 AND C26 > AVGC20.26) * (ABS(C27 <= AVGC5.27 OR C27 <= AVGC10.27 OR C27 <= AVGC20.27) * 26 + ABS(C27 > AVGC5.27 AND C27 > AVGC10.27 AND C27 > AVGC20.27) * (ABS(C28 <= AVGC5.28 OR C28 <= AVGC10.28 OR C28 <= AVGC20.28) * 27 + ABS(C28 > AVGC5.28 AND C28 > AVGC10.28 AND C28 > AVGC20.28) * (ABS(C29 <= AVGC5.29 OR C29 <= AVGC10.29 OR C29 <= AVGC20.29) * 28 + ABS(C29 > AVGC5.29 AND C29 > AVGC10.29 AND C29 > AVGC20.29) * (ABS(C30 <= AVGC5.30 OR C30 <= AVGC10.30 OR C30 <= AVGC20.30) * 29 + ABS(C30 > AVGC5.30 AND C30 > AVGC10.30 AND C30 > AVGC20.30) * 30)))))))))))))))))))))))))))))
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/17/2016 Posts: 48
|
Bruce, Thanks for the above formula.
Yes, I want to know how long the %K has been above the %D (in other words, how many bars ago did the %K Crossover %D)
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try the following Indicator Formula for your stochastic. It should max out at 20 bars.
ABS(STOC14.3.1 > AVG(STOC14.3.1,3)) * (ABS(STOC14.3.2 <= AVG(STOC14.3.2,3)) + ABS(STOC14.3.2 > AVG(STOC14.3.2,3)) * (ABS(STOC14.3.3 <= AVG(STOC14.3.3,3)) * 2 + ABS(STOC14.3.3 > AVG(STOC14.3.3,3)) * (ABS(STOC14.3.4 <= AVG(STOC14.3.4,3)) * 3 + ABS(STOC14.3.4 > AVG(STOC14.3.4,3)) * (ABS(STOC14.3.5 <= AVG(STOC14.3.5,3)) * 4 + ABS(STOC14.3.5 > AVG(STOC14.3.5,3)) * (ABS(STOC14.3.6 <= AVG(STOC14.3.6,3)) * 5 + ABS(STOC14.3.6 > AVG(STOC14.3.6,3)) * (ABS(STOC14.3.7 <= AVG(STOC14.3.7,3)) * 6 + ABS(STOC14.3.7 > AVG(STOC14.3.7,3)) * (ABS(STOC14.3.8 <= AVG(STOC14.3.8,3)) * 7 + ABS(STOC14.3.8 > AVG(STOC14.3.8,3)) * (ABS(STOC14.3.9 <= AVG(STOC14.3.9,3)) * 8 + ABS(STOC14.3.9 > AVG(STOC14.3.9,3)) * (ABS(STOC14.3.10 <= AVG(STOC14.3.10,3)) * 9 + ABS(STOC14.3.10 > AVG(STOC14.3.10,3)) * (ABS(STOC14.3.11 <= AVG(STOC14.3.11,3)) * 10 + ABS(STOC14.3.11 > AVG(STOC14.3.11,3)) * (ABS(STOC14.3.12 <= AVG(STOC14.3.12,3)) * 11 + ABS(STOC14.3.12 > AVG(STOC14.3.12,3)) * (ABS(STOC14.3.13 <= AVG(STOC14.3.13,3)) * 12 + ABS(STOC14.3.13 > AVG(STOC14.3.13,3)) * (ABS(STOC14.3.14 <= AVG(STOC14.3.14,3)) * 13 + ABS(STOC14.3.14 > AVG(STOC14.3.14,3)) * (ABS(STOC14.3.15 <= AVG(STOC14.3.15,3)) * 14 + ABS(STOC14.3.15 > AVG(STOC14.3.15,3)) * (ABS(STOC14.3.16 <= AVG(STOC14.3.16,3)) * 15 + ABS(STOC14.3.16 > AVG(STOC14.3.16,3)) * (ABS(STOC14.3.17 <= AVG(STOC14.3.17,3)) * 16 + ABS(STOC14.3.17 > AVG(STOC14.3.17,3)) * (ABS(STOC14.3.18 <= AVG(STOC14.3.18,3)) * 17 + ABS(STOC14.3.18 > AVG(STOC14.3.18,3)) * (ABS(STOC14.3.19 <= AVG(STOC14.3.19,3)) * 18 + ABS(STOC14.3.19 > AVG(STOC14.3.19,3)) * (ABS(STOC14.3.20 <= AVG(STOC14.3.20,3)) * 19 + ABS(STOC14.3.20 > AVG(STOC14.3.20,3)) * 20)))))))))))))))))))
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/17/2016 Posts: 48
|
Thanks a million Bruce
|
|
Registered User Joined: 7/2/2015 Posts: 2
|
Bruce - thanks, these formulae helped in answering a similar question, In my case, I was simply looking to determine whether a crossover had happened within a certain number of days,
For usiong this approach in a column value of a watch list, where the value is the number of days since the last crossover, there may be an error in this approach. I haven't proven this yet, but let me give a hypothetical example.
Suppose the crossover occurred more than one time in the period covered by the formula - say, for the 20 bar stochastic above. If a crossover had occurred 5 days ago and 12 days ago, I believe the result would be 17, the sum of the two, not 5, which is the desired answer.
I haven't thought about this enough to come up with a solution (for that matter, like I said, I haven't even proven it's a problem, but I'm pretty confident it is). Not sure if this can be done without an if/else or other conditional structure to bail out once the test condition has been met the first time, but I'll respond if I come up with something worthwhile.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Actually the formulas given above are designed in such a way that they shouldn't add together 5 and 12 to get 17. The formulas should return 5 ind ignore the cross from 12 bars ago.
This is because the formulas do in fact implement a primitive if/then type syntax using the the idea that placing an ABS() function around a Boolean (true or false) formula makes it return 1 when true and 0 when false when part of a formula which is designed to return a numeric value.
The tecnique is described in more detail in the following topic.
Days Since Last Peak (or other day-counting needs)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 7/2/2015 Posts: 2
|
Thanks - I didn't initially appreciate how well structured the nested parentheses are in these formulae. Vey nicely done within the language set, and this definitely gives the correct answer.
This is a great tehcnique to know!
|
|
Registered User Joined: 3/17/2008 Posts: 9
|
QUOTE (Bruce_L)
Please try the following Indicator Formula for your stochastic. It should max out at 20 bars.
ABS(STOC14.3.1 > AVG(STOC14.3.1,3)) * (ABS(STOC14.3.2 <= AVG(STOC14.3.2,3)) + ABS(STOC14.3.2 > AVG(STOC14.3.2,3)) * (ABS(STOC14.3.3 <= AVG(STOC14.3.3,3)) * 2 + ABS(STOC14.3.3 > AVG(STOC14.3.3,3)) * (ABS(STOC14.3.4 <= AVG(STOC14.3.4,3)) * 3 + ABS(STOC14.3.4 > AVG(STOC14.3.4,3)) * (ABS(STOC14.3.5 <= AVG(STOC14.3.5,3)) * 4 + ABS(STOC14.3.5 > AVG(STOC14.3.5,3)) * (ABS(STOC14.3.6 <= AVG(STOC14.3.6,3)) * 5 + ABS(STOC14.3.6 > AVG(STOC14.3.6,3)) * (ABS(STOC14.3.7 <= AVG(STOC14.3.7,3)) * 6 + ABS(STOC14.3.7 > AVG(STOC14.3.7,3)) * (ABS(STOC14.3.8 <= AVG(STOC14.3.8,3)) * 7 + ABS(STOC14.3.8 > AVG(STOC14.3.8,3)) * (ABS(STOC14.3.9 <= AVG(STOC14.3.9,3)) * 8 + ABS(STOC14.3.9 > AVG(STOC14.3.9,3)) * (ABS(STOC14.3.10 <= AVG(STOC14.3.10,3)) * 9 + ABS(STOC14.3.10 > AVG(STOC14.3.10,3)) * (ABS(STOC14.3.11 <= AVG(STOC14.3.11,3)) * 10 + ABS(STOC14.3.11 > AVG(STOC14.3.11,3)) * (ABS(STOC14.3.12 <= AVG(STOC14.3.12,3)) * 11 + ABS(STOC14.3.12 > AVG(STOC14.3.12,3)) * (ABS(STOC14.3.13 <= AVG(STOC14.3.13,3)) * 12 + ABS(STOC14.3.13 > AVG(STOC14.3.13,3)) * (ABS(STOC14.3.14 <= AVG(STOC14.3.14,3)) * 13 + ABS(STOC14.3.14 > AVG(STOC14.3.14,3)) * (ABS(STOC14.3.15 <= AVG(STOC14.3.15,3)) * 14 + ABS(STOC14.3.15 > AVG(STOC14.3.15,3)) * (ABS(STOC14.3.16 <= AVG(STOC14.3.16,3)) * 15 + ABS(STOC14.3.16 > AVG(STOC14.3.16,3)) * (ABS(STOC14.3.17 <= AVG(STOC14.3.17,3)) * 16 + ABS(STOC14.3.17 > AVG(STOC14.3.17,3)) * (ABS(STOC14.3.18 <= AVG(STOC14.3.18,3)) * 17 + ABS(STOC14.3.18 > AVG(STOC14.3.18,3)) * (ABS(STOC14.3.19 <= AVG(STOC14.3.19,3)) * 18 + ABS(STOC14.3.19 > AVG(STOC14.3.19,3)) * (ABS(STOC14.3.20 <= AVG(STOC14.3.20,3)) * 19 + ABS(STOC14.3.20 > AVG(STOC14.3.20,3)) * 20)))))))))))))))))))
Bruce
i jut saw this pcf on stoch up move great formula u made - would i just reverse the sign for the same counting of bars in d crossing over k
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Yes, just reversing the signs should work. There is a slightly shorter way to write this in TC2000 v17 however.
TrueInRow(STOC14.3.1 > AVG(STOC14.3.1,3), 20)
Version 17 PCF Capabilities
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/15/2018 Posts: 1
|
Hi Bruce,
Thanks for posting all this. I am looking for a column to show how many bars ago the moving average 2 crossed under the moving average 8. I was able to use the first formula you posted and changed the 5 to 2 and the 10 to 8, then I reversed the > to the < . However the count is off by a few days on almost all of them. Sometimes its off by 1 and others by 3 or 4 days.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If you are using TC2000 v18, then you can just use the following.
SinceTrue(XDOWN(AVGC2, AVGC8), 50)
Reversing this would be the following.
SinceTrue(XUP(AVGC2, AVGC8), 50)
Note that this assumes simple moving averages of price for both moving averages. If the moving averages are of say exponential or of something other than price (such as each other), then the number of bars will not be correct.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |