| 
 PureBytes Links 
Trading Reference Links 
 | 
Hi,
As an exercise to get used to Amibroker's AFL language, I thought I 
would take a description of how to calculated a CCI(20) and code it 
up myself to compare against Amibroker's built-in CCI() indicator.  
My results are different than Amibroker's.  Could someone please 
take the following, place it in an exploration and tweak it to get 
it to match Tomasz's  CCI?  
Thanks!
Steve
P.S. I used the description from stockcharts.com because Tomasz's 
description did not mention taking an absolute value in one step and 
the mention of taking 0.015 as a multiplier was mentioned twice 
which confused me.   Here is the stockcharts.com link:
http://www.stockcharts.com/education/IndicatorAnalysis/indic_CCI.html
-------------------------------------------------
Filter = 1; /* all symbols and quotes accepted */ 
// Calculate the last period's Typical Price 
// (TP) = (H+L+C)/3 where H = High, L = Low, AND C = Close. 
// In Amibroker, the built-in symbol Avg is the same as TP.
TP = Avg;
// Calculate the 20-period Simple Moving Average of the 
// Typical Price (SMATP)
SMATP = MA(TP, 20);
// Calculate the Mean Deviation. First, calculate the absolute value
// of the difference between the last period's SMATP AND the typical 
// price for each of the past 20 periods. Add all of these absolute 
// values together AND divide by 20 to find the Mean Deviation. 
MeanDiff = TP - SMATP;
MD = MA(abs(MeanDiff), 20);
// 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) / (0.015 * Mean Deviation)
//
myCCI = MeanDiff / (0.015 * MD);
AddColumn(High,"High",1.2);
AddColumn(Low,"Low",1.2);
AddColumn(Close,"Close",1.2);
AddColumn(Avg, "TP", 1.2);
AddColumn(SMATP, "SMATP(20)", 1.2);
AddColumn(MeanDiff, "MeanDiff", 1.2);
AddColumn(MyCCI, "MyCCI(20)", 1.2);
AddColumn(CCI(20), "CCI(20)", 1.2);
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 
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Yahoo! Groups Links
To visit your group on the web, go to:
 http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:
 amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 
 
 |