[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] AFL formula for CCI



PureBytes Links

Trading Reference Links

This isn't an exact match, I tried to check against the description in AB
help files but couldn't quite follow it.
I am missing something, just not certain what.

TP = (H+L+C)/3;
SMATP = MA(TP,20);
MD = MA(abs(TP - SMATP),20);
CCIx = (TP - SMATP) / (0.015 * MD);

Plot(CCIx,"CCIx",colorGreen,styleLine);
Plot(CCI(20),"CCI",colorRed,styleLine);

Cheers,
Graham
http://groups.msn.com/ASXShareTrading
http://groups.msn.com/FMSAustralia 

-----Original Message-----
From: Dave Merrill [mailto:dmerrill@xxxxxxx] 
Sent: Sunday, 12 October 2003 12:22 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] AFL formula for CCI


re the earlier discussion of using arrays as paremters to built-in
indicators, I need a version of the CCI that can take an array for its
period.

here's a description of how the 20-period CCI is calculated, from
StockCharts.com:
  1) Calculate today's Typical Price (TP) = (H+L+C)/3 where H = high; L =
low, and C = close.
  2) Calculate today's 20-day Simple Moving Average of the Typical Price
(SMATP).
  3) Calculate today's Mean Deviation. First, calculate the absolute value
of the difference between today's SMATP and the typical price for each of
the past 20 days. Add all of these absolute values together and divide by 20
to find the Mean Deviation.
  4) The final step is to apply the Typical Price (TP), the Simple Moving
Average of the Typical Price (SMATP), the Mean Deviation and a Constant
(.015) to the following formula:
	CCI = (Typical Price - SMATP) / (.015 x Mean Deviation)

according to my tests, this matches the built-in CCI exactly:
  MD = 0;	// MD is Mean Deviation
  for(i = 0; i < period; i++) {
    MD = MD + Abs(SMATP - Ref(avg, -i));
  }
  MD = MD / period;

can anyone see how to do the same thing with AFL array processing instead of
the loop?

thanks,

dave



Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/JYdFFC/XP.FAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/