File Name: EMAPredictive.efs

Description:
EMA Predictive

Formula Parameters:
Long Period : 25
Short Period : 8
Extra Time Forward : 1



Notes:
Traditional moving averages, as simple-minded linear filters, have significant group delay.
In engineering that isn't so important as nobody cares if your sound from your iPod is delayed
a few milliseconds after it is first processed. But in markets, you can't
trade on the smoothed price, only the actual noisy, market price now. Hence you
ought to estimate better.
This statistic (what math/science people call what technical analysts call an 'indicator')
may be useful as the "fast" moving average in a moving average crossover trading system.
It could also be useful for the slow moving average as well.



Download File:
EMAPredictive.efs



EFS Code:
PHP Code:
/*********************************
Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2009. All rights reserved. This sample eSignal 
    Formula Script (EFS) is for educational purposes only and may be 
    modified and saved under a new file name.  eSignal is not responsible
    for the functionality once modified.  eSignal reserves the right 
    to modify and overwrite this EFS file with each new release.

Description:        
    EMA Predictive
    
Version:            1.0  09/15/2009
 
Formula Parameters:                     Default:
    Long Period                         25
    Short Period                        8
    Extra Time Forward                  1
   
Notes:
    Traditional moving averages, as simple-minded linear filters, have significant group delay.
    In engineering that isn't so important as nobody cares if your sound from your iPod is delayed
    a few milliseconds after it is first processed.  But in markets, you can't
    trade on the smoothed price, only the actual noisy, market price now.   Hence you 
    ought to estimate better.
    This statistic (what math/science people call what technical analysts call an 'indicator')
    may be useful as the "fast" moving average in a moving average crossover trading system.
    It could also be useful for the slow moving average as well.    
**********************************/
var fpArray = new Array();
var 
bInit false;

function 
preMain(){
    
setPriceStudy(true);
    
setShowCursorLabel(true);
    
setShowTitleParameters(false);
    
setStudyTitle("EMA Predictive");
    
setCursorLabelName("EMAP"0);
    
setPlotType(PLOTTYPE_LINE0);
    
setDefaultBarThickness(20);
    
setDefaultBarFgColor(Color.green0);
    var 
0;
    
fpArray[x] = new FunctionParameter("LongPeriod"FunctionParameter.NUMBER);
    
with(fpArray[x++]) {
        
setName("Long Period");
        
setLowerLimit(1);
        
setDefault(25);
    }    
    
fpArray[x] = new FunctionParameter("ShortPeriod"FunctionParameter.NUMBER);
    
with(fpArray[x++]) {
        
setName("Short Period");
        
setLowerLimit(1);
        
setDefault(8);
    }    
    
fpArray[x] = new FunctionParameter("ExtraTimeForward"FunctionParameter.NUMBER);
    
with(fpArray[x++]) {
        
setName("Extra Time Forward");
        
setLowerLimit(0.000001);
        
setDefault(1);
    }        
}

var 
xEMAPredictive null;

function 
main(LongPeriodShortPeriodExtraTimeForward) {
var 
nBarState getBarState();
var 
nEMAPredictive 0;
    if (
nBarState == BARSTATE_ALLBARS) {
        if(
LongPeriod == nullLongPeriod 25;
        if(
ShortPeriod == nullShortPeriod 8;
        if(
ExtraTimeForward == nullExtraTimeForward 1;
    }
    if (
bInit == false) {
        
xEMAPredictive efsInternal("Calc_EMAPredictive"LongPeriodShortPeriodExtraTimeForward);
        
bInit true;
    }
    
nEMAPredictive xEMAPredictive.getValue(0);
    if (
nEMAPredictive == null) return;
    return 
nEMAPredictive;
}

var 
bSecondInit false;
var 
xFma null;
var 
xSma null;

function 
Calc_EMAPredictive(LongPeriodShortPeriodExtraTimeForward) {
var 
nRes 0;
    if (
bSecondInit == false) {
        
xFma ema(ShortPeriod);
        
xSma ema(LongPeriod);
        
bSecondInit true;
    }
    var 
nFma xFma.getValue(0);
    var 
nSma xSma.getValue(0);
    if (
nSma == null) return;
    var 
t1 = (LongPeriod 1.0) / 2.0;
    var 
t3 = (ShortPeriod 1.0) / 2.0;
    var 
ShortPeriod ExtraTimeForward;
    var 
slope1 = (nFma nSma) / (t1-t3);
    
nRes nFma slope1 t;
    return 
nRes;