Announcement

Collapse
No announcement yet.

Edit EFS to alerts

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

  • Edit EFS to alerts

    Hi Alex anyone,

    I have edited this EFS to the moving averages I would like to use however I would Like to be able to back test them and use them with pop up alerts, how would I go about editing them.

    Cheers

    W
    Attached Files

  • #2
    Hi Walton,

    Here is the stratage based on the MAs crossover. If you have any further questions or require additional assistance please let me know.

    Regards,
    Andy


    Code:
    /************************************************
    Alexis C. Montenegro © July 2003                          
    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.                      
    *************************************************/
    
    var vMA1 = null;
    var vMA2 = null;
    
    function preMain() {
    
        setPriceStudy(true);
        setStudyTitle("MAx2");
        setCursorLabelName("MA1", 0);
        setCursorLabelName("MA2", 1);
        setDefaultBarStyle(PS_SOLID, 0);
        setDefaultBarStyle(PS_SOLID, 1);
        setDefaultBarFgColor(Color.blue, 0);
        setDefaultBarFgColor(Color.red, 1);
        setDefaultBarThickness(1, 0);
        setDefaultBarThickness(1, 1);
        setPlotType(PLOTTYPE_LINE, 0);
        setPlotType(PLOTTYPE_LINE, 1);
        checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicMAx2.efs"); //Comment this line out if modifying the code
        
        var fp1 = new FunctionParameter("MA1Length", FunctionParameter.NUMBER);
    	fp1.setLowerLimit(1);		
    	fp1.setDefault(3); //Edit this value to set a new default
    	
    	var fp2 = new FunctionParameter("MA1Offset", FunctionParameter.NUMBER);
    	fp2.setDefault(0); //Edit this value to set a new default
    	
    	var fp3 = new FunctionParameter("MA1Source", FunctionParameter.STRING);
        fp3.setName("MA1Source");
    	fp3.addOption("Close");
    	fp3.addOption("High");
    	fp3.addOption("Low");
    	fp3.addOption("Open");
    	fp3.addOption("HL/2");
    	fp3.addOption("HLC/3");
    	fp3.addOption("OHLC/4");
    	fp3.setDefault("Close"); //Edit this value to set a new default	 
    	
    	var fp4 = new FunctionParameter("MA1Type", FunctionParameter.STRING);
    	fp4.setName("MA1Type");
    	fp4.addOption("MAStudy.SIMPLE");
    	fp4.addOption("MAStudy.EXPONENTIAL");
    	fp4.addOption("MAStudy.WEIGHTED");
    	fp4.addOption("MAStudy.VOLUMEWEIGHTED");
    	// HOS CHANGE fp4.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
    	fp4.setDefault("MAStudy.EXPONENTIAL"); //Edit this value to set a new default
    	
    	var fp5 = new FunctionParameter("MA2Length", FunctionParameter.NUMBER);
    	fp5.setLowerLimit(1);		
    	//HOS CHANGE fp5.setDefault(10); //Edit this value to set a new default
    	fp5.setDefault(18); //Edit this value to set a new default
    	
    	var fp6 = new FunctionParameter("MA2Offset", FunctionParameter.NUMBER);
    	fp6.setDefault(0); //Edit this value to set a new default
    	
    	var fp7 = new FunctionParameter("MA2Source", FunctionParameter.STRING);
    	fp7.setName("MA1Source");
    	fp7.addOption("Close");
    	fp7.addOption("High");
    	fp7.addOption("Low");
    	fp7.addOption("Open");
    	fp7.addOption("HL/2");
    	fp7.addOption("HLC/3");
    	fp7.addOption("OHLC/4");
    	fp7.setDefault("Close"); //Edit this value to set a new default
    	
    	var fp8 = new FunctionParameter("MA2Type", FunctionParameter.STRING);
    	fp8.setName("MA2Type");
    	fp8.addOption("MAStudy.SIMPLE");
    	fp8.addOption("MAStudy.EXPONENTIAL");
    	fp8.addOption("MAStudy.WEIGHTED");
    	fp8.addOption("MAStudy.VOLUMEWEIGHTED");
    	// HOS CHANGE fp8.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
    	fp8.setDefault("MAStudy.EXPONENTIAL"); //Edit this value to set a new default
    
    }
    
    function main(MA1Length,MA1Offset,MA1Source,MA1Type,MA2Length,MA2Offset,MA2Source,MA2Type) {
    
        var vHL = high() - low();
        var vVar = vHL * 0.25;
        var vAddVar = vVar * 0.35;
        
        if (vMA1 == null)
        	vMA1 = new MAStudy(MA1Length, MA1Offset, MA1Source, eval(MA1Type));
        if (vMA2 == null)
        	vMA2 = new MAStudy(MA2Length, MA2Offset, MA2Source, eval(MA2Type));
            
    /*****************************************
    Insert your code following this text block
    Use vMA1.getValue(MAStudy.MA) and         
    vMA2.getValue(MAStudy.MA) for your code   
    ******************************************/
    	if(vMA1.getValue(MAStudy.MA) > vMA2.getValue(MAStudy.MA) && !Strategy.isLong()){
    		Strategy.doLong("Long", Strategy.MARKET, Strategy.THISBAR);
    		drawShapeRelative(0, low() - vVar, Shape.UPARROW, "", Color.lime, null, "buyShp" + getValue("time"));
    		drawTextRelative(-1, low() - (vVar + vAddVar), "Buy", Color.black, Color.lime, Text.BOLD | Text.ONTOP, null, null, "buyTxt" + getValue("time"));
    	}
    	if(vMA1.getValue(MAStudy.MA) < vMA2.getValue(MAStudy.MA) && !Strategy.isShort()){
    		Strategy.doShort("Short", Strategy.MARKET, Strategy.THISBAR);
    				drawShapeRelative(0, high() + vVar, Shape.DOWNARROW, "", Color.red, null, "sellShp" + getValue("time"));
    		drawTextRelative(-1, high() + (vVar + vAddVar), "Sell", Color.black, Color.red, Text.BOTTOM | Text.BOLD | Text.ONTOP, null, null, "buyTxt" + getValue("time"));
    	}
    
    
        return new Array (vMA1.getValue(MAStudy.MA),vMA2.getValue(MAStudy.MA));
        
    }

    Comment


    • #3
      Thanks Andy,

      Cheers

      W

      Comment


      • #4
        Walton
        FYI if you do use the code Andy posted remember to comment out the line in preMain with checkVersion() else if the original gets updated you will be notified by EFS Auto Update that there is a new version of the efs which would not apply in this case.
        Alex

        Comment

        Working...
        X