Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Different MACD Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thebernie
Posted : Friday, July 22, 2011 9:09:41 AM
Registered User
Joined: 7/23/2006
Posts: 132

Here’s a MACD with a few subtle changes:

1) The price data used is (H+L+C)/3 rather than the close. I find this makes a subtle improvement in the display of divergences.

2) You can plot a second long time frame MACD line on the same chart (hidden by default).

3) The histogram bars are colored based on the relationship to the previous bar vice the standard above/below zero line coloring.

4) The color of the main MACD line is white when the slope is positive and purple when negative.

Can the following Think Script be converted to anything that telechart can use?

declare lower;
 
input ShortTimeFrameFastLength = 7;
input ShortTimeFrameSlowLength = 28;
input STFMACDLength = 7;
input LongTimeFrameFastLength = 28;
input LongTimeFrameSlowLength = 112;
input LTFMACDLength = 5;
 
def fastAvg = ExpAverage(data = hlc3, length = ShortTimeFrameFastLength);
def slowAvg = ExpAverage(data = hlc3, length = ShortTimeFrameSlowLength);
 
plot STFValue = fastAvg - slowAvg;
STFValue.setLineWeight(2);
DEF STFslope = (STFValue-STFValue[1]);
DEF STFslopeColor = if(STFslope > 0.0,9,0);
STFValue.AssignValueColor(getColor(STFSlopeColor));
plot STFAvg = ExpAverage(data = STFValue, length = STFMACDLength);
STFAvg.SetDefaultColor(GetColor(8));
 
def LfastAvg = ExpAverage(data = hlc3, length = LongTimeFrameFastLength);
def LslowAvg = ExpAverage(data = hlc3, length = LongTimeFrameSlowLength);
plot LTFValue = LfastAvg - LslowAvg;
LTFValue.setDefaultColor(color.green);
LTFValue.hide();
 
plot Diff = STFvalue - STFavg;
diff.AssignValueColor(if diff >= diff[1] then Color.UPTICK else Color.DOWNTICK);
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetDefaultColor(GetColor(5));
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(0));
Bruce_L
Posted : Friday, July 22, 2011 9:50:16 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The coloring is not possible in either TeleChart 2007 or TC2000 version 12 (it is possible in StockFinder), but the actual indicator can be plotted in either program using the same basic formulas as for a regular MACD, but done for the High, Low and Close instead of just the Close, which are then added together and divided by three.

Understanding MACD

So an Exponential MACD 7,28 could be created with a Custom PCF Indicator using the following formula:

(XAVGH7 - XAVGH28 + XAVGL7 - XAVGL28 + XAVGC7 - XAVGC28) / 3

You could then just add a 7-Period Exponential Moving Average to the Custom PCF Indicator to get the signal line.

The second Exponential MACD 28,112 would require a second Custom PCF Indicator:

(XAVGH28 - XAVGH112 + XAVGL28 - XAVGL112 + XAVGC28 - XAVGC112) / 3

As with the first MACD, just add a 5-Period Exponential Moving Average to the second Custom PCF Indicator to get its signal line.

You will probably want to Scale the Custom PCF Indicators to be centered on zero. I do not know of a way to force them into the same scale however (again, it would be possible in StockFinder).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thebernie
Posted : Friday, July 22, 2011 8:50:13 PM
Registered User
Joined: 7/23/2006
Posts: 132
Not exactly what I was hoping for but thanks anyway.

Bernie
BobMc
Posted : Friday, July 22, 2011 9:24:42 PM
Registered User
Joined: 10/7/2004
Posts: 816
Bruce,
would you please post the SF code

Thanks
BobMc
Bruce_L
Posted : Monday, July 25, 2011 11:17:09 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You should be able to Open an attached Indicator directly into a running copy of StockFinder 5 (and save it from within StockFinder 5 if desired). You could also Save it to the \My Documents\StockFinder5\(Your Username)\My Indicators\ folder and then load it like you would any other Indicator (or Copy and Paste it there from wherever it Saves if you can't specify the destination directory when Saving).

Attachments:
Different MACD.sfIndRC - 16 KB, downloaded 651 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
BobMc
Posted : Monday, July 25, 2011 11:31:01 AM
Registered User
Joined: 10/7/2004
Posts: 816
Thanks Bruce

Regards
BobMc
Bruce_L
Posted : Monday, July 25, 2011 11:34:10 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-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.