Announcement

Collapse
No announcement yet.

ema study modification for intraday use

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ema study modification for intraday use

    I am looking for an intraday ema study.
    I need the ema to start ploting every day at the opening time of the market(9:30).
    is there anything like that out there?
    thanks.

  • #2
    ema study modification for intraday use

    i have this standard ema study, that i need to ajust for intraday use so it will have the following characteristics:

    1. It will start to plot the ema at the start of the trading session.

    2. It will treat the first bar as the moving average.
    so for example, if it is 9:39 at a 5 minute chart, I will have two bars. the ema calculation will be based on those two bars. the first one will be used as the ema basis, and the new bar will be added to create the new ema.

    3. I need the calculation to be based on (high+low+close)/3 rather then just close.

    the efs i currently have is from the database:

    /************************************************** ***************
    Provided By : eSignal. (c) Copyright 2003
    ************************************************** ***************/

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("EMA calculation");
    setCursorLabelName("EMA of Close", 0);
    setDefaultBarFgColor(Color.lime, 0);
    }

    var vEMA = null;
    var vEMA1 = null;

    var dPercent = 0.0;
    var bPrimed = false;

    function EMA(nLength, nArray) {
    var nBarState = getBarState();
    var dSum = 0.0;
    var dRef;

    if(nBarState == BARSTATE_ALLBARS || bPrimed == false) {
    dPercent = (2.0 / (nLength + 1.0));
    bPrimed = false;
    }

    if (nBarState == BARSTATE_NEWBAR) {
    vEMA1 = vEMA;
    }

    if(bPrimed == false) {
    for(i = 0; i < nLength; i++) {
    dSum += nArray[i];
    }
    bPrimed = true;
    return (dSum / nLength);
    } else {
    return (((close() - vEMA1) * dPercent) + vEMA1);
    }
    }

    function main(nLength) {
    if(nLength == null || nLength <= 0) nLength = 10;

    var nArray = getValue("Close", 0, -nLength);
    if(nArray == null) return;

    vEMA = EMA(nLength, nArray);

    return vEMA;

    thanks for your help, I am stuggling with it for a few days now, with no success.

    Comment

    Working...
    X