Announcement

Collapse
No announcement yet.

CCI Strategy

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CCI Strategy

    File Name: CCI_Strategy.efs

    Description:
    CCI Strategy

    Formula Parameters:
    Slow moving average length 10
    Fast moving average length 20


    Notes:
    The Commodity Channel Index (CCI) is best used with markets that display cyclical or
    seasonal characteristics, and is formulated to detect the beginning and ending of these
    cycles by incorporating a moving average together with a divisor that reflects both possible
    and actual trading ranges. The final index measures the deviation from normal, which indicates
    major changes in market trend.

    To put it simply, the Commodity Channel Index (CCI) value shows how the instrument is trading
    relative to its mean (average) price. When the CCI value is high, it means that the prices are
    high compared to the average price; when the CCI value is down, it means that the prices are low
    compared to the average price. The CCI value usually does not fall outside the -300 to 300 range
    and, in fact, is usually in the -100 to 100 range.


    Download File:
    CCI_Strategy.efs



    EFS Code:
    PHP Code:
    /*********************************

    Provided By:  

        eSignal (Copyright c eSignal), a division of Interactive Data 
        Corporation. 2008. All rights reserved. This sample eSignal 
        Formula Script (EFS) is for educational purposes only and may be 
        modified and saved under a new file name.  eSignal is not responsible
        for the functionality once modified.  eSignal reserves the right 
        to modify and overwrite this EFS file with each new release.

    Description:        

        This study calculates CCI strategy

    Version:            1.0  09/30/2008

    Notes:

        The Commodity Channel Index (CCI) is best used with markets that display cyclical or 
        seasonal characteristics, and is formulated to detect the beginning and ending of these 
        cycles by incorporating a moving average together with a divisor that reflects both possible 
        and actual trading ranges. The final index measures the deviation from normal, which indicates 
        major changes in market trend.
        
        To put it simply, the Commodity Channel Index (CCI) value shows how the instrument is trading 
        relative to its mean (average) price. When the CCI value is high, it means that the prices are 
        high compared to the average price; when the CCI value is down, it means that the prices are low 
        compared to the average price. The CCI value usually does not fall outside the -300 to 300 range 
        and, in fact, is usually in the -100 to 100 range.

    Formula Parameters:                     Default:

        Slow moving average length          10
        Fast moving average length          20

    **********************************/

    var fpArray = new Array();
    var 
    bInit false;

    function 
    preMain() {
        
    setPriceStudy(false);
        
    setStudyTitle("CCI Strategy"); 
        
    setCursorLabelName("CCI MA Slow",0);
        
    setDefaultBarFgColor(Color.red,0);
        
    setCursorLabelName("CCI MA FAST",1);
        
    setDefaultBarFgColor(Color.blue,1);
        
    setColorPriceBars(true);
        
    setDefaultPriceBarColor(Color.grey);

        
    askForInput();
        var 
    0;
        
    fpArray[x] = new FunctionParameter("FastMA"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);        
            
    setDefault(10);
        }
        
        
    fpArray[x] = new FunctionParameter("SlowMA"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);        
            
    setDefault(20);
        }
    }

    var 
    xSMA null;
    var 
    xFMA null;

    function 
    main(FastMA,SlowMA) {

        var 
    nBarState getBarState();
        
        if(
    nBarState == BARSTATE_ALLBARS) {
            if (
    FastMA == nullFastMA 10;
            if (
    SlowMA == nullSlowMA 20;
        }
        
        if (
    bInit == false) {
            var 
    xCCI cci(10);
            if (
    xCCI == null) return;
            
    xSMA sma(SlowMAxCCI);
            
    xFMA sma(FastMAxCCI);
            
    bInit true;
        }

        if(
    getCurrentBarIndex()==0) return;
        
        var 
    nSMA xSMA.getValue(0);
        var 
    nFMA xFMA.getValue(0);
        
        if(
    nSMA nFMA && !Strategy.isLong()) 
            
    Strategy.doLong("Long"Strategy.CLOSEStrategy.THISBAR);

        if(
    nSMA nFMA && !Strategy.isShort()) 
            
    Strategy.doShort("Short"Strategy.CLOSEStrategy.THISBAR);

        if(
    Strategy.isLong())
                   
    setPriceBarColor(Color.lime);

        if(
    Strategy.isShort())
                
    setPriceBarColor(Color.red);

        return new Array(
    nSMAnFMA);

Working...
X