Registered User Joined: 11/7/2012 Posts: 5
|
Hi, I'm struggling with the following:
I have created an indicator (and a scan of it) that looks like ((C-C1)> etc etc) and I have that indicator on my chart.
1) How would I scan for such an event not today but within say the last 10,20 or 30 days etc please?
2) The second question is that I want to then add to the above a second conditon of proximity to a moving average, and have found on the forum this formula which I think is what I need?
ABS(C / AVGC200 - 1) <= .01
this apparently show prices between 99-101% of the 200 day MA. So I can substitute the '200' for the MA I want but if i wanted to play around with the percentages either side do I just change the '0.01' to say .02 for 2% either side? i.e. can you only search for equal deviations each side?
Lastly, what is the logic of the '-1' after the AVGC200 for future refence please?
Thank you.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If the condition can be expressed as a Condition Formula, you can use the Condition Formula as the Boolean Formula in a Custom PCF % True Indicator. You could then set the Average Type of the Custom PCF % True Indicator to Simple with the Period of the Custom PCF % True Indicator being the number of bars over which you wish to check if the Condition was true.
Adding and Moving Indicators
If the Boolean Formula is not true at all, the Custom PCF % True Indicator will return 0, otherwise it will return a value greater than zero. This means you can click on the Custom PCF % True Indicator and select Create Scan Condition to create a Condition checking for a value greater than 0 to check if the Boolean Formula was true at least once over the period and greater than 99.9 to check if the Boolean Formula was true for all of the bars during the period.
Create Conditions from Your Chart
The most common way to write a formula for the percent difference between price and its moving average is:
100 * (C - AVGC200) / AVGC200
If you convert this to:
100 * (C / AVGC200 - AVGC200 / AVGC200)
You can simplify it to:
100 * (C / AVGC200 - 1)
Or:
100 * C / AVGC200 - 100
The 1 or 100 at the end of these formulas represents 1 times AVGC200 or 100% of AVGC200.
Now let's take a look at other formula:
ABS(C / AVGC200 - 1) <= .01
The 1 in this formula still represents 1 times AVGC200. The .01 at the end of the formula is 1% because we haven't multiplied the whole thing by 100. So we can change the .01 to .02 to check for being 2% away from AVGC200 instead of 1%.
If we want the center of the range to be something other than 1 * AVGC200, we can change the - 1 in the middle of the formula to something else. For example, let's say we wanted to check for price being between 95% of the moving average and 101% of the moving average. We could write this as:
.95 * AVGC200 <= C AND C <= 1.01 * AVGC200
But we could also figure out where the center of this range is (.95 + 1.01) / 2 = .98 and use this as the center formula. Since (1.01 - .95) / 2 = .03, we would need to check for price being within .03 of this center. So the following Condition Formula would return the same result:
ABS(C / AVGC200 - .98) <= .03
PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!
-Bruce Personal Criteria Formulas TC2000 Support Articles
|