Announcement

Collapse
No announcement yet.

BtMovingAverage2.efs

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BtMovingAverage2.efs

    File Name: BtMovingAverage2.efs

    Description:
    Modified from eSignal/Formulas/BackTesting/BtMovingAverage.efs. Shows examples for how to use: drawLineRelative(), drawTextRelative(), drawShapeRelative() and drawImageRelative().

    Formula Parameters:
    None.

    Notes:
    This formula is also compatible with the Strategy Analyzer for Back Testing.

    Download File:
    BtMovingAverage2.efs




    EFS Code:
    PHP Code:
    /*******************************
    Provided By : eSignal. (c) Copyright 2003
    *******************************/
    var study = new MAStudy(100"Close"MAStudy.SIMPLE);

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Draw Lines, Text, Shapes and Images.");
    }

    var 
    vHigh;
    var 
    vLow;
    var 
    BarCntr 0;
    function 
    main() {
        var 
    study.getValue(MAStudy.MA);

        if(
    == null)
            return;

        if (
    getBarState() == BARSTATE_NEWBAR
            
    BarCntr +=1;
        
        
    vHigh high();
        
    vLow low();
        for (
    020; ++i) {
            
    vHigh Math.max(high(-i), vHigh);
            
    vLow Math.min(low(-i), vLow);
        }

        
    drawLineRelative(-20vHigh0vHighPS_SOLID2Color.red"High");
        
    drawLineRelative(-20vLow0vLowPS_SOLID2Color.green"Low");

        var 
    space 1;
        if (
    getInterval() != "D")
            
    space high() - low();
        
        if(
    close() >= v) {
            if(!
    Strategy.isLong()) {
                
    drawShapeRelative(0low(), Shape.UPARROWnullColor.limeImage.ONTOP"Buy" BarCntr);
                
    drawTextRelative(0low() - (space 1.75), "B"Color.blackColor.limeText.FRAME Text.ONTOP Text.BOLDnull9"text buy" BarCntr );
                
    drawImageRelative(0low() - (space 3), "SystemHappyFace"nullImage.ONTOP"buy image" BarCntr);
                
    Strategy.doLong("Crossing Up"Strategy.MARKETStrategy.NEXTBAR);
            }
        } else if(!
    Strategy.isShort()) {
            
    drawShapeRelative(0high() + spaceShape.DOWNARROWnullColor.yellowImage.ONTOP"Sell" BarCntr);
            
    drawTextRelative(0high() + (space 1.75), "S"Color.blackColor.redText.FRAME Text.BOTTOM Text.BOLDnull9"text sell" BarCntr );
            
    drawImageRelative(0high() + (space 3), "SystemHappyFace"nullImage.BOTTOM"short image" BarCntr);
            
    Strategy.doShort("Crossing Down"Strategy.MARKETStrategy.NEXTBAR);
        }

        return 
    v;

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X