Announcement

Collapse
No announcement yet.

2004 Jan: eSignal_RisingDarkness.efs

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

  • 2004 Jan: eSignal_RisingDarkness.efs

    File Name: eSignal_RisingDarkness.efs


    Description:
    Based on Trading In The Hours Of Darkness – Holding Overnight Positions by Anthony Trongone, PhD, CFP, CTA. This article appeared in the January 2004 issue of Stocks & Commodities.

    Formula Parameters:
    None.

    Notes:
    The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.

    Download File:
    eSignal_RisingDarkness.efs




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

    Indicator: Rising Darkness

    Notes:  
        Requires at least 50 bars of data and a 
            Daily chart interval.
        Bottom row of arrows are Price symbols.
        Top row of arrows are Volume symbols.
    ********************************************/

    function preMain() {
        
    setStudyTitle("Rising Darkness ");
        
    setCursorLabelName("Vol \%Chg"0);
        
    setCursorLabelName("Price \%Chg"1);
        
    setDefaultBarThickness(50);  
        
    setDefaultBarThickness(31);
        
    setDefaultBarFgColor(Color.navy0);
        
    setDefaultBarFgColor(Color.aqua1);
        
    setPlotType(PLOTTYPE_HISTOGRAM0);
        
    setPlotType(PLOTTYPE_HISTOGRAM1);
        
    addBand(0PS_SOLID1Color.black"zero");
        
    }

    var 
    aVolChg = new Array(50);
    var 
    aVol = new Array(8);
    var 
    vVol null;    // Today's volume
    var vAvg null;    // Today's avg volume
    var vAvg1 null;   // Yesterday's avg volume
    var vVolChg null;
    var 
    bLabels false;
    var 
    nImageCntr 0;

    function 
    main() {
        if (
    getInterval() != "D") {
            
    drawTextAbsolute(-110"Formula requires Daily interval."
                
    Color.redColor.blackText.BOLD|Text.RIGHTnull
                
    12"error");
            return;
        }
        
    // Remove the code block above to enable all intervals.
        
        
    if (bLabels == false) {
            
    drawTextAbsolute(22"-- Price Symbols"Color.black
                
    nullText.BOLD|Text.RELATIVETOBOTTOMnull
                
    10"price label");
            
    drawTextAbsolute(214"-- Volume Symbols"Color.black
                
    nullText.BOLD|Text.RELATIVETOBOTTOMnull
                
    10"volume label");
            
    bLabels true;
        }
        
        var 
    nState getBarState();
        var 
    vRank null;
        var 
    close();
        var 
    c1 close(-1);
        if (
    c1 == null) return;

        if (
    nState == BARSTATE_NEWBAR && vVol != null) {
            
    nImageCntr += 1;
            if (
    nImageCntr 200nImageCntr 0;
            
    aVol.pop();
            
    aVol.unshift(vVol);
            
    vAvg1 vAvg;
            if (
    vVolChg != null) {
                
    aVolChg.pop();
                
    aVolChg.unshift(vVolChg);
            }
        }
        
        
    vVol volume();
        
    aVol[0] = vVol;
        
        if (
    aVol[7] == null) return;
        
        
    vAvg calcMA();
        
        if (
    vAvg1 == null) return;
        
        
    vVolChg = (((vAvg vAvg1) / vAvg1) * 100).toFixed(4) *1;
        
    aVolChg[0] = vVolChg;
        
        if (
    aVolChg[49] != null) {
            
    vRank getRank(aVolChg);
        }
        
        var 
    vPriceChg = (((c1) / c) * 100).toFixed(2) *1;
        
        
    // Draw Volume and Price Symbols
        
    var nVol 0;   // 0 = no signal, 1 = positive, 2 = negative
        
    var nPrc 0;
        if (
    vRank/50 >= 0.70) {
            
    nVol 1;
        } else if (
    vRank/50 <= 0.30) {
            
    nVol 2;
        }
        if (
    vPriceChg >= 1.00) {
            
    nPrc 1;
        } else if (
    vPriceChg <= -1.00) {
            
    nPrc 2;
        }

        if (
    nVol && nPrc 0) {
            if (
    nVol == 1) {
                
    drawShapeRelative(012Shape.UPARROWnull
                    
    Color.greenShape.RELATIVETOBOTTOM
                    
    "vol"+nImageCntr);
            } else if (
    nVol == 2) {
                
    drawShapeRelative(012Shape.DOWNARROWnull
                    
    Color.redShape.RELATIVETOBOTTOM
                    
    "vol"+nImageCntr);
            }
            if (
    nPrc == 1) {
                
    drawShapeRelative(01Shape.UPARROWnull
                    
    Color.greenShape.RELATIVETOBOTTOM
                    
    "prc"+nImageCntr);
            } else if (
    nPrc == 2) {
                
    drawShapeRelative(01Shape.DOWNARROWnull
                    
    Color.redShape.RELATIVETOBOTTOM
                    
    "prc"+nImageCntr);
            }
        } else {
            
    removeShape("vol"+nImageCntr);
            
    removeShape("prc"+nImageCntr);
        }

        return new Array(
    vVolChgvPriceChg);
    }



    /*** Functions ***/

    function calcMA() {
        var 
    dSum 0.0;
        var 
    0;
        for(
    08i++) {
            
    dSum += aVol[i];
        }
        return (
    dSum 8);
    }

    function 
    getRank(aRank) {
        var 
    0;
        var 
    cntr 0;
        for (
    050; ++i) {
            if (
    vVolChg >= aRank[i]) cntr += 1;
        }
        return 
    cntr;

    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