Announcement

Collapse
No announcement yet.

2017 Jun: Daytrading With Night Volume by Domenico D'Errico

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

  • 2017 Jun: Daytrading With Night Volume by Domenico D'Errico

    File Name: Night_and_Day.efs

    Description:
    Daytrading With Night Volume by Domenico D'Errico

    Formula Parameters:

    Night_and_Day.efs

    Length: 5
    Night Session Open: 23:00
    Day Session Open: 08:30
    Day Session Close: 15:00
    Volume Ratio: 1
    Strategy Type: First Hour BreakOut

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

    Download File:
    Night_and_Day.efs

    Night_and_Day.efs


    EFS Code:
    PHP Code:
    /*********************************
    Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data
    Corporation. 2016. 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:        
        Daytrading With Night Volume by Domenico D'Errico

    Version:            1.00  04/12/2017

    Formula Parameters:                     Default:
    Length                                  5
    Night Session Open                      23:00
    Day Session Open                        08:30
    Day Session Close                       15:00
    Volume Ratio                            1
    Strategy Type                           First Hour BreakOut


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

    **********************************/

    var fpArray = new Array();

    function 
    preMain(){
        
    setPriceStudy(false);
        
    setColorPriceBars(true);
        
    setDefaultPrecision(0,0);
        
    setDefaultPriceBarColor(Color.RGB(0,148,255));
        
    setStudyTitle("Night&Day");

        
    setPlotType(PLOTTYPE_HISTOGRAM);
        
    setCursorLabelName("CumVol");

        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Length");
            
    setDefault(5);
            
    setLowerLimit(1);
        }
        
    fpArray[x] = new FunctionParameter("NightO"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setName("Night Session Open");
            
    setDefault("23:00");
        }
        
    fpArray[x] = new FunctionParameter("DayO"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setName("Day Session Open");
            
    setDefault("08:30");
        }
        
    fpArray[x] = new FunctionParameter("DayC"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setName("Day Session Close");
            
    setDefault("15:00");
        }
        
    fpArray[x] = new FunctionParameter("VolRatio"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Volume Ratio");
            
    setDefault(1);
            
    setLowerLimit(1);
        }
        
    fpArray[x] = new FunctionParameter("StrategyType"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setName("Strategy Type");
            
    setDefault("First Hour BreakOut");
            
    addOption("First Hour BreakOut");
            
    addOption("Night & Day");
        }
    }

    var 
    bInit false;
    var 
    bVersion null;
    var 
    xHigh null;
    var 
    xLow null;
    var 
    xClose null;
    var 
    xVol null;
    var 
    aNightVol null;
    var 
    nCurrNightVol 0;
    var 
    nLastVol 0;

    var 
    nNightSessionOpen null;
    var 
    nDaySessionOpen null;
    var 
    nDaySessionClose null;

    var 
    nFirstHourHighest null;
    var 
    nFirstHourLowest null;

    function 
    main(LengthNightODayODayCStrategyType){
        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return;

        if (
    getBarState() == BARSTATE_ALLBARS){
            
    bInit false;
        }

        if (!
    bInit){
            
    xHigh high();
            
    xLow low();
            
    xClose close();
            
    xVol volume();
            
    aNightVol = new Array(Length0);
            
    nFirstHourHighest null;
            
    nFirstHourLowest null;
            
    nCurrNightVol 0;
            
    nLastVol 0;
            
    nNightSessionOpen TimeStringToNumber(NightO);
            
    nDaySessionOpen TimeStringToNumber(DayO);
            
    nDaySessionClose TimeStringToNumber(DayC);
            
    bInit true;
        }


        var 
    nHigh xHigh.getValue(0);
        var 
    nLow xLow.getValue(0);
        var 
    nClose xClose.getValue(0);

        var 
    barTime hour(0) * 100 minute(0);


        if (
    getBarState() == BARSTATE_NEWBAR){
            if (
    barTime == nNightSessionOpennCurrNightVol 0;
            
    nLastVol nCurrNightVol;
        }

        
    nCurrNightVol nLastVol xVol.getValue(0);

        if (
    barTime == nDaySessionOpen){
            for (var 
    Length 10i--){
                
    aNightVol[i] = aNightVol[1];
            }
            
    aNightVol[0] = nCurrNightVol;
            
    nFirstHourLowest nLow;
        }

        if (
    barTime >= nDaySessionOpen && barTime <= TimeMath(nDaySessionOpen"add"60)){
            if (
    nHigh nFirstHourHighestnFirstHourHighest nHigh;
            if (
    nLow nFirstHourLowestnFirstHourLowest nLow;
            
    setPriceBarColor(Color.red);
        }


        if (
    getCurrentBarIndex() != 0){
            if(
    barTime >= TimeMath(nDaySessionOpen"add"60 parseInt(getInterval())) &&
                
    barTime TimeMath(nDaySessionClose"sub"parseInt(getInterval()))){
                    if (!
    Strategy.isInTrade()){
                        if (
    StrategyType == "First Hour BreakOut"){
                            if (
    nHigh nFirstHourHighest){
                                
    Strategy.doLong("First Hour BreakUP"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                                
    nFirstHourHighest 0;
                            }
                            else if (
    nLow nFirstHourLowest){
                                
    Strategy.doShort("First Hour BreakDN"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                                
    nFirstHourLowest 0;
                            }
                        }

                        else if (
    StrategyType == "Night & Day" && aNightVol[0] > AvgVolume(aNightVolLength)){
                            if (
    nHigh nFirstHourHighest){
                                
    Strategy.doLong("N & D BreakUP"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                                
    nFirstHourHighest 0;
                            }
                            else if (
    nLow nFirstHourLowest){
                                
    Strategy.doShort("N & D BreakDN"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                                
    nFirstHourLowest 0;
                            }
                        }
                    }

            }

            if (
    barTime >= TimeMath(nDaySessionClose"add"parseInt(getInterval()))){
                if (
    Strategy.isLong())
                    
    Strategy.doSell("Exit BreakUP"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                else if (
    Strategy.isShort())
                    
    Strategy.doCover("Exit BreakDN"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
            }
        }

        if (
    barTime nDaySessionOpensetPriceBarColor(Color.black);
        else if (
    barTime nDaySessionClosesetPriceBarColor(Color.grey);

        return 
    nCurrNightVol;
    }


    function 
    TimeStringToNumber(timeStr){
        var 
    tempTime = new Array();
        
    tempTime timeStr.split(':',2);
        if (
    tempTime[0][0] == '0')
            
    tempTime[0] = tempTime[0].substr(1);
        if (
    tempTime[1][0] == '0')
            
    tempTime[1] = tempTime[1].substr(1);
        
    tempTime = (parseInt(tempTime[0]) * 100) + parseInt(tempTime[1]);

        return 
    tempTime;
    }

    function 
    AvgVolume(aVolumeLength){
        var 
    sumVol 0;
        for (var 
    0Lengthi++){
            
    sumVol += aVolume[i];
        }
        return (
    sumVol Length);
    }

    function 
    TimeMath(timeValtypevalue){
        if (
    type == "add"){
            
    timeVal += (value 60 Math.floor(value 60) * 100);
        }
        else if (
    type == "sub"){
            
    timeVal -= Math.floor(value 60) * 100;
            if (
    value 60 timeVal 100timeVal -= (100 - (60 value 60));
        }
        return 
    timeVal;
    }

    function 
    verify(){
        var 
    false;
        if (
    getBuildNumber() < 3742){
            
    drawTextAbsolute(535"This study requires version 12.1 or later.",
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"error");
            
    drawTextAbsolute(520"Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"upgrade");
            return 
    b;
        }
        else
            
    true;

        return 
    b;

Working...
X