Announcement

Collapse
No announcement yet.

Indicator modification problem

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

  • Indicator modification problem

    Hi all,
    I have been playing around with some of the code from the Super Indictator efs and at the same time trying to learn more about java script, but now I am stuck. I have gone over the code for the past hour and I have not made any progress. I am trying to make the put the CCI only into the Super indicator line, then later build other indicators in. Even if the indicator doesn't really work right with just the cci, what I am trying to understand is the concept for how to make it work. Right now when I try to run the code the window is just blank and the error window says the syntax is ok. Could someone take a look and tell me what I am missing? Thank you.

    Chris

    PHP Code:
    /*********************************************************
    Team Effort © March 2004                          
    Contributors Include:
    Alexis C. Montenegro, Dan Ferry, Steve Hare, 
    Use and/or modify this code freely. If you redistribute it
    please include this and/or any other comment blocks and a 
    description of any changes you make.                      
    **********************************************************/
    //There are no gaurantees!//
    //This is an expirement using the sum of 3 studies plotted by a Moving Average
    //with a few munipulations.// Please take LPL & HPH into consideration.
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Making the super indicator line that only contains the values from the CCI.

    =====================================================================*/

    var vCCI null
    var vcci0 null;
    var 
    cci0 null;
    var 
    vSum3 null;
    var 
    aSum null;

    function 
    preMain() {

        
    setPriceStudy(false);
        
    setStudyTitle("SuperDev");
        
    setCursorLabelName("superfib"0);
        
    setDefaultBarStyle(PS_SOLID0);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarThickness(20);
        
    setPlotType(PLOTTYPE_LINE0);
        
    addBand(70,PS_SOLID,1,Color.red);
        
    addBand(30,PS_SOLID,1,Color.green);
       
        
    //CCI
        
    var fp1 = new FunctionParameter("CCILength",FunctionParameter.NUMBER);
        
    fp1.setLowerLimit(1);fp1.setDefault(20);
        
        var 
    fp2 = new FunctionParameter("CCISource",FunctionParameter.STRING);
        
    fp2.addOption("Close"); fp2.addOption("High"); fp2.addOption("Low");fp2.addOption("Open");
        
    fp2.addOption("HL/2");fp2.addOption("HLC/3");fp2.setDefault("HLC/3");
       }
       
       function (
    CCILength,CCISource) {
       
       if (
    MALength == nullMALength 5;
       
       if (
    vCCI == nullvCCI = new CCIStudy(CCILength,CCISource);
       
       
    cci0=vCCI.getValue(MAStudy.MA)/3;
       
       if(
    cci0 == null);
       return;
       
       
    vSum3 = (cci0);
       
       if(
    vSum3==null)
       return;
       
       if(
    aSum == null) {
        
    aSum = new Array(MALength);
       }
       if (
    getBarState() == BARSTATE_NEWBAR) {
           
    aSum.pop();  
           
    aSum.unshift(vSum3);
        } else {
        
    aSum[0] = vSum3;
        }
        var 
    nSum 0;
        for (
    0MALength; ++i) {
         
    nSum += aSum[i];
        }
        
        var 
    vSMA nSum/MALength;
        
        if(
    vSMA>70)
        
    setBarFgColor(Color.red);
        if(
    vSMA<10)
        
    setBarFgColor(Color.lime);

        return 
    vSMA;
       } 

  • #2
    Chris,

    First problem that I see is that you do not have a main section. As a result you will not get any errors. Fixing that will allow you to start to seeing your problems. I know you do not want me to fix all of those, as you will miss out on recognizing problems with your efs.

    I have attached a copy of the efs, commented, with a copy of my trace debugging utility contained at the end. There are some examples as to how to use trace at the end of the efs and I have put a sample line in the code. The trace utility outputs a file in the C:\Program Files\eSignal\FormulaOutput directory and it will be named Trace Super Indicator.txt.

    This is an alternative to using the debugPrintln feature. I use both methods. debugPrintln is quick, Trace gives you a feel for program flow and how the efs processed data.

    Please post any questions you may have and either myself or another board member will be happy to help you out.

    Regards,
    Attached Files
    Last edited by Guest; 06-13-2004, 08:03 PM.

    Comment


    • #3
      Steve thank you for your reply. I have been studying one of your other post where you ran the trace utility, but I have not been able to get the trace to work on this indicator. I think I understand what it does, it calculates the indicator and the lines that don't return data are the ones that are broken. Is that right? If someone could take a look and tell me what I am missing that would be great. Thanks.

      Chris
      Attached Files

      Comment


      • #4
        Chris,

        Do you have the formula output window open? If you did, you would see that the efs is erroring out because I believe you still do not have the MALength variable defined. I will run in an hour or so.

        Steve

        Comment


        • #5
          Chris,

          Sorry it took a while, I lost power around 4:45 est and just got it back a little after 9 PM. Luckily, my new ups allowed me to save my work and post I was preparing.

          You did several things wrong. First, trace was a function which was supposed to be outside of main. You had modified it and placed it inside of main. That is a no - no.

          Another area that you made a mistake is that you put return; in multiple places. Do not do that, all that does is return you to the beginning of main, and you will not know it. Instead, use either debugPrintln or a trace statement to let you know what is going on. Keep the return statement at the end of the efs to return the variables back to the chart.

          Alex and I have made changes to the efs to make it work, then I used UltraEdit text editor to compare the working version versus yours. The working efs line is to the left (some are commented) seperated by a * and the line from the non working efs is to the right

          !> means the line was removed

          <! means the line was added

          PHP Code:

          Comparing
          C:\Program Files\eSignal\Formulas\Downloads\superdevtrace fixed by Alex and Steve.efs
          To
          C:\Program Files\eSignal\Formulas\Downloads\superdevtrace chris.efs
          =======
          2      //all these steps are placed below above the trace function  * //############ global variables required above premain #############
          3      * var barcount 0//added, use this with trace so you know where you are in the file output  * var tracedata = new Array();
          4      *   * var traceon true;//tracefile is only created if it is called, this is a flag to create file
                    
          !> var nStudy "find hi";
                    !> var    
          tracefile = new File("SuperTrace.txt");
                    !> 
          //############ global variables required above premain ############
          44      *    if (MALength == nullMALength 5;  *    if (MALength == nullMALength 5;trace ("47: "+trace);
          45     <!      trace ("45: ");
          47      *    if (vCCI == nullvCCI = new CCIStudy(CCILength,CCISource);  *    if (vCCI == nullvCCI = new CCIStudy(CCILength,CCISource);trace ("49: "+trace);
          48     <!      trace ("48: ");
          50      *    cci0=vCCI.getValue(CCIStudy.CCI)/3;trace ("50: cci0 = "+cci0);//error #1 - wrong study was called  *    cci0=vCCI.getValue(MAStudy.MA)/3;trace ("51: "+trace);
          52      *    //if(cci0 == null);trace ("53: "+trace); //error#2 - cci0 will be null  *    if(cci0 == null);trace ("53: "+trace);
          53      *    //return;  *    return;
          55      *    vSum3 cci0//no need for parenthesis  *    vSum3 = (cci0);
          57      *    //if(vSum3==null); //error #3 - vSum3 will be null  *    if(vSum3==null);
          58      *    //return;  *    return;
          64      *         barcount++  *        aSum.pop();trace ("65: "+trace);
          65      *         trace("66: barcount = "+barcount);  *        //aSum.unshift(vSum3);("66: "+trace);
          66     <!        aSum.pop();
          67     <!        aSum.unshift(vSum3);trace("67: vSum3 = "+vSum3); //error #4 - this is required to feed new value to the array
          69      *     aSum[0] = vSum3;trace("69: aSum[0] = "+aSum[0]); //error #5 - this is required to feed current value to array  *     //aSum[0] = vSum3;("65: "+trace);
          71      *     var nSum 0;trace("71: "); //error #6 - the variable was not declared   *     //var nSum = 0;("70: "+trace);
          78      *     if(vSMA>70){  *     if(vSMA>70)
          80      *             trace ("80: vSMA>70");  *     if(vSMA<10)
          81     <!         }
          82     <!     if(vSMA<10){
          84     <!             trace ("84: vSMA<10"); 
          You had MALength in the main statement. That is ok, since you evaluate for null, however, I would recommend defining it with a new FunctionParameter Section.

          You had a +trace in all the trace statements. trace is a function, not a variable as you were treating it within the parenthesis. I modified the trace statements to the correct construct.

          I put a newer trace routine in the code (the one I had previously put there) I noticed you took a trace routine from some other code of mine. It would have worked fine, this is just easier. I have to update some of my older code.

          Two comments. When you change things, you change a ton of things. This is a very bad habit. I strongly recommend you change one thing at a time and test them. That way if you get an error, you know exactly what caused the error. I usually put the date in the filename with an a,b,c, etc after the date to reflect the revision level. Additionally, save your modifications often as you succeed with your revisions.

          The second comment is that you may consider working on some simpler efs's.

          Attached is the file that Alex and I worked on. Alex fixed all the errors, I played with the trace statements and summarized the changes above in the PHP box. It has a trace output file renamed per your last efs.

          Regards,
          Last edited by Guest; 06-14-2004, 09:36 PM.

          Comment


          • #6
            ops

            forgot the file that we put together.

            here it is:
            Attached Files
            Last edited by Guest; 06-14-2004, 09:47 PM.

            Comment


            • #7
              THANK YOU so much Steve and Alex. I have learned so much on this project. I will start out with simpler efs' until I get a handle on JavaScript. I had forgotten about how often I had used the shotgun change method in the past when I can't figure something out. So again, thank you both for all your efforts.

              Best regards,
              Chris

              Comment

              Working...
              X