BtMovingAverage2.efs

ICE Data Services -


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:
NA

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

Download File:
BtMovingAverage2.efs




EFS Code:
/*******************************Provided By : eSignal. (c) Copyright 2003*******************************/var study = new MAStudy(10, 0, "Close", MAStudy.SIMPLE);function preMain() {    setPriceStudy(true);    setStudyTitle("Draw Lines, Text, Shapes and Images.");}var vHigh;var vLow;var BarCntr = 0;function main() {	var v = study.getValue(MAStudy.MA);	if(v == null)		return;    if (getBarState() == BARSTATE_NEWBAR)         BarCntr +=1;        vHigh = high();    vLow = low();    for (i = 0; i < 20; ++i) {        vHigh = Math.max(high(-i), vHigh);        vLow = Math.min(low(-i), vLow);    }    drawLineRelative(-20, vHigh, 0, vHigh, PS_SOLID, 2, Color.red, "High");    drawLineRelative(-20, vLow, 0, vLow, PS_SOLID, 2, Color.green, "Low");    var space = 1;    if (getInterval() != "D")        space = high() - low();    	if(close() >= v) {		if(!Strategy.isLong()) {            drawShapeRelative(0, low(), Shape.UPARROW, null, Color.lime, Image.ONTOP, "Buy" + BarCntr);            drawTextRelative(0, low() - (space * 1.75), "B", Color.black, Color.lime, Text.FRAME | Text.ONTOP | Text.BOLD, null, 9, "text buy" + BarCntr );            drawImageRelative(0, low() - (space * 3), "SystemHappyFace", null, Image.ONTOP, "buy image" + BarCntr);			Strategy.doLong("Crossing Up", Strategy.MARKET, Strategy.THISBAR);		}	} else if(!Strategy.isShort()) {        drawShapeRelative(0, high() + space, Shape.DOWNARROW, null, Color.yellow, Image.ONTOP, "Sell" + BarCntr);        drawTextRelative(0, high() + (space * 1.75), "S", Color.black, Color.red, Text.FRAME | Text.BOTTOM | Text.BOLD, null, 9, "text sell" + BarCntr );        drawImageRelative(0, high() + (space * 3), "SystemHappyFace", null, Image.BOTTOM, "short image" + BarCntr);		Strategy.doShort("Crossing Down", Strategy.MARKET, Strategy.THISBAR);	}	return v;}