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

macd's Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
seanyboy
Posted : Friday, December 10, 2004 3:48:29 PM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 14
i need to know if i can write a pcf identifying stocks that are coming off an oversold point. my settings are 9,42,15. i am plotting the macd as a histogram and by oversold i mean a reading showing the histogram bar at an extreme low. i would like to see stocks where the most current bar is alittle shorter than the preceding longer bar.
Craig_S
Posted : Friday, December 10, 2004 5:32:58 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
I would visually sort by your MACD histogram. After you sort by the indicator set it to ascending order and go to the top of the list. These stocks will be the ones making new lows. Space bar through them and you should have no trouble finding this pattern. Here is a video on visual sorting:

http://www.worden.com/training/default.aspx?g=posts&t=134

I would create an EasyScan with all your parameters for Volume and Price, etc. in it (to be sure the stocks you find are viable trades). You can also add these two PCFs to the scan to make sure the MACD bar today is not as low as the one yesterday:

Histogram (9,42,15) greater today than yesterday
((AVGC9 - AVGC42) - (((AVGC9 - AVGC42) + (AVGC9.1 - AVGC42.1) + (AVGC9.2 - AVGC42.2) + (AVGC9.3 - AVGC42.3) + (AVGC9.4 - AVGC42.4) + (AVGC9.5 - AVGC42.5) + (AVGC9.6 - AVGC42.6) + (AVGC9.7 - AVGC42.7) + (AVGC9.8 - AVGC42.8) + (AVGC9.9 - AVGC42.9) + (AVGC9.10 - AVGC42.10) + (AVGC9.11 - AVGC42.11) + (AVGC9.12 - AVGC42.12) + (AVGC9.13 - AVGC42.13) + (AVGC9.14 - AVGC42.14)) / 15)) > ((AVGC9.1 - AVGC42.1) - ((AVGC9.1 - AVGC42.1) + (AVGC9.2 - AVGC42.2) + (AVGC9.3 - AVGC42.3) + (AVGC9.4 - AVGC42.4) + (AVGC9.5 - AVGC42.5) + (AVGC9.6 - AVGC42.6) + (AVGC9.7 - AVGC42.7) + (AVGC9.8 - AVGC42.8) + (AVGC9.9 - AVGC42.9) + (AVGC9.10 - AVGC42.10) + (AVGC9.11 - AVGC42.11) + (AVGC9.12 - AVGC42.12) + (AVGC9.13 - AVGC42.13) + (AVGC9.14 - AVGC42.14) + (AVGC9.15 - AVGC42.15)) / 15)

Histogram (9,42,15) is below 0

((AVGC9 - AVGC42) - (((AVGC9 - AVGC42) + (AVGC9.1 - AVGC42.1) + (AVGC9.2 - AVGC42.2) + (AVGC9.3 - AVGC42.3) + (AVGC9.4 - AVGC42.4) + (AVGC9.5 - AVGC42.5) + (AVGC9.6 - AVGC42.6) + (AVGC9.7 - AVGC42.7) + (AVGC9.8 - AVGC42.8) + (AVGC9.9 - AVGC42.9) + (AVGC9.10 - AVGC42.10) + (AVGC9.11 - AVGC42.11) + (AVGC9.12 - AVGC42.12) + (AVGC9.13 - AVGC42.13) + (AVGC9.14 - AVGC42.14)) / 15)) < 0

Now visually sort the list in ascending order and let me know if this does what you wanted! I did it and noticed CBTI. Is the MACD on CBTI today a good example of what you are looking for?

- Craig
Here to Help!
Tanstaafl
Posted : Friday, December 10, 2004 11:26:28 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, Craig:

The PCF's you provided are are correct for a Simple-Moving-Average based MACDH, but do not even come close to the industry-standard exponential-MA-based MACD, which is almost universally accepted. Of course there is no "harm" in creating a simple-MA based formula, but it would not be generally accepted in the Technical Analysis community as a normal MACD.

Also, the form of the equations can be dramatically simplified and speeded up by using the XAvg() function ... or, if you really WANT simple MA's, using the Avg() function.

The formula for an exponential MACDH (MACD Histogram) is easy to do now, since TC has added the XAvgC and XAvg() functions to model exponential moving averages.

Here is the basis for it. The MACD is the difference of two XMA's (exponential moving averages) - for this example would be:
XAvgC9 - XAvgC45

The MACD Signal line is the XMA *of* the MACD. Conceptually, that would be:
XAvg( (XAvgC9 - XAvgC45), 15 )
However TC does not permit complex expressions to be used as arguments in the XAvg() function, so you need to apply the Distributive property. This yields a completely legit and totally equivalent formula for the signal line that CAN be used in TC:
XAvg(XAvgC9,15)-XAvg(XAvgC42,15)

But there is one small problem with this. There is a bug in the current-release's XAvg() function that creates excess error unless one simple rule is followed: when nesting two XAvg functions, always put the highest value in the innermost XAvg. There is a good, solid explanation why this adequately circumvents the bug, but that's beyond the scope of this discussion. I've explained it extensively in my TC-Net club - feel free to take a gander if you are interested.

This "Commutative" rule for nested moving averages is totally legit, mathematically. Therefore we can use it to get around the bug and produce a good TC-able Signal line equation:
XAvg(XAvgC15,9)-XAvg(XAvgC42,15)

Finally, the MACD Histo (MACDH) equation is:
MACD - MACD Signal ... or:
XAvgC9 - XAvgC45 - ( XAvg(XAvgC15,9)-XAvg(XAvgC42,15) )

I encourage everyone to TRY OUT this formula to see its accuracy in TC. Copy and paste it as a Custom indicator into TC, with center-zero-line checked, and on the same pane plot the 9,45,15 exponential MACD Histo using TC's native tool ... you will see that the values are virtually identical.

Here's the same formula, for yesterday:
XAvgC9.1-XAvgC42.1 - ( XAvg(XAvgC15.1,9)-XAvg(XAvgC42.1,15) )

The PCF for Today > Yesterday is therefore obvious:
XAvgC9-XAvgC42 - ( XAvg(XAvgC15,9)-XAvg(XAvgC42,15) )
> XAvgC9.1-XAvgC42.1 - ( XAvg(XAvgC15.1,9)-XAvg(XAvgC42.1,15) )

And the PCF for Today < 0 is also obvious:
XAvgC9-XAvgC42 - ( XAvg(XAvgC15,9)-XAvg(XAvgC42,15) ) < 0

This methodology works for any combination of MACDH parameters, but BE SURE to use the commutative rule above to keep the highest value innermost in the nested Signal calc.

I hope this helps!


seanyboy
Posted : Tuesday, December 14, 2004 1:04:34 PM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 14
hi craig.......yes you were helpful.......i need some guidance on how to write such pcf's........please contact me via my on file email address........
Craig_S
Posted : Tuesday, December 14, 2004 1:08:52 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
seanyboy,

We do not offer support for PCF writing via email. We only offer limited support over these boards. By limiting the support to the boards we allow others to benefit from your questions and our solutions. Feel free to ask for more here.

- Craig
Here to Help!
seanyboy
Posted : Tuesday, December 14, 2004 1:10:37 PM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 14
hi tanstaafl......thanks for your thoughts as well......i am a tc2000 user so ido not have access to your club but would welcome any guidance on how to write these types of pcf's.........i often have trading ideas but am not able to express them in pcf formula's .........
Tanstaafl
Posted : Tuesday, December 14, 2004 2:14:21 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi Sean: (I presume that's your "real" name :~)

The original description you provided is a little bit too general to pin down precisely into a PCF (presuming that you do have more unstated precision in mind ;~)

I trust that you can follow the explanation of how the XMA-based MACDH is modelled, and can plug in your own parameters.

The real "sticky wicket" is your phrase: "at an extreme low". The rest of it is pretty easy.

So, for the easy part first, you probably want:

MACDH(9,42,15) today > MACDH(9,42,15) yesterday
and
MACDH(9,42,15) < 0

I trust that you can plug the param's into the formulae above to flesh this out (it would be "healthier" if you give it a go on your own :~)

The difficult part is determining just WHAT "an extreme low" value is, since the MACD and the MACDH are "unbounded" indicators - their values differ widely for different symbols and historical periods, so it is not possible to set "fixed" oversold/bought thresholds like you can with RSI or Stochastics.

The best way to solve your problem would be to compare the MACDH to the Min(MACDH,100) or something like that. Unfortunately, TC does not allow complex expressions in its Min() function, and since it also does not offer an internal MACDH function, you're outa luck using that method. Hopefully in the future it will have more flexibility.

So, whaddaya do?

My approach is to wrap Bollinger Bands around the MACDH (or MACD), to provide a statistically-based "dynamic" threshold value.

To do this on a TC chart, you gotta know a trick (for the current version). The plotted MACDH (ie the bar graph) MUST have a 1-day Rate of Change Child attached to it, before trying to attach any other Child indicators. That is,

MACDH(9,42,15) as histogram
... ROC(1) as thin line
...... Bollinger Band (periods, width)
...... any other desired child indicator

Once you have that plotted, you can use SortBy Comparison on the Bollinger Band to isolate cases where the MACDH is near to that dynamic lower limit (i.e. values near -100 or lower).

"But", you may say, "I wanted this to be automated with a PCF and scan!"

Well, as you can imagine, that too is do-able ... you can write a PCF that determines the lower BB envelope value of a given MACDH ... but it is definitely nontrivial.

I suggest that you set up the MACDH and BB envelope on the chart and play with the BB param's to find something that YOU think will be a good setting for the "min" thresholds. I suggest you start with a BB periods setting equal to the largest of the first two MACDH parameters (for your example, that would be 42), and a BB width of between 15 and 20 (=1.5 to 2.0 std.dev's)

I hope this helps.

Jim Dean


seanyboy
Posted : Wednesday, December 15, 2004 6:58:02 AM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 14
hi jim.......thanks for all your thought on my behalf......i am going to work with your suggestions and see what i come up with.......my goal is to be able to write these types of pcf's that i believe will uncover many opportunities in the markets......thanks again!!
Tanstaafl
Posted : Wednesday, December 15, 2004 7:08:06 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
You're welcome! I hope this gets you fired up and on your way to doing this kind of thing on your own.

Jim Dean

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.