Announcement

Collapse
No announcement yet.

Cumulative Average Range Up/Down

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

  • Cumulative Average Range Up/Down

    Is there an EFS that plots the cumulative average range of up bars vs down bars that starts at 9:30 (EST)?

    If not, would someone be willing to code it?

    It would be a good EFS to go along with the new "Up-Down Bar Counter" that Alex just wrote. (especially when using volume bars)

    I am not sure if plotting the cumulative average range based on 'open to close' or 'high to low' data would be best. A parameter that would allow you use either would be nice. Any other suggestions are appreciated.

    Thanks

  • #2
    Himalaya
    I am not sure I understood correctly what you are asking never the less give the enclosed efs a try.
    It calculates the High-Low or Open-Close ranges and depending on which is selected in Edit Studies runs a cumulative total for up and down bars.
    Alex



    PHP Code:
    function preMain(){

        
    setPriceStudy(false);
        
    setStudyTitle("UP-DN Range");
        
    setCursorLabelName("UP Rng",0);
        
    setCursorLabelName("DN Rng",1);
        
    setDefaultBarFgColor(Color.blue,0);
        
    setDefaultBarFgColor(Color.red,1);
        
    setComputeOnClose();

        var 
    fp1 = new FunctionParameter("Range"FunctionParameter.STRING);
        
    fp1.setName("Range");
        
    fp1.addOption("HiLo");
        
    fp1.addOption("OpCl");
        
    fp1.setDefault("HiLo"); 
    }

    var 
    vCntrUP 0;
    var 
    vCntrDN 0
    var Diff 0;

    function 
    main(Range){

        if((
    getHour()*100)+getMinute()==930){
            
    vCntrUP=0;
            
    vCntrDN 0;
        }

        if(
    Range == "HiLo"){
            
    vDiff high(0)-low(0);
        }
        if(
    Range == "OpCl"){
            
    vDiff Math.abs(open(0)-close(0));
        }

        if(
    close(0)>open(0)){
            
    vCntrUP += vDiff;
        }
        if(
    close(0)<open(0)){
            
    vCntrDN += vDiff;
        }

        return new Array (
    vCntrUP,vCntrDN);

    Comment


    • #3
      Getting there

      Alex,

      Thanks for your quick response, again.

      Sorry I wasn't clearer in my description. I probably used "cumulative" incorrectly.

      I need the efs to now take the info that you have been able to plot "the cumulative range" and divide it by the the "cumulative bar count" (up bars for up range and down bars for down range)

      What I am trying to see with just a glance ,at any point in the day, is the average range of an up bar vs average range of a down bar - to gauge if buyers have more strength than sellers.
      (So if there has been 35 up bars with a cumulative range of 17.5 pts the study would read .5)

      BTW, nice feature to be able to use the op/cl or hi/lo

      Again, sorry for the confusion

      Comment


      • #4
        Himalaya
        In that case it should only be a matter of combining the two efs. Try the enclosed version
        Alex



        PHP Code:
        function preMain(){

            
        setPriceStudy(false);
            
        setStudyTitle("UP-DN Range");
            
        setCursorLabelName("UP Rng",0);
            
        setCursorLabelName("DN Rng",1);
            
        setDefaultBarFgColor(Color.blue,0);
            
        setDefaultBarFgColor(Color.red,1);
            
        setComputeOnClose();

            var 
        fp1 = new FunctionParameter("Range"FunctionParameter.STRING);
            
        fp1.setName("Range");
            
        fp1.addOption("HiLo");
            
        fp1.addOption("OpCl");
            
        fp1.setDefault("HiLo"); 
        }

        var 
        vCntrUP 0;
        var 
        vCntrDN 0;
        var 
        vRngUP 0;
        var 
        vRngDN 0;
        var 
        Diff 0;
        var 
        vAvgRngUP 0;
        var 
        vAvgRngDN 0;

        function 
        main(Range){

            if((
        getHour()*100)+getMinute()==930){
                
        vCntrUP=0;
                
        vCntrDN 0;
                
        vRngUP 0;
                
        vRngDN 0;
            }

            if(
        Range == "HiLo"){
                
        vDiff high(0)-low(0);
            }
            if(
        Range == "OpCl"){
                
        vDiff Math.abs(open(0)-close(0));
            }

            if(
        close(0)>open(0)){
                
        vCntrUP++;
                
        vRngUP += vDiff;
            }
            if(
        close(0)<open(0)){
                
        vCntrDN++;
                
        vRngDN += vDiff;
            }
            
            
        vAvgRngUP vRngUP/vCntrUP;
            if(
        isNaN(vAvgRngUP)) vAvgRngUP 0;
            
        vAvgRngDN vRngDN/vCntrDN;
            if(
        isNaN(vAvgRngDN)) vAvgRngDN 0;


            return new Array (
        vAvgRngUP,vAvgRngDN);

        Comment


        • #5
          Thanks Alex EOM

          Thanks Alex

          Comment

          Working...
          X