CCI formula help

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #234451 quote
    Malibu1Malibu1
    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álezIván González
    Moderator
    Legend

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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álezIván González
2 years, 2 months ago.

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