Announcement

Collapse
No announcement yet.

BuiltIn CCI Error Code

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

  • BuiltIn CCI Error Code

    Setting length on the BuiltIn CCI indicator to a number > 1000
    I get an error " line 40 parameter 1 invalid ". Why ?

  • #2
    Re: BuiltIn CCI Error Code

    huntergatherer
    That is likely due to some limitation set internally in the legacy CCIStudy() function.
    Use the customCCI formula that is in the EFS2 Custom folder and that does not appear to have this limitation
    Alex


    Originally posted by huntergatherer
    Setting length on the BuiltIn CCI indicator to a number > 1000
    I get an error " line 40 parameter 1 invalid ". Why ?

    Comment


    • #3
      I put some time into adding alerts to the builtinCCI. Everything was working fine until I ran into the limitation of 1000 bars that CCIStudy can use. Now I have to start over with the customCCI that uses array code.

      I can't get an alert to fire. Do I need a getvalue after xCCI.getValue???? < -100 or is it something else ?
      PHP Code:

      var fpArray = new Array();

      function 
      preMain() {
          
          
      setPriceStudy(false);
          
      setStudyTitle("CCI");
          
      setCursorLabelName("CCI"0);
          
      setDefaultBarFgColor(Color.blue0);
          
      setPlotType(PLOTTYPE_LINE,0);
          
      setDefaultBarThickness(1,0);
          
      askForInput();
          
          var 
      x=0;
          
      fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
          
      with(fpArray[x++]){
              
      setLowerLimit(1);        
              
      setDefault(20);
          }
          
      fpArray[x] = new FunctionParameter("Source"FunctionParameter.STRING);
          
      with(fpArray[x++]){
              
      addOption("open"); 
              
      addOption("high");
              
      addOption("low");
              
      addOption("close");
              
      addOption("hl2");
              
      addOption("hlc3");
              
      addOption("ohlc4"); 
              
      setDefault("close"); 
          }
          
      fpArray[x] = new FunctionParameter("Symbol"FunctionParameter.STRING);
          
      with(fpArray[x++]){
              
      setDefault();
          }
          
      fpArray[x] = new FunctionParameter("Interval"FunctionParameter.STRING);
          
      with(fpArray[x++]){
              
      setDefault();
          }
          
      fpArray[x] = new FunctionParameter("Upper"FunctionParameter.NUMBER);
          
      with(fpArray[x++]){
              
      setDefault(100); 
          }
          
      fpArray[x] = new FunctionParameter("Lower"FunctionParameter.NUMBER);
          
      with(fpArray[x++]){
              
      setDefault(-100); 
          }
          
      fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
          
      with(fpArray[x++]){
              
      setName("Show Parameters");
              
      setDefault(false);
          }
      }

      var 
      bInit false;
      var 
      xCCI null;
      var 
      vLastAlert null;

      function 
      main(Length,Source,Symbol,Interval,Upper,Lower,Params) {

          if(
      bInit == false){
              if(
      Symbol == nullSymbol getSymbol();
              if(
      Interval == nullInterval getInterval();
              var 
      vSymbol Symbol+","+Interval;
              
      xCCI cci(Length, eval(Source)(sym(vSymbol)));
              
              if(
      xCCI < -100 && vLastAlert != -1){
                      
      Alert.addToList(getSymbol(), "CCI is < -100"Color.whiteColor.blue);
                      
      Alert.playSound("beep.wav");
                      
      vLastAlert = -1;
                  }
                
                  
              if(
      xCCI 100 && vLastAlert != 1){
                      
      Alert.addToList(getSymbol(), "CCI is > 100"Color.whiteColor.blue);
                      
      Alert.playSound("beep.wav");
                      
      vLastAlert 1;
                  }
              
      addBandUpperPS_SOLID1Color.black,"Upper");
              
      addBandLowerPS_SOLID1Color.black,"Lower");
              
      setShowTitleParameters(eval(Params));
              
      bInit true;
          }

          return 
      getSeries(xCCI);

      Last edited by huntergatherer; 08-25-2010, 07:20 PM.

      Comment


      • #4
        huntergatherer
        One reason you are not getting any alerts is because your conditions are enclosed inside the bInit routine which is executed once only when the formula is first loaded in the chart [or after a Reload].
        You will need to move your conditions outside of that routine so that they are evaluated on each tick
        Also you need to use the getValue() method to retrieve the values of a Series Object. See this article in the EFS KnowledgeBase for general information on the Series Object and the available methods. See also this article in the EFS KnowledgeBase for information specific to the cci() function together with examples of its use
        Alex


        Originally posted by huntergatherer
        I put some time into adding alerts to the builtinCCI. Everything was working fine until I ran into the limitation of 1000 bars that CCIStudy can use. Now I have to start over with the customCCI that uses array code.

        I can't get an alert to fire. Do I need a getvalue after xCCI.getValue???? < -100 or is it something else ?
        PHP Code:

        var fpArray = new Array();

        function 
        preMain() {
            
            
        setPriceStudy(false);
            
        setStudyTitle("CCI");
            
        setCursorLabelName("CCI"0);
            
        setDefaultBarFgColor(Color.blue0);
            
        setPlotType(PLOTTYPE_LINE,0);
            
        setDefaultBarThickness(1,0);
            
        askForInput();
            
            var 
        x=0;
            
        fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
            
        with(fpArray[x++]){
                
        setLowerLimit(1);        
                
        setDefault(20);
            }
            
        fpArray[x] = new FunctionParameter("Source"FunctionParameter.STRING);
            
        with(fpArray[x++]){
                
        addOption("open"); 
                
        addOption("high");
                
        addOption("low");
                
        addOption("close");
                
        addOption("hl2");
                
        addOption("hlc3");
                
        addOption("ohlc4"); 
                
        setDefault("close"); 
            }
            
        fpArray[x] = new FunctionParameter("Symbol"FunctionParameter.STRING);
            
        with(fpArray[x++]){
                
        setDefault();
            }
            
        fpArray[x] = new FunctionParameter("Interval"FunctionParameter.STRING);
            
        with(fpArray[x++]){
                
        setDefault();
            }
            
        fpArray[x] = new FunctionParameter("Upper"FunctionParameter.NUMBER);
            
        with(fpArray[x++]){
                
        setDefault(100); 
            }
            
        fpArray[x] = new FunctionParameter("Lower"FunctionParameter.NUMBER);
            
        with(fpArray[x++]){
                
        setDefault(-100); 
            }
            
        fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
            
        with(fpArray[x++]){
                
        setName("Show Parameters");
                
        setDefault(false);
            }
        }

        var 
        bInit false;
        var 
        xCCI null;
        var 
        vLastAlert null;

        function 
        main(Length,Source,Symbol,Interval,Upper,Lower,Params) {

            if(
        bInit == false){
                if(
        Symbol == nullSymbol getSymbol();
                if(
        Interval == nullInterval getInterval();
                var 
        vSymbol Symbol+","+Interval;
                
        xCCI cci(Length, eval(Source)(sym(vSymbol)));
                
                if(
        xCCI < -100 && vLastAlert != -1){
                        
        Alert.addToList(getSymbol(), "CCI is < -100"Color.whiteColor.blue);
                        
        Alert.playSound("beep.wav");
                        
        vLastAlert = -1;
                    }
                  
                    
                if(
        xCCI 100 && vLastAlert != 1){
                        
        Alert.addToList(getSymbol(), "CCI is > 100"Color.whiteColor.blue);
                        
        Alert.playSound("beep.wav");
                        
        vLastAlert 1;
                    }
                
        addBandUpperPS_SOLID1Color.black,"Upper");
                
        addBandLowerPS_SOLID1Color.black,"Lower");
                
        setShowTitleParameters(eval(Params));
                
        bInit true;
            }

            return 
        getSeries(xCCI);

        Comment


        • #5
          I moved the conditionals outside the blnit block and set var nCCI to hold xCCI value but the only alert I get is if I use zero < or > in the conditional. The alert is cci is > than 0 even if the cci < 0. As far as I can tell I have everything as in the cci() specific link you gave for syntax.
          PHP Code:
          var fpArray = new Array();

          function 
          preMain() {
              
              
          setPriceStudy(false);
              
          setStudyTitle("CCI");
              
          setCursorLabelName("CCI"0);
              
          setDefaultBarFgColor(Color.blue0);
              
          setPlotType(PLOTTYPE_LINE,0);
              
          setDefaultBarThickness(1,0);
              
          askForInput();
              
              var 
          x=0;
              
          fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
              
          with(fpArray[x++]){
                  
          setLowerLimit(1);        
                  
          setDefault(27);
              }
              
          fpArray[x] = new FunctionParameter("Source"FunctionParameter.STRING);
              
          with(fpArray[x++]){
                  
          addOption("open"); 
                  
          addOption("high");
                  
          addOption("low");
                  
          addOption("close");
                  
          addOption("hl2");
                  
          addOption("hlc3");
                  
          addOption("ohlc4"); 
                  
          setDefault("hlc3"); 
              }
              
          fpArray[x] = new FunctionParameter("Symbol"FunctionParameter.STRING);
              
          with(fpArray[x++]){
                  
          setDefault();
              }
              
          fpArray[x] = new FunctionParameter("Interval"FunctionParameter.STRING);
              
          with(fpArray[x++]){
                  
          setDefault();
              }
              
          fpArray[x] = new FunctionParameter("Upper"FunctionParameter.NUMBER);
              
          with(fpArray[x++]){
                  
          setDefault(100); 
              }
              
          fpArray[x] = new FunctionParameter("Lower"FunctionParameter.NUMBER);
              
          with(fpArray[x++]){
                  
          setDefault(-100); 
              }
              
          fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
              
          with(fpArray[x++]){
                  
          setName("Show Parameters");
                  
          setDefault(false);
              }
          }

          var 
          bInit false;
          var 
          xCCI null;

          //var vLastAlert = null;

          function main(Length,Source,Symbol,Interval,Interval2,Upper,Lower,Params) {

              if(
          bInit == false){
                  if(
          Symbol == nullSymbol getSymbol();
                  if(
          Interval == nullInterval getInterval();
                  var 
          vSymbol Symbol+","+Interval;
                  
          xCCI cci(Length, eval(Source)(sym(vSymbol)));
                  
          addBandUpperPS_SOLID1Color.black,"Upper");
                  
          addBandLowerPS_SOLID1Color.black,"Lower");
                  
          setShowTitleParameters(eval(Params));
                  
          bInit true;
              }
              
              var 
          nCCI xCCI.getValue();
              
                  if(
          nCCI < -0){
                          
          Alert.addToList(getSymbol(), "CCI is < -100"Color.whiteColor.blue);
                          
          Alert.playSound("beep.wav");
                          
          //vLastAlert = -1;
                      
          }
                    
                      
                  if(
          nCCI >= 0){
                          
          Alert.addToList(getSymbol(), "CCI is > 100"Color.whiteColor.blue);
                          
          Alert.playSound("ding.wav");
                         
          // vLastAlert = 1;
                      
          }

              return 
          getSeries(xCCI);

          Comment


          • #6
            huntergatherer
            You omitted to include a 0 in xCCI.getValue() to retrieve the current value of the xCCI series
            Alex


            Originally posted by huntergatherer
            I moved the conditionals outside the blnit block and set var nCCI to hold xCCI value but the only alert I get is if I use zero < or > in the conditional. The alert is cci is > than 0 even if the cci < 0. As far as I can tell I have everything as in the cci() specific link you gave for syntax.
            PHP Code:
            var fpArray = new Array();

            function 
            preMain() {
                
                
            setPriceStudy(false);
                
            setStudyTitle("CCI");
                
            setCursorLabelName("CCI"0);
                
            setDefaultBarFgColor(Color.blue0);
                
            setPlotType(PLOTTYPE_LINE,0);
                
            setDefaultBarThickness(1,0);
                
            askForInput();
                
                var 
            x=0;
                
            fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
                
            with(fpArray[x++]){
                    
            setLowerLimit(1);        
                    
            setDefault(27);
                }
                
            fpArray[x] = new FunctionParameter("Source"FunctionParameter.STRING);
                
            with(fpArray[x++]){
                    
            addOption("open"); 
                    
            addOption("high");
                    
            addOption("low");
                    
            addOption("close");
                    
            addOption("hl2");
                    
            addOption("hlc3");
                    
            addOption("ohlc4"); 
                    
            setDefault("hlc3"); 
                }
                
            fpArray[x] = new FunctionParameter("Symbol"FunctionParameter.STRING);
                
            with(fpArray[x++]){
                    
            setDefault();
                }
                
            fpArray[x] = new FunctionParameter("Interval"FunctionParameter.STRING);
                
            with(fpArray[x++]){
                    
            setDefault();
                }
                
            fpArray[x] = new FunctionParameter("Upper"FunctionParameter.NUMBER);
                
            with(fpArray[x++]){
                    
            setDefault(100); 
                }
                
            fpArray[x] = new FunctionParameter("Lower"FunctionParameter.NUMBER);
                
            with(fpArray[x++]){
                    
            setDefault(-100); 
                }
                
            fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
                
            with(fpArray[x++]){
                    
            setName("Show Parameters");
                    
            setDefault(false);
                }
            }

            var 
            bInit false;
            var 
            xCCI null;

            //var vLastAlert = null;

            function main(Length,Source,Symbol,Interval,Interval2,Upper,Lower,Params) {

                if(
            bInit == false){
                    if(
            Symbol == nullSymbol getSymbol();
                    if(
            Interval == nullInterval getInterval();
                    var 
            vSymbol Symbol+","+Interval;
                    
            xCCI cci(Length, eval(Source)(sym(vSymbol)));
                    
            addBandUpperPS_SOLID1Color.black,"Upper");
                    
            addBandLowerPS_SOLID1Color.black,"Lower");
                    
            setShowTitleParameters(eval(Params));
                    
            bInit true;
                }
                
                var 
            nCCI xCCI.getValue();
                
                    if(
            nCCI < -0){
                            
            Alert.addToList(getSymbol(), "CCI is < -100"Color.whiteColor.blue);
                            
            Alert.playSound("beep.wav");
                            
            //vLastAlert = -1;
                        
            }
                      
                        
                    if(
            nCCI >= 0){
                            
            Alert.addToList(getSymbol(), "CCI is > 100"Color.whiteColor.blue);
                            
            Alert.playSound("ding.wav");
                           
            // vLastAlert = 1;
                        
            }

                return 
            getSeries(xCCI);

            Comment

            Working...
            X