Announcement

Collapse
No announcement yet.

Syntax error???

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

  • Syntax error???

    Hi i'm using an efs for 34ema degrees and every time i load it i'm getting a syntax error for some reason can anyone help?
    Attached Files

  • #2
    this is the efs:

    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description 7532//

    //two arrays that you will need to maintain. The first array (aValues) is the list of price differences. The second
    //array (aDegree) is the list of degrees that corresponds to the values. You must always maintain exactly the same
    //number of elements in each array. So, in the arrays below, a price difference <= 1.0 equates to a degrees value of 2,
    //a price difference <= 2 equates to a degrees value of 3, etc. etc.
    aValues = new Array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
    aDegree = new Array( 1, 3, 10, 20, 21,21,22, 23,23,23, 23, 25, 30, 32, 35, 35, 38, 39, 42, 45 );

    //{{EFSWizard_Declarations

    var vEMA34_of_HLC3 = new MAStudy(34, 0, "HLC/3", MAStudy.EXPONENTIAL);
    var vLastAlert = -1;
    var nPlot;
    var nSign;
    var deg;
    var decPts;

    //}}EFSWizard_Declarations 12193


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(true);
    setStudyTitle("34 EMA Degrees");
    setCursorLabelName("34 EMA Degrees", 0);
    setCursorLabelName("EMAchg", 1);
    setCursorLabelName("nPlot", 2);
    setCursorLabelName("nSign", 3);
    setCursorLabelName("deg", 4);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarThickness(3, 0);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_INSTANTCOLORLINE,0);
    //}}EFSWizard_PreMain 30539

    }

    function main(decPts) {
    if(decPts==null)decPts=2

    if(getSymbol()=="es h4")
    decPts=2;
    if(getSymbol()=="6E H4")
    decPts=5;
    if(getSymbol()=="AB H4")
    decPts=3;
    if(getSymbol()=="ZB H4")
    decPts=3;
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    close() > vEMA34_of_HLC3.getValue(MAStudy.MA)
    ) onAction1()
    //}}EFSWizard_Expression_1 9296

    //{{EFSWizard_Expression_2
    else if (
    close() < vEMA34_of_HLC3.getValue(MAStudy.MA)
    ) onAction2();
    //}}EFSWizard_Expression_2 11350

    //}}EFSWizard_Expressions 38428


    factor=Math.pow(10,decPts)*1;
    text="Trade OK"
    if(deg<20)text="No Trade"
    drawTextAbsolute( 1, high()+5/factor, deg+" degree", Color.blue, null, Text.BOLD|Text.FRAME|Text.TOP, "Courier", 14, 1 );
    //drawTextAbsolute( 1, high()+1/factor, text, Color.blue, null, Text.BOLD|Text.FRAME|Text.TOP, "Courier", 14, 1 );


    //get value of MA this bar
    nVal1 = vEMA34_of_HLC3.getValue(MAStudy.MA, 0 );
    //get value of MA last bar
    nVal2 = vEMA34_of_HLC3.getValue(MAStudy.MA, -1 );

    //calculate the difference between the two
    factor=Math.pow(10,decPts)*1
    nDiff = ((nVal1 - nVal2)*factor-((nVal1 - nVal2)*factor)%1);
    nSign = nDiff>=0 ? 1.0 : -1.0 ;
    nDiff = Math.abs( nDiff );

    //walk through list of values and convert to degrees
    nPlot=0;
    for ( x=0; x<aValues.length; x++ ) {
    if ( nDiff<=aValues[x] ) {
    nPlot = aDegree[x];
    break;
    }
    }
    //debugPrintln("p="+nPlot+" s="+ nSign+" d="+ nDiff)
    deg=nPlot*nSign;

    //At this point, the variable 'nPlot' will contain the degrees value associated with the
    //price change of the MA over the last bar. 'nSign' will contain the sign of the value. So
    //the final value will always be nSign * nPlot. (eg., if nDegrees is 3 and nSign is -1.0 then the
    //final answer will be -1.0 * 3 which equals -3 degrees.

    //So, your code that uses the Degrees information would go here.



    //{{EFSWizard_Return
    return new Array(vEMA34_of_HLC3.getValue(MAStudy.MA),vEMA34_o f_HLC3.getValue(MAStudyMA)-vEMA34_of_HLC3.getValue(MAStudy.MA,-1), nPlot+"", nSign+"", deg+"");
    //}}EFSWizard_Return 5919

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    setBarFgColor(Color.aqua);
    if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1 24209

    //{{EFSWizard_Action_2
    function onAction2() {
    setBarFgColor(Color.maroon);
    if (vLastAlert != 2) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2 22305

    //}}EFSWizard_Actions 67343

    Comment


    • #3
      silverxx12
      Open the efs with the Editor and in line 119 change MAStudyMA to MAStudy.MA
      Alex

      Comment


      • #4
        thanks- one other question in the edit studies window theres something called ''decPTs'' and has the ability to change values what exactly is this ?

        Comment


        • #5
          silverxx12
          I believe it stands for "decimal points" ie how many decimals there are in the price of a specified symbol
          Alex

          Comment


          • #6
            i really dont understand this this ema is definitely not 0 degrees any suggestions?
            Attached Files

            Comment

            Working...
            X