Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

MA crossing up X-number of bars ago Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Siddharth
Posted : Thursday, January 31, 2013 5:47:42 PM
Registered User
Joined: 10/7/2004
Posts: 9

Hi Bruce,

I have not been able to figure out how i could write a formula so that the scan gives me results of crossover five days ago. I have a scan that give me 1MA crossing up 17MA. But i want this as of five bars ago. Will you please kindly help? Sorry if i am not very articulate in telling you!!! Thanks!

Bruce_L
Posted : Friday, February 1, 2013 8:43:09 AM


Worden Trainer

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

I don't know the specifics of the formula you are using, but one way to create a formula for price crossing up through its 17-Period Simple Moving Average between the previous bar and the current bar would be:

C > AVGC17 AND C1 <= AVGC17.1

Note that the part of the formula for the current bar has no bars ago parameters in use while the part of the formula representing the previous bar uses 1 for both the bars ago parameter for price and the bars ago parameter for the moving average.

Now if we want to get the same results for 5-bars ago, we need to add 5 to the bars ago parameters for both parts of the formula. This will mean we will use 5 as the bars ago parameter for the first part and 6 for the bars ago parameter in the second part:

C5 > AVGC17.5 AND C6 <= AVGC17.6

The actual specifics of your particular formula might be different, but the basic technique would remain the same. Let's say we had used the AVG() function throughout the formula. The original would have been:

AVG(C, 1) > AVG(C, 17) AND AVG(C1, 1) <= AVG(C1, 17)

Note that the bars ago parameter is applied to the close as the AVG() function itself does not have a bars ago parameter. This means converting this formula would result in:

AVG(C5, 1) > AVG(C5, 17) AND AVG(C6, 1) <= AVG(C6, 17)

PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.