PureBytes Links
Trading Reference Links
|
Just checked the CCI with a
couple of sources, and it seems correct even though Tomasz must use a slight
different version to that elsewhere.
/*
Add each period's High, Low, AND Close AND divide
this Sum by 3. This is the typical price.
Calculate an n-period simple moving average of the
typical prices computed in Step 1.
for each of the prior n-periods, subtract today's
Step 2 value from Step 1's value n days ago. for example, if you were
calculating a 5-Day CCI, you would perform five subtractions using today's Step
2 value.
Calculate an n-period simple moving average of the
absolute values of each of the results in Step 3.
Multiply the value in Step 4 by 0.015.
Subtract the value from Step 2 from the value in
Step 1.
Divide the value in Step 6 by the value in Step 5.
*/
n = <FONT face="Courier New"
color=#ff00ff>20<FONT
size=2>;
SMATP = <FONT face="Courier New"
color=#0000ff>MA(<FONT face="Courier New"
color=#ff0000>Avg,<FONT
face="Courier New">n);<FONT face="Courier New"
color=#008000>//1,2
MD = <FONT face="Courier New"
color=#0000ff>MA(
abs<FONT
size=2>(<FONT face="Courier New"
color=#ff0000>Avg - SMATP<FONT
face="Courier New">), n );<FONT face="Courier New"
color=#008000>//3,4
CCIx = (<FONT face="Courier New"
color=#ff0000>Avg - SMATP) / (<FONT
color=#ff00ff>0.015 * MD);<FONT
face="Courier New" color=#008000>//5,6,7<FONT
color=#0000ff>
Plot(CCIx,<FONT
color=#8b0000>"CCIx",<FONT
color=#ff0000>colorGreen,<FONT
color=#ff0000>styleLine);<FONT
color=#0000ff>
Plot(<FONT
color=#0000ff>CCI(<SPAN
class=786112106-12102003>n),<FONT
color=#8b0000>"CCI",<FONT
color=#ff0000>colorRed,<FONT
color=#ff0000>styleLine);
Cheers,Graham<A
href="">http://groups.msn.com/ASXShareTrading<A
href="">http://groups.msn.com/FMSAustralia
<FONT
face=Tahoma size=2>-----Original Message-----From: Graham
[mailto:gkavanagh@xxxxxxxxxxxxx] Sent: Sunday, 12 October 2003 1:46
PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker]
AFL formula for CCI
sorry that was
wrong
Cheers,Graham<A
href="">http://groups.msn.com/ASXShareTrading<A
href="">http://groups.msn.com/FMSAustralia
<FONT
face=Tahoma size=2>-----Original Message-----From: Graham
[mailto:gkavanagh@xxxxxxxxxxxxx] Sent: Sunday, 12 October 2003
1:39 PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE:
[amibroker] AFL formula for CCI
ok got
it
TP = (H<FONT
size=2>+L<FONT
size=2>+C<FONT
size=2>)/<FONT face="Courier New" color=#ff00ff
size=2>3;
SMATP = <FONT face="Courier New" color=#0000ff
size=2>MA(TP,<FONT color=#ff00ff
size=2>20);
MD = <FONT face="Courier New" color=#0000ff
size=2>MA(<FONT face="Courier New"
color=#0000ff size=2>MA(TP<FONT
face="Courier New" size=2>,<FONT face="Courier New" color=#ff00ff
size=2>20) -
SMATP,20);
CCIx = (TP - SMATP) / (<FONT color=#ff00ff
size=2>0.015 * MD);<FONT color=#0000ff
size=2>
Plot(CCIx,<FONT color=#8b0000
size=2>"CCIx",<FONT color=#ff0000
size=2>colorGreen,<FONT color=#ff0000
size=2>styleLine);<FONT color=#0000ff
size=2>
Plot(<FONT color=#0000ff
size=2>CCI(<FONT
face="Courier New" color=#ff00ff size=2>20<FONT
face="Courier New" size=2>),<FONT
color=#8b0000 size=2>"CCI",<FONT
color=#ff0000 size=2>colorRed,<FONT
color=#ff0000 size=2>styleLine<FONT
size=2>);
Cheers,Graham<A
href="">http://groups.msn.com/ASXShareTrading<A
href="">http://groups.msn.com/FMSAustralia
<FONT
face=Tahoma size=2>-----Original Message-----From: Dave Merrill
[mailto:dmerrill@xxxxxxx] Sent: Sunday, 12 October 2003 1:24
PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE:
[amibroker] AFL formula for CCI
<SPAN
class=806081305-12102003>thanks for jumping in graham.
<SPAN
class=806081305-12102003>
<SPAN
class=806081305-12102003>first, I think AB's Avg is (H+L+C)/3, so we don't
need to calculated it again.
<SPAN
class=806081305-12102003>
<SPAN
class=806081305-12102003>second, I think the problem we're both having is
the mean deviation code. my loop version sums, over 20 days, the
absolute values of the difference between TODAY'S SMATP and the typical
price of that day.
<SPAN
class=806081305-12102003>
<SPAN
class=806081305-12102003>this non-loop version is close, not the results
it gives, but conceptually:
<SPAN
class=806081305-12102003>
<SPAN
class=806081305-12102003> MD = Sum(Abs(SMATP - avg),
period);
<SPAN
class=806081305-12102003>
<SPAN
class=806081305-12102003>what's wrong I think is that for each day being
summed, it uses the SMATP value for that day, same as it uses the avg
value for that day. but as I said above, it needs the avg for each day,
but the SMATP value used should always be from the current day, the one
being calculated, not the value on each of the previous (Period)
days.
<SPAN
class=806081305-12102003>
<SPAN
class=806081305-12102003>any more ideas? not just you graham,
but anyone?
<SPAN
class=806081305-12102003>
<SPAN
class=806081305-12102003>dave
<BLOCKQUOTE
>This
isn't an exact match, I tried to check against the description in
ABhelp 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<A
href="">http://groups.msn.com/ASXShareTrading<A
href="">http://groups.msn.com/FMSAustralia
-----Original Message-----From: Dave Merrill
[mailto:dmerrill@xxxxxxx] Sent: Sunday, 12 October 2003 12:22
PMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] AFL formula
for CCIre the earlier discussion of using arrays as
paremters to built-inindicators, I need a version of the CCI that
can take an array for itsperiod.here's a description of how
the 20-period CCI is calculated, fromStockCharts.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 valueof the
difference between today's SMATP and the typical price for each
ofthe past 20 days. Add all of these absolute values together and
divide by 20to find the Mean Deviation. 4) The final step
is to apply the Typical Price (TP), the Simple MovingAverage 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 ofthe
loop?thanks,daveSend BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at:<A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to <A
href="">http://docs.yahoo.com/info/terms/
Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of
Service. Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Send
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Yahoo! Groups Sponsor
ADVERTISEMENT
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 the Yahoo! Terms of Service.
|