Announcement

Collapse
No announcement yet.

barIndex of -1 returns same cci value as 0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • barIndex of -1 returns same cci value as 0

    Hi,
    When I change the barIndex form 0 to -1 for the cci I get the same value?

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("CCI");
    setCursorLabelName("CCI",0);
    setCursorLabelName("CCI last",1);
    setDefaultBarFgColor(Color.blue,0);
    setDefaultBarThickness(2,0);
    }

    var cbCCI_Var = 0;
    var cbCCI = 0;
    var nCCIPeriod = 14;
    var nCCISource = "hlc3()";

    function main() {

    cbCCI = cci(14,hlc3(),null,null,0);
    cbCCI_last = cci(14,hlc3(),null,null,-1);
    // cbCCI_Var = cci(14,nCCISource).toFixed(2)*1;

    var retArray = new Array(2);

    setBarFgColor(Color.blue, 0);
    setBarFgColor(Color.red, 1);
    retArray[0] = cbCCI;
    retArray[1] = cbCCI_last;

    return retArray;
    }

    Thanks
    Tom

  • #2
    Tom
    That is happening because the syntax used in the cci() functions in the following lines
    cbCCI = cci(14,hlc3(),null,null,0);
    cbCCI_last = cci(14,hlc3(),null,null,-1);

    is incorrect for what you are trying to accomplish.
    If you are not using the sym() or inv() parameters you do not need to add nulls as those parameters are optional. Furthermore if you were to use them they would need to be nested inside the hlc3() function.
    Try writing those two lines as follows
    cbCCI = cci(14,hlc3(),0);
    cbCCI_last = cci(14,hlc3(),-1);

    and you should get the expected results
    Alex

    Comment


    • #3
      Tom
      You may also want to see this post which provides a complete series of examples on how to implement the parameters in an efs2 function.
      Alex

      Comment


      • #4
        Thank You again Alexis.

        Your examples are very good and now I understand.

        Comment


        • #5
          Tom
          You are most welcome and thank you for the compliments.
          Alex

          Comment

          Working...
          X