Skip to main content

Stochastic Momentum Index (SMI) for eSignal (EFS)

petert over 8 years ago eSignal (EFS)

  • Rating:
    0 / 5 (Votes 0)
  • Tags:
    eSignal, oscillator

Stochastic Momentum Index (SMI) was created by William Blau in January 1993 issue of Technical Analysis of Stocks & Commodities. The SMI shows where the close price is in relation to the middle of the last high/low price range, in comparison to the close relative to the recent low/high with the Stochastic Oscillator.

The oscillator values fluctuate between -100 and 100, and as a result can be less reliable then the stochastic oscillator with the same period. The SMI can be used to identify overbought and oversold levels. The most common way of interpreting the SMI is to sell when the SMI rises above +40 and then returns to the point under that level and to buy when the SMI decreases under -40 and then shifts back above it.

Indicator / Formula

Copy & Paste Friendly
/*********************************************************
Alexis C. Montenegro © December 2004                      
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 fpArray = new Array();

function preMain() {
    setPriceStudy(false);
    setStudyTitle("Stoch MOM");
    setCursorLabelName("%K",0);
    setCursorLabelName("%D",1);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    var x=0;
    fpArray[x] = new FunctionParameter("KLength", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("%K");
        setLowerLimit(1);		
        setDefault(14);
    }
	fpArray[x] = new FunctionParameter("KSmoothing", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("%KSmooth");
        setLowerLimit(1);		
        setDefault(1);
    }
    fpArray[x] = new FunctionParameter("DLength", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("%D");
        setLowerLimit(1);		
        setDefault(3);
    }
    fpArray[x] = new FunctionParameter("MOMLength", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(10);
    }
	fpArray[x] = new FunctionParameter("MOMSource", FunctionParameter.STRING);
	with(fpArray[x++]){
        addOption("open"); 
        addOption("high");
        addOption("low");
        addOption("close");
        addOption("hl2");
        addOption("hlc3");
        addOption("ohlc4"); 
        setDefault("close"); 
    }
    fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
    with(fpArray[x++]){
        setDefault();
	}
	fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
	with(fpArray[x++]){
        setDefault();
    }
    fpArray[x] = new FunctionParameter("Upper", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(0);
        setDefault(80); 
    }
	fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(0);
        setDefault(20); 
	}
	fpArray[x] = new FunctionParameter("LineColor1", FunctionParameter.COLOR);
	with(fpArray[x++]){
        setName("Color1");
        setDefault(Color.blue);
    }
    fpArray[x] = new FunctionParameter("LineColor2", FunctionParameter.COLOR);
	with(fpArray[x++]){
        setName("Color2");
        setDefault(Color.red);
    }
    fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
	with(fpArray[x++]){
        setName("Show Parameters");
        setDefault(false);
    }
}

var bInit = false;
var xStochK = null;
var xStochD = null;

function main(KLength,KSmoothing,DLength,MOMLength,MOMSource,Symbol,Interval,Upper,Lower,LineColor1,LineColor2,Params) {
    if(bInit == false){
        if(Symbol == null) Symbol = getSymbol();
        if(Interval == null) Interval = getInterval();
        var vSymbol = Symbol+","+Interval;
        xStochK = getSeries(stochK(KLength,KSmoothing,DLength,mom(MOMLength,eval(MOMSource)(sym(vSymbol)))));
        xStochD = getSeries(stochD(KLength,KSmoothing,DLength,mom(MOMLength,eval(MOMSource)(sym(vSymbol)))));   
        setDefaultBarFgColor(LineColor1,0);
        setDefaultBarFgColor(LineColor2,1);
        addBand( Upper, PS_SOLID, 1, Color.black,"Upper");
        addBand( Lower, PS_SOLID, 1, Color.black,"Lower");
        setShowTitleParameters(eval(Params));
        bInit = true;
    }
    return new Array (xStochK,xStochD);
}

0 comments

Leave Comment

Please login here to leave a comment.