CCI formula help

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #234451 quote
    Malibu1
    Participant
    New

    Hi,

    I am looking to explore modifying the CCI indicator. Can someone help me with the actual code of the CCI.

    Here is the actual formula but I don’t know how turn this into code.

    CCI=.015×Mean DeviationTypical PriceMA

    where:

    Typical Price=i=1P((High+Low+Close)÷3)

    P=Number of periods

    MA=Moving AverageMoving Average=(i=1PTypical Price)÷P

    Mean Deviation=(i=1PTypical PriceMA)÷P

    Can anyone help me with this?

    TIA​

    #234459 quote
    Iván González
    Moderator
    Master

    Hi, here you have the code:

    // Calculation of Typical Price
    // typicalPrice = (High + Low + Close) / 3
    
    // Parameter for the number of periods
    periods = 20 // You can change this value according to your needs
    
    // Calculation of the Moving Average
    MA = Average[periods](typicalPrice)
    
    // Calculation of the Mean Deviation
    sumDeviation = 0
    FOR i = 0 TO periods - 1 DO
        sumDeviation = sumDeviation + Abs(typicalPrice[i] - MA)
    NEXT
    meanDeviation = sumDeviation / periods
    
    // Calculation of the CCI
    myCCI = (typicalPrice - MA) / (0.015 * meanDeviation)
    
    // Return the value of the CCI
    RETURN myCCI AS "CCI"
    
    druby and Malibu1 thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

CCI formula help


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
Malibu1 @malibu1 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
1 year, 7 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 06/28/2024
Status: Active
Attachments: No files
Logo Logo
Loading...