Announcement

Collapse
No announcement yet.

2002 Jan: The True Strength Index (Blau_TSI.efs)

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2002 Jan: The True Strength Index (Blau_TSI.efs)

    File Name: Blau_TSI.efs

    Description:
    This study is based on The True Stength Index by Thom Hartle, which appeared in the January 2002 issue of Active Trader Magazine.


    Formula Parameters:
    nR: 25 (First EMA period length)
    nS: 13 (EMA period length of nR)


    Notes:
    The TSI Method outlined in the article was designed by William Blau. The related article is copyrighted material. If you are not a subscriber of Active Trader Magazine, please visit www. activetradermag.com.

    Download File:
    Blau_TSI.efs



    EFS Code:
    PHP Code:
    /**********
    Provided By : eSignal (c) Copyright 2004

    Description:  The True Strength Index (TSI) by William Blau

    Notes:
        Based on article from January 2002 issue of Active Trader Magazine.
        The True Strength Index by Thom Hartle
    ***********/


    function preMain() {
        
    setPriceStudy(false);
        
    setStudyTitle("Blau TSI");
        
    setCursorLabelName("TSI"0);
        
    setCursorLabelName("Signal"1);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarFgColor(Color.red1);
        
        
    addBand(0PS_SOLID1Color.black"zero");
    }

    var 
    aTSI = new Array(7);
    var 
    nTSI 0;

    function 
    main(nRnS) {
        if (
    nR == nullnR 25;
        if (
    nS == nullnS 13;

        if (
    getBarState() == BARSTATE_NEWBAR && nTSI != && nTSI != null) {
            
    aTSI.pop();
            
    aTSI.unshift(nTSI);
        }    

        var 
    nSignal 0;
        
        
    nTSI TSI(nRnS);
        if (
    nTSI == null) return;

        if (
    aTSI[6] != null) {
            
    vEMA[4] = EMA(7aTSI4nTSI);
            
    nSignal vEMA[4];
        }
        
        return new Array(
    nTSI*100nSignal*100);
    }

    function 
    TSI(nRnS) {
        if (
    close(-1) == null) return;

        
    nTSI 0;

        var 
    nMtm close(0) - close(-1);
        var 
    nEMAofMtm1 DXAverage("Value1"nMtmnRnS);
        if (
    nEMAofMtm1 == null) return;
        var 
    nEMAofMtm2 DXAverage("Value2"Math.abs(nMtm), nRnS);
        if (
    nEMAofMtm2 == null) return;

        if (
    nEMAofMtm2 != 0) {
            
    nTSI nEMAofMtm1 nEMAofMtm2;
        }

        return 
    nTSI;
    }

    //Double EMA
    var aSource1 null// r   nMtm
    var aSource2 null// s   Source1
    var aSource3 null// r   |nMtm|
    var aSource4 null// s   Source3

    function DXAverage(sSourcenValuenMA1LengthnMA2Length) {
        if (
    sSource == null || nValue == null || nMA1Length == null || nMA2Length == null) return;
        
        var 
    nDXAverage null;
        var 
    nState getBarState();

        if (
    aSource1 == nullaSource1 = new Array(nMA1Length);
        if (
    aSource2 == nullaSource2 = new Array(nMA2Length);
        if (
    aSource3 == nullaSource3 = new Array(nMA1Length);
        if (
    aSource4 == nullaSource4 = new Array(nMA2Length);
        
        if (
    nState == BARSTATE_NEWBAR) {
            if (
    sSource == "Value1") {
                if (
    nValue != null) {
                    
    aSource1.pop();
                    
    aSource1.unshift(nValue);
                }
                if (
    vEMA[0] != null) {
                    
    aSource2.pop();
                    
    aSource2.unshift(vEMA[0]);
                }
            }
            if (
    sSource == "Value2") {
                if (
    nValue != null) {
                    
    aSource3.pop();
                    
    aSource3.unshift(nValue);
                }
                if (
    vEMA[2] != null) {
                    
    aSource4.pop();
                    
    aSource4.unshift(vEMA[2]);
                }
            }
        }
        
        
    // EMA(nLength, nArray, nNum, nIndicator); 
        
        
    if (sSource == "Value1") {
            
    // EMA of aSource1 r
            
    if (aSource1[nMA1Length-1] == null) return;
            
    vEMA[0] = EMA(nMA1LengthaSource10nValue);
            
    aSource2[0] = vEMA[0];
            
            
    // EMA of aSource2 s
            
    if (aSource2[nMA2Length-1] == null) return;
            
    vEMA[1] = EMA(nMA2LengthaSource21vEMA[0]);
            
    nDXAverage vEMA[1];
            
        }
        if (
    sSource =="Value2") {
            
    // EMA of aSource4 r
            
    if (aSource3[nMA1Length-1] == null) return;
            
    vEMA[2] = EMA(nMA1LengthaSource32nValue);
            
    aSource4[0] = vEMA[2];
            
            
    // EMA of aSource5 s
            
    if (aSource4[nMA2Length-1] == null) return;
            
    vEMA[3] = EMA(nMA2LengthaSource43vEMA[2]);
            
    nDXAverage vEMA[3];
        }


        return 
    nDXAverage;
    }

    var 
    bPrimed = new Array(5);
    bPrimed[0] = false;  // r   Mtm
    bPrimed[1] = false;  // s   Source1
    bPrimed[2] = false;  // u   |Mtm|
    bPrimed[3] = false;  // r   Source3
    bPrimed[4] = false;  // 7   aTSI

    var dPercent = new Array(5);
    var 
    vEMA = new Array(5);
    var 
    vEMA1 = new Array(5);

    function 
    EMA(nLengthnArraynNumnIndicator) {
        var 
    nBarState getBarState();
        var 
    dSum 0.0;

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

        if (
    nBarState == BARSTATE_NEWBAR) {
            
    vEMA1[nNum] = vEMA[nNum];
        }

        if(
    bPrimed[nNum] == false) {
            for(
    0nLengthi++) {
                
    dSum += nArray[i];
            }
            
    bPrimed[nNum] = true;
            return (
    dSum nLength);
        } else {
            return (((
    nIndicator vEMA1[nNum]) * dPercent[nNum]) + vEMA1[nNum]);
        }

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X