Announcement

Collapse
No announcement yet.

Highest range of day

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

  • Highest range of day

    I am using the following to keep track of the highest range of a specific period. I am currently using a fixed period of 70, but I would like to return the highest range of the trading day. To do this, I would like to change this from a fixed number to 'bars since first bar of day' is there an easy way to code this in esignal? ( I use this in other software but Im not familiar with coding in esignal)>

    Thanks,

    Code:
    var ddeAHH=null; 
    var AHH=null;
    var veMA=null;
    var avg=null
    
    
    
    function preMain() { 
    
        setStudyTitle("Highest High Range"); 
        setCursorLabelName("Range", 0); 
        setCursorLabelName("Average", 1); 
        setPlotType(PLOTTYPE_HISTOGRAM, 0); 
        setDefaultBarFgColor(Color.blue, 0); 
        setDefaultBarFgColor(Color.red, 1); 
         
     
    
    } 
    
    function main() {
    
     AHH = efsInternal("HHH"); //this line calls the function "range" and creates a series 
         veMA = highest(70,AHH); //the series is used as an input to the builtin study 
       
         avg = veMA.getValue(0)
    
        if (ddeAHH == null) {
            var sName = "AHH" + getSymbol() + getInterval();
            sName = sName.replace(/\$/g, ""); // remove $ from string
            sName = sName.replace(/\#/g, ""); // remove # from string
            sName = sName.replace(/\-/g, "");
            sName = sName.replace(/\(/g, "");
            sName = sName.replace(/\)/g, "");
            sName = sName.replace(/\ /g, "_") // replace space with underscore
            debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
            ddeAHH = new DDEOutput(sName);
        } 
            ddeAHH.set(avg);
    
            return avg;
    
    } 
    
    
    var DClose = null;
    var Highest= null;
    
    //this is the separate function that calculates the range 
    function HHH() { 
    
            
                Highest = Math.abs(high(0) - low(0));
       
        
        return Highest;
        
        
    
    }

  • #2
    Try this:
    PHP Code:
    //http://forum.esignal.com/showthread.php?38481-Highest-range-of-day
    //http://forum.esignal.com/showthread.php?s=&threadid=35174  today only code from Alexis Montenegro 
    var AHH=null;
    var 
    veMA=null;
    var 
    bCurrentDay false//Note: added
    function preMain() { 
        
    setStudyTitle("Highest High Range"); 
        
    setCursorLabelName("Range"0); 
        
    setCursorLabelName("Average"1); 
        
    setPlotType(PLOTTYPE_HISTOGRAM0); 
        
    setDefaultBarFgColor(Color.blue0); 
        
    setDefaultBarFgColor(Color.red1); 


    function 
    main() {
        var 
    avg=null;//Note: this is only used within main & is reset on every tick so it should be local
        
    var ddeAHH=null;//Note: same as above
        
    if(getBarState()==BARSTATE_ALLBARS){//Note: today only code from Alexis Montenegro 
            
    bCurrentDay=false;
        }
        if(
    bCurrentDay==false && getDay(0) != getDay(-1)){
            var 
    xTime getValue("time");
            var 
    xDate = new Date();
            var 
    sTime = (xTime.getMonth()+1+"/"+xTime.getDate()+"/"+xTime.getFullYear());
            var 
    sToday = (xDate.getMonth()+1+"/"+xDate.getDate()+"/"+xDate.getFullYear());
            if(
    sTime == sToday){
                
    bCurrentDay true;
            }
            if(
    bCurrentDay==false){
                return;
            }
        }
        
    //Note: the null checks for AAH & veMA create the series only once instead of on every tick
        
    if(AHH==nullAHH efsInternal("HHH"); //this line calls the function "range" and creates a series 
        
    if(veMA==nullveMA highest(70,AHH); //the series is used as an input to the builtin study 
         
    avg veMA.getValue(0)

        if (
    ddeAHH == null) {
            var 
    sName "AHH" getSymbol() + getInterval();
            
    sName sName.replace(/\$/g""); // remove $ from string
            
    sName sName.replace(/\#/g, ""); // remove # from string
            
    sName sName.replace(/\-/g"");
            
    sName sName.replace(/\(/g"");
            
    sName sName.replace(/\)/g"");
            
    sName sName.replace(/\ /g"_"// replace space with underscore
            
    debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
            
    ddeAHH = new DDEOutput(sName);
        } 
        
    ddeAHH.set(avg);

        return 
    avg;



    //var DClose = null;//Note: not used
    //var Highest= null;//not needed as global or local

    //this is the separate function that calculates the range 
    function HHH() { 
        
    //Highest = Math.abs(high(0) - low(0));//Note: no variable is needed if it's the only return value
        //return Highest;
        
    return Math.abs(high(0) - low(0));

    Wayne
    Last edited by waynecd; 03-12-2013, 07:25 AM.

    Comment


    • #3
      Thanks for the reply Wayne, Ive put this up on a chart, but I'm not exactly sure what this is doing though. The lookback period for highest is still 70. I would like the period to be the bars since first bar of day so it tracks the highest range of the day since the open. The last bar of the day will reflect the highest range of the day and start again the following day from the first bar.
      Thanks

      Comment


      • #4
        maninjapan
        Just define - in whatever way you want - your first bar of the day and store its range then from that bar onwards compare the stored and current range values and store the highest of the two. See the enclosed screenshot for a basic example of this
        Search the forum and you will find other examples of how to do this using also loops etc as the topic has been covered before
        Alex




        Originally posted by maninjapan View Post
        I am using the following to keep track of the highest range of a specific period. I am currently using a fixed period of 70, but I would like to return the highest range of the trading day. To do this, I would like to change this from a fixed number to 'bars since first bar of day' is there an easy way to code this in esignal? ( I use this in other software but Im not familiar with coding in esignal)>

        Thanks,

        Code:
        var ddeAHH=null; 
        var AHH=null;
        var veMA=null;
        var avg=null
        
        
        
        function preMain() { 
        
            setStudyTitle("Highest High Range"); 
            setCursorLabelName("Range", 0); 
            setCursorLabelName("Average", 1); 
            setPlotType(PLOTTYPE_HISTOGRAM, 0); 
            setDefaultBarFgColor(Color.blue, 0); 
            setDefaultBarFgColor(Color.red, 1); 
             
         
        
        } 
        
        function main() {
        
         AHH = efsInternal("HHH"); //this line calls the function "range" and creates a series 
             veMA = highest(70,AHH); //the series is used as an input to the builtin study 
           
             avg = veMA.getValue(0)
        
            if (ddeAHH == null) {
                var sName = "AHH" + getSymbol() + getInterval();
                sName = sName.replace(/\$/g, ""); // remove $ from string
                sName = sName.replace(/\#/g, ""); // remove # from string
                sName = sName.replace(/\-/g, "");
                sName = sName.replace(/\(/g, "");
                sName = sName.replace(/\)/g, "");
                sName = sName.replace(/\ /g, "_") // replace space with underscore
                debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
                ddeAHH = new DDEOutput(sName);
            } 
                ddeAHH.set(avg);
        
                return avg;
        
        } 
        
        
        var DClose = null;
        var Highest= null;
        
        //this is the separate function that calculates the range 
        function HHH() { 
        
                
                    Highest = Math.abs(high(0) - low(0));
           
            
            return Highest;
            
            
        
        }

        Comment

        Working...
        X