Registered User Joined: 10/7/2004 Posts: 23
|
I need help in writing a pcf that calculates the perecentage change of a moving averages that crosses above another moving average.
The moving averages am interested in measuring the percentage change are the Xavgc8 and avgc30.
Ex, chart NDX-X. On 8/14/2014 the 8exp crossed up above the 30sma, from that point onwards I want to measure the percentage change of the 8exp moving average from that positive crossover.
I plan on having a column on a watchlist of the NDX-X or S&P stocks to compare the best performing stocks since their positive crossover.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The following Condition Formula uses the techniques in the Days Since Last Peak (or other day-counting needs) topic to look back up to 60 bars for the cross. The calculations will break down with a divide by zero error if the cross happened further back than 60 bars.
100 * (XAVGC8 / (ABS(XAVGC8 > AVGC30 AND XAVGC8.1 <= AVGC30.1) * XAVGC8 + ABS(XAVGC8 <= AVGC30 OR XAVGC8.1 > AVGC30.1) * (ABS(XAVGC8.1 > AVGC30.1 AND XAVGC8.2 <= AVGC30.2) * XAVGC8.1 + ABS(XAVGC8.1 <= AVGC30.1 OR XAVGC8.2 > AVGC30.2) * (ABS(XAVGC8.2 > AVGC30.2 AND XAVGC8.3 <= AVGC30.3) * XAVGC8.2 + ABS(XAVGC8.2 <= AVGC30.2 OR XAVGC8.3 > AVGC30.3) * (ABS(XAVGC8.3 > AVGC30.3 AND XAVGC8.4 <= AVGC30.4) * XAVGC8.3 + ABS(XAVGC8.3 <= AVGC30.3 OR XAVGC8.4 > AVGC30.4) * (ABS(XAVGC8.4 > AVGC30.4 AND XAVGC8.5 <= AVGC30.5) * XAVGC8.4 + ABS(XAVGC8.4 <= AVGC30.4 OR XAVGC8.5 > AVGC30.5) * (ABS(XAVGC8.5 > AVGC30.5 AND XAVGC8.6 <= AVGC30.6) * XAVGC8.5 + ABS(XAVGC8.5 <= AVGC30.5 OR XAVGC8.6 > AVGC30.6) * (ABS(XAVGC8.6 > AVGC30.6 AND XAVGC8.7 <= AVGC30.7) * XAVGC8.6 + ABS(XAVGC8.6 <= AVGC30.6 OR XAVGC8.7 > AVGC30.7) * (ABS(XAVGC8.7 > AVGC30.7 AND XAVGC8.8 <= AVGC30.8) * XAVGC8.7 + ABS(XAVGC8.7 <= AVGC30.7 OR XAVGC8.8 > AVGC30.8) * (ABS(XAVGC8.8 > AVGC30.8 AND XAVGC8.9 <= AVGC30.9) * XAVGC8.8 + ABS(XAVGC8.8 <= AVGC30.8 OR XAVGC8.9 > AVGC30.9) * (ABS(XAVGC8.9 > AVGC30.9 AND XAVGC8.10 <= AVGC30.10) * XAVGC8.9 + ABS(XAVGC8.9 <= AVGC30.9 OR XAVGC8.10 > AVGC30.10) * (ABS(XAVGC8.10 > AVGC30.10 AND XAVGC8.11 <= AVGC30.11) * XAVGC8.10 + ABS(XAVGC8.10 <= AVGC30.10 OR XAVGC8.11 > AVGC30.11) * (ABS(XAVGC8.11 > AVGC30.11 AND XAVGC8.12 <= AVGC30.12) * XAVGC8.11 + ABS(XAVGC8.11 <= AVGC30.11 OR XAVGC8.12 > AVGC30.12) * (ABS(XAVGC8.12 > AVGC30.12 AND XAVGC8.13 <= AVGC30.13) * XAVGC8.12 + ABS(XAVGC8.12 <= AVGC30.12 OR XAVGC8.13 > AVGC30.13) * (ABS(XAVGC8.13 > AVGC30.13 AND XAVGC8.14 <= AVGC30.14) * XAVGC8.13 + ABS(XAVGC8.13 <= AVGC30.13 OR XAVGC8.14 > AVGC30.14) * (ABS(XAVGC8.14 > AVGC30.14 AND XAVGC8.15 <= AVGC30.15) * XAVGC8.14 + ABS(XAVGC8.14 <= AVGC30.14 OR XAVGC8.15 > AVGC30.15) * (ABS(XAVGC8.15 > AVGC30.15 AND XAVGC8.16 <= AVGC30.16) * XAVGC8.15 + ABS(XAVGC8.15 <= AVGC30.15 OR XAVGC8.16 > AVGC30.16) * (ABS(XAVGC8.16 > AVGC30.16 AND XAVGC8.17 <= AVGC30.17) * XAVGC8.16 + ABS(XAVGC8.16 <= AVGC30.16 OR XAVGC8.17 > AVGC30.17) * (ABS(XAVGC8.17 > AVGC30.17 AND XAVGC8.18 <= AVGC30.18) * XAVGC8.17 + ABS(XAVGC8.17 <= AVGC30.17 OR XAVGC8.18 > AVGC30.18) * (ABS(XAVGC8.18 > AVGC30.18 AND XAVGC8.19 <= AVGC30.19) * XAVGC8.18 + ABS(XAVGC8.18 <= AVGC30.18 OR XAVGC8.19 > AVGC30.19) * (ABS(XAVGC8.19 > AVGC30.19 AND XAVGC8.20 <= AVGC30.20) * XAVGC8.19 + ABS(XAVGC8.19 <= AVGC30.19 OR XAVGC8.20 > AVGC30.20) * (ABS(XAVGC8.20 > AVGC30.20 AND XAVGC8.21 <= AVGC30.21) * XAVGC8.20 + ABS(XAVGC8.20 <= AVGC30.20 OR XAVGC8.21 > AVGC30.21) * (ABS(XAVGC8.21 > AVGC30.21 AND XAVGC8.22 <= AVGC30.22) * XAVGC8.21 + ABS(XAVGC8.21 <= AVGC30.21 OR XAVGC8.22 > AVGC30.22) * (ABS(XAVGC8.22 > AVGC30.22 AND XAVGC8.23 <= AVGC30.23) * XAVGC8.22 + ABS(XAVGC8.22 <= AVGC30.22 OR XAVGC8.23 > AVGC30.23) * (ABS(XAVGC8.23 > AVGC30.23 AND XAVGC8.24 <= AVGC30.24) * XAVGC8.23 + ABS(XAVGC8.23 <= AVGC30.23 OR XAVGC8.24 > AVGC30.24) * (ABS(XAVGC8.24 > AVGC30.24 AND XAVGC8.25 <= AVGC30.25) * XAVGC8.24 + ABS(XAVGC8.24 <= AVGC30.24 OR XAVGC8.25 > AVGC30.25) * (ABS(XAVGC8.25 > AVGC30.25 AND XAVGC8.26 <= AVGC30.26) * XAVGC8.25 + ABS(XAVGC8.25 <= AVGC30.25 OR XAVGC8.26 > AVGC30.26) * (ABS(XAVGC8.26 > AVGC30.26 AND XAVGC8.27 <= AVGC30.27) * XAVGC8.26 + ABS(XAVGC8.26 <= AVGC30.26 OR XAVGC8.27 > AVGC30.27) * (ABS(XAVGC8.27 > AVGC30.27 AND XAVGC8.28 <= AVGC30.28) * XAVGC8.27 + ABS(XAVGC8.27 <= AVGC30.27 OR XAVGC8.28 > AVGC30.28) * (ABS(XAVGC8.28 > AVGC30.28 AND XAVGC8.29 <= AVGC30.29) * XAVGC8.28 + ABS(XAVGC8.28 <= AVGC30.28 OR XAVGC8.29 > AVGC30.29) * (ABS(XAVGC8.29 > AVGC30.29 AND XAVGC8.30 <= AVGC30.30) * XAVGC8.29 + ABS(XAVGC8.29 <= AVGC30.29 OR XAVGC8.30 > AVGC30.30) * (ABS(XAVGC8.30 > AVGC30.30 AND XAVGC8.31 <= AVGC30.31) * XAVGC8.30 + ABS(XAVGC8.30 <= AVGC30.30 OR XAVGC8.31 > AVGC30.31) * (ABS(XAVGC8.31 > AVGC30.31 AND XAVGC8.32 <= AVGC30.32) * XAVGC8.31 + ABS(XAVGC8.31 <= AVGC30.31 OR XAVGC8.32 > AVGC30.32) * (ABS(XAVGC8.32 > AVGC30.32 AND XAVGC8.33 <= AVGC30.33) * XAVGC8.32 + ABS(XAVGC8.32 <= AVGC30.32 OR XAVGC8.33 > AVGC30.33) * (ABS(XAVGC8.33 > AVGC30.33 AND XAVGC8.34 <= AVGC30.34) * XAVGC8.33 + ABS(XAVGC8.33 <= AVGC30.33 OR XAVGC8.34 > AVGC30.34) * (ABS(XAVGC8.34 > AVGC30.34 AND XAVGC8.35 <= AVGC30.35) * XAVGC8.34 + ABS(XAVGC8.34 <= AVGC30.34 OR XAVGC8.35 > AVGC30.35) * (ABS(XAVGC8.35 > AVGC30.35 AND XAVGC8.36 <= AVGC30.36) * XAVGC8.35 + ABS(XAVGC8.35 <= AVGC30.35 OR XAVGC8.36 > AVGC30.36) * (ABS(XAVGC8.36 > AVGC30.36 AND XAVGC8.37 <= AVGC30.37) * XAVGC8.36 + ABS(XAVGC8.36 <= AVGC30.36 OR XAVGC8.37 > AVGC30.37) * (ABS(XAVGC8.37 > AVGC30.37 AND XAVGC8.38 <= AVGC30.38) * XAVGC8.37 + ABS(XAVGC8.37 <= AVGC30.37 OR XAVGC8.38 > AVGC30.38) * (ABS(XAVGC8.38 > AVGC30.38 AND XAVGC8.39 <= AVGC30.39) * XAVGC8.38 + ABS(XAVGC8.38 <= AVGC30.38 OR XAVGC8.39 > AVGC30.39) * (ABS(XAVGC8.39 > AVGC30.39 AND XAVGC8.40 <= AVGC30.40) * XAVGC8.39 + ABS(XAVGC8.39 <= AVGC30.39 OR XAVGC8.40 > AVGC30.40) * (ABS(XAVGC8.40 > AVGC30.40 AND XAVGC8.41 <= AVGC30.41) * XAVGC8.40 + ABS(XAVGC8.40 <= AVGC30.40 OR XAVGC8.41 > AVGC30.41) * (ABS(XAVGC8.41 > AVGC30.41 AND XAVGC8.42 <= AVGC30.42) * XAVGC8.41 + ABS(XAVGC8.41 <= AVGC30.41 OR XAVGC8.42 > AVGC30.42) * (ABS(XAVGC8.42 > AVGC30.42 AND XAVGC8.43 <= AVGC30.43) * XAVGC8.42 + ABS(XAVGC8.42 <= AVGC30.42 OR XAVGC8.43 > AVGC30.43) * (ABS(XAVGC8.43 > AVGC30.43 AND XAVGC8.44 <= AVGC30.44) * XAVGC8.43 + ABS(XAVGC8.43 <= AVGC30.43 OR XAVGC8.44 > AVGC30.44) * (ABS(XAVGC8.44 > AVGC30.44 AND XAVGC8.45 <= AVGC30.45) * XAVGC8.44 + ABS(XAVGC8.44 <= AVGC30.44 OR XAVGC8.45 > AVGC30.45) * (ABS(XAVGC8.45 > AVGC30.45 AND XAVGC8.46 <= AVGC30.46) * XAVGC8.45 + ABS(XAVGC8.45 <= AVGC30.45 OR XAVGC8.46 > AVGC30.46) * (ABS(XAVGC8.46 > AVGC30.46 AND XAVGC8.47 <= AVGC30.47) * XAVGC8.46 + ABS(XAVGC8.46 <= AVGC30.46 OR XAVGC8.47 > AVGC30.47) * (ABS(XAVGC8.47 > AVGC30.47 AND XAVGC8.48 <= AVGC30.48) * XAVGC8.47 + ABS(XAVGC8.47 <= AVGC30.47 OR XAVGC8.48 > AVGC30.48) * (ABS(XAVGC8.48 > AVGC30.48 AND XAVGC8.49 <= AVGC30.49) * XAVGC8.48 + ABS(XAVGC8.48 <= AVGC30.48 OR XAVGC8.49 > AVGC30.49) * (ABS(XAVGC8.49 > AVGC30.49 AND XAVGC8.50 <= AVGC30.50) * XAVGC8.49 + ABS(XAVGC8.49 <= AVGC30.49 OR XAVGC8.50 > AVGC30.50) * (ABS(XAVGC8.50 > AVGC30.50 AND XAVGC8.51 <= AVGC30.51) * XAVGC8.50 + ABS(XAVGC8.50 <= AVGC30.50 OR XAVGC8.51 > AVGC30.51) * (ABS(XAVGC8.51 > AVGC30.51 AND XAVGC8.52 <= AVGC30.52) * XAVGC8.51 + ABS(XAVGC8.51 <= AVGC30.51 OR XAVGC8.52 > AVGC30.52) * (ABS(XAVGC8.52 > AVGC30.52 AND XAVGC8.53 <= AVGC30.53) * XAVGC8.52 + ABS(XAVGC8.52 <= AVGC30.52 OR XAVGC8.53 > AVGC30.53) * (ABS(XAVGC8.53 > AVGC30.53 AND XAVGC8.54 <= AVGC30.54) * XAVGC8.53 + ABS(XAVGC8.53 <= AVGC30.53 OR XAVGC8.54 > AVGC30.54) * (ABS(XAVGC8.54 > AVGC30.54 AND XAVGC8.55 <= AVGC30.55) * XAVGC8.54 + ABS(XAVGC8.54 <= AVGC30.54 OR XAVGC8.55 > AVGC30.55) * (ABS(XAVGC8.55 > AVGC30.55 AND XAVGC8.56 <= AVGC30.56) * XAVGC8.55 + ABS(XAVGC8.55 <= AVGC30.55 OR XAVGC8.56 > AVGC30.56) * (ABS(XAVGC8.56 > AVGC30.56 AND XAVGC8.57 <= AVGC30.57) * XAVGC8.56 + ABS(XAVGC8.56 <= AVGC30.56 OR XAVGC8.57 > AVGC30.57) * (ABS(XAVGC8.57 > AVGC30.57 AND XAVGC8.58 <= AVGC30.58) * XAVGC8.57 + ABS(XAVGC8.57 <= AVGC30.57 OR XAVGC8.58 > AVGC30.58) * (ABS(XAVGC8.58 > AVGC30.58 AND XAVGC8.59 <= AVGC30.59) * XAVGC8.58 + ABS(XAVGC8.58 <= AVGC30.58 OR XAVGC8.59 > AVGC30.59) * (ABS(XAVGC8.59 > AVGC30.59 AND XAVGC8.60 <= AVGC30.60) * XAVGC8.59)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - 1)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 10/7/2004 Posts: 23
|
Thanks Bruce, that works.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|