AutoMOB.efs

ICE Data Services -

AutoMOB.efs  

File Name: AutoMOB.efs

Description:
Displays an Advanced Get MOB automatically.

Formula Parameters:
NA

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

 

Download File:
AutoMOB.efs



EFS Code:



var pivots = new GetPivotsStudy();
var elliott = new GetElliottStudy(300, 0, 50, 5, 35, 0);

var nLastMRW		= null; // Last Most Recent Wave (used for reloading)
var nLastMRWIndex   	= null;
var dLastMRWHigh	= null;
var dLastMRWLow		= null;
var bMOBDrawn		= false;


var arPivots		= new Array();
var arPivotBar		= new Array();


function preMain() {
    checkVersion(2, "http://share.esignal.com/ContentRoot/PowerStation/MAG-EFS/AutoMOB.efs");
    
    addEntitlement("AGST", "Not entitled for Advanced GET Studies");
   	setPriceStudy(true);
	setStudyTitle("Auto MOB");
}

function main() {
	// What's the most recent wave?  If it has changed since last remembered, reload the EFS.
	// If the elliot waves change, you can count on the pivots updating.
	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;
			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) {
		clearLineTool(LineTool.MOB);
		clearShape();
		
		arPivots.length		= 0;
		arPivotBar.length	= 0;
		
		bMOBDrawn = false;
	}

	if(nBarState == BARSTATE_NEWBAR) {
		var nPivot = pivots.getValue(GetPivotsStudy.PIVOTS, -1);
		if(nPivot != null) {
			arPivots.push(nPivot);
			arPivotBar.push(getCurrentBarIndex());
		}
	
	}
	    
	if(bMOBDrawn == false && getCurrentBarIndex() == 0) {
		bMOBDrawn = true;
		
		var nStart = arPivots.length-1;
		var i;
		var nCount = 0;
		
		for(i = nStart; i >= 0; i--) {
			var vPivot = arPivots[i];
			var vBar = arPivotBar[i]-1;
			
			// debugPrintln("I: " + i + " Pivot: " + vPivot + " Bar: " + vBar);
			
			// 1 primary
			// 2 major
			// 3 intermediate
			// 4 minor
			// if negative, a downsize pivot.
	        if(vPivot == 1) {
				addLineTool(LineTool.MOB, vBar, high(vBar), Color.aqua, Color.magenta, Color.black, "mob");
				//drawShapeRelative(vBar, 20, Shape.UPTRIANGLE, "", Color.blue, Shape.RELATIVETOTOP, "Pt" + getValue("rawtime", vBar));
				//drawShapeRelative(vBar, 10, Shape.UPTRIANGLE, "", Color.blue, Shape.RELATIVETOBOTTOM, "Pb" + getValue("rawtime", vBar));
				nCount++;
			} else if(vPivot == -1) {
				addLineTool(LineTool.MOB, vBar, low(vBar), Color.aqua, Color.magenta, Color.black, "mob");
			    //drawShapeRelative(vBar, 20, Shape.DOWNTRIANGLE, "", Color.red, Shape.RELATIVETOTOP, "Pt" + getValue("rawtime", vBar));
				//drawShapeRelative(vBar, 10, Shape.DOWNTRIANGLE, "", Color.red, Shape.RELATIVETOBOTTOM, "Pb" + getValue("rawtime", vBar));
				nCount++;
				/**
			} else if(vPivot == 2) {
				addLineTool(LineTool.MOB, vBar, high(vBar), Color.yellow, Color.yellow, Color.black, "mob");
				drawShapeRelative(vBar, 20, Shape.UPTRIANGLE, "", Color.yellow, Shape.RELATIVETOTOP, "Pt" + getValue("rawtime", vBar));
				drawShapeRelative(vBar, 10, Shape.UPTRIANGLE, "", Color.yellow, Shape.RELATIVETOBOTTOM, "Pb" + getValue("rawtime", vBar));
				nCount++;
			} else if(vPivot == -2) {
				addLineTool(LineTool.MOB, vBar, low(vBar), Color.yellow, Color.yellow, Color.black, "mob");
		        drawShapeRelative(vBar, 20, Shape.DOWNTRIANGLE, "", Color.yellow, Shape.RELATIVETOTOP, "Pt" + getValue("rawtime", vBar));
				drawShapeRelative(vBar, 10, Shape.DOWNTRIANGLE, "", Color.yellow, Shape.RELATIVETOBOTTOM, "Pb" + getValue("rawtime", vBar));
				nCount++;
				**/
			}
			
			if(nCount > 4)
				break;
		}
		
	  
    }

}