AutoEllipse.efs

ICE Data Services -


AutoEllipse.efs 
  

File Name: AutoEllipse.efs


Description:
Displays an Advanced Get Ellipse automatically.


Formula Parameters:
NA

Notes:
** Please note this study requires a subscription to the Advanced Get Studies.

Download File:
AutoEllipse.efs




EFS Code:
/************************Copyright � eSignal, 2003*************************Description: Displays an Advanced Get Ellipse automatically.** Please note this study requires a subscription to the Advanced Get Studies.*/function preMain() {    checkVersion(2, "http://share.esignal.com/ContentRoot/PowerStation/MAG-EFS/AutoEllipse.efs");    addEntitlement("AGST", "Not entitled for Advanced GET Studies");	setStudyTitle("Auto Ellipse");	setPriceStudy(true);}var elliott = new GetElliottStudy(300, 0, 50, 5, 35, 0);var nLastMRW		= null; // Last Most Recent Wave (used for reloading)var nLastMRWIndex   = null;var arWaves			= new Array();var arWaveBar		= new Array();var bEllipsesDrawn	= false;var dLastMRWHigh	= null;var dLastMRWLow		= null;function initWaves() {	clearLineTool(LineTool.ELLIPSE);		arWaves.length		= 0;	arWaveBar.length	= 0;	bEllipsesDrawn		= false;}function dumpWaves() {	debugPrintln("Dumping Waves");	var i;	for(i = 0; i < arWaveBar.length; i++) {		debugPrintln("    Wave[" + i + "]" + arWaves[i] + " Index: " + arWaveBar[i]);	}}var WAVE_A			= 7var WAVE_B			= 8var WAVE_C			= 9var WAVENOTFOUND	= 1; // this is a bar indexfunction isABC(nWave) {	nWave = Math.abs(nWave);	if(nWave == 7 || nWave == 8 || nWave == 9)		return true;	return false;}function findPriorWave(nWave) {	var i;	if(arWaves.length == 0)		return WAVENOTFOUND;	var nStart = arWaves.length-1;	nStart--;	for(i = nStart; i >= 0; i--) {		var nWaveBar = Math.abs(arWaves[i]);		// If a 4 stop searching		if(nWaveBar == 4 || nWaveBar == WAVE_A || nWaveBar == WAVE_B)			return WAVENOTFOUND;		if(nWaveBar == nWave)			return arWaveBar[i];	}		return WAVENOTFOUND;}function findPriorWaveABC(nWave) {	var i;	if(arWaves.length == 0)		return WAVENOTFOUND;	var nStart = arWaves.length-1;	for(i = nStart; i >= 0; i--) {		var nWaveBar = Math.abs(arWaves[i]);		// If a 4 stop searching		if(nWaveBar <= 5)			return WAVENOTFOUND;		if(nWave == WAVE_C && nWaveBar < WAVE_C)			return WAVENOTFOUND;		if(nWave == WAVE_B && nWaveBar < WAVE_B)			return WAVENOTFOUND;		if(nWaveBar == nWave)			return arWaveBar[i];	}		return WAVENOTFOUND;}function findCurrentWave(nWave) {	if(arWaves.length == 0)		return WAVENOTFOUND;	var nStart = arWaves.length-1;	var nWaveBar = Math.abs(arWaves[nStart]);	if(nWaveBar == nWave)		return arWaveBar[nStart];	return WAVENOTFOUND;}function findOnePriorWave(nWave) {	if(arWaves.length < 2)		return WAVENOTFOUND;	var nStart = arWaves.length-1;	var nWaveBar = Math.abs(arWaves[nStart-1]);	if(nWaveBar == nWave)		return arWaveBar[nStart-1];	return WAVENOTFOUND;}function FormatSI() {	return getSymbol() + "," + getInterval();}function main() {	// What's the most recent wave?  If it has changed since last remembered, reload the EFS.	var nMRW = elliott.getValue(GetElliottStudy.MOSTRECENTWAVE);	var nMRWIndex = elliott.getValue(GetElliottStudy.MOSTRECENTWAVEBARINDEX);		if(nMRWIndex == null)        return;	if(getCurrentBarIndex() == 0) {		if(nLastMRW == null) {			nLastMRW = nMRW;			nLastMRWIndex = nMRWIndex;			dLastMRWHigh = high(nMRWIndex);			dLastMRWLow = low(nMRWIndex);		} else if(nLastMRW != nMRW || nMRWIndex > nLastMRWIndex || low(nMRWIndex) != dLastMRWLow || high(nMRWIndex) != dLastMRWHigh) {			nLastMRW = null;			nLastMRWIndex = null;			dLastMRWHigh = null;				dLastMRWLow = null;			// Alert.playSound("krtechop.wav");			// Alert.playSound("Pairing.wav");			// Alert.addToList(FormatSI(), "Elliott Wave Change");			reloadEFS();			return;		} else {			nLastMRWIndex = nMRWIndex;			dLastMRWHigh = high(nMRWIndex);			dLastMRWLow = low(nMRWIndex);		}	}		var nBarState = getBarState();	// If ALLBARS, init the wave arrays and vars.	// If newbar, shift the bar indexes	if(nBarState == BARSTATE_ALLBARS) {		initWaves();	} else if(nBarState == BARSTATE_NEWBAR) {		// Get the current wave for a specific bar and add the wave and bar to the arrays		var nWave = elliott.getValue(GetElliottStudy.WAVE);		if(nWave != null) {			arWaves.push(nWave);			arWaveBar.push(getCurrentBarIndex());		}	}	// If on the most recent bar and the ellipses haven't been drawn, search for them	// and draw them.	// Should the MRW change, a reload will occur and this will re-execute.	if(bEllipsesDrawn == false && getCurrentBarIndex() == 0) {		bEllipsesDrawn = true;		// debugPrintln("---- CurWave: " + nMRW);		// dumpWaves();		if(Math.abs(nMRW) == 4) {			// If in a W4, do W2/W3, and W5/W3.			var nBar4 = findCurrentWave(4);			var nBar2 = findPriorWave(2);			var nBar3 = findPriorWave(3);			var nBar5 = findPriorWave(5);			var nBarC = findPriorWave(WAVE_C);			// debugPrintln("Bar2: " + nBar2);			// debugPrintln("Bar3: " + nBar3);			// debugPrintln("Bar5: " + nBar5);			// debugPrintln("BarC: " + nBarC);			if(nBar5 != WAVENOTFOUND && nBar3 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBar5, nBar3, "5/3");			} else if(nBarC != WAVENOTFOUND && nBar3 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBarC, nBar3, "C/3");			}			if(nBar2 != WAVENOTFOUND && nBar3 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBar2, nBar3, "2/3");			}						if(nBar3 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBar3, nBar4, "3/4");			}		} else if(Math.abs(nMRW) == 3) {			// If in a W4, do W2/W3, and W5/W3.			var nBar3 = findCurrentWave(3);			var nBar2 = findPriorWave(2);			var nBar5 = findPriorWave(5);			var nBarC = findPriorWave(WAVE_C);			// debugPrintln("Bar2: " + nBar2);			// debugPrintln("Bar3: " + nBar3);			// debugPrintln("Bar5: " + nBar5);			// debugPrintln("BarC: " + nBarC);			if(nBar5 != WAVENOTFOUND && nBar3 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBar5, nBar3, "5/3");			} else if(nBarC != WAVENOTFOUND && nBar3 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBarC, nBar3, "C/3");			}			if(nBar2 != WAVENOTFOUND && nBar3 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBar2, nBar3, "2/3");			}		} else if(Math.abs(nMRW) == WAVE_C) {			// If in a C, A/B, B/C			var nBarA = findPriorWaveABC(WAVE_A);			var nBarB = findPriorWaveABC(WAVE_B);			var nBarC = findCurrentWave(WAVE_C);			var nBar4 = findOnePriorWave(4);			// debugPrintln("BarA: " + nBarA);			// debugPrintln("BarB: " + nBarB);			// debugPrintln("BarC: " + nBarC);			// debugPrintln("Bar4: " + nBar4);			if(nBar4 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBar4, nBarC, "4/C");				// 4->C (aka 4->5)			} else if(nBarA != WAVENOTFOUND && nBarB != WAVENOTFOUND) {				// If BarB is WAVENOTFOUND then B & C are on the same bar.				addLineTool(LineTool.ELLIPSE, nBarA, nBarB, "A/B");				addLineTool(LineTool.ELLIPSE, nBarB, nBarC, "B/C");			}		} else if(Math.abs(nMRW) == 5) {			// projecting the W3?			// If in a W5, W4/W5			var nBar4 = findOnePriorWave(4);			var nBar5 = findCurrentWave(5);			if(nBar4 != WAVENOTFOUND) {				addLineTool(LineTool.ELLIPSE, nBar4, nBar5, "4/5");			}			// debugPrintln("Bar4: " + nBar4);			// debugPrintln("Bar5: " + nBar5);		}	}	return;	}