Announcement

Collapse
No announcement yet.

Envelope OpenClose/2

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

  • Envelope OpenClose/2

    Hi All. Is it possible to modify the built-in envelope indicator to use Open Close / 2 as the price source?

  • #2
    This should do it, although it doesn't seem to make a lot of difference
    to the original 'Envelope' in custom indicators.
    Regards
    Nigel

    PHP Code:
    /*************************************************************
    | Alexis C. Montenegro © July 2003                           |
    | Use and/or modify this code freely. If you redistribute it |
    | please include this and/or any other comment blocks and a  |
    | description of any changes you make.                       |
    |                                                            |
    | Modified to use (open(0)+close(0))/2.  Jan 2013 by red49er |
    |*************************************************************/ 

    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Modified_Envelope");
        
    setCursorLabelName("EnvUpr"0);
        
    setCursorLabelName("EnvBas"1);
        
    setCursorLabelName("EnvLwr"2);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarFgColor(Color.red1);
        
    setDefaultBarFgColor(Color.blue2);
        
    setDefaultBarThickness(1,0);
        
    setDefaultBarThickness(1,1);
        
    setDefaultBarThickness(1,2);
        
        var 
    fp1 = new FunctionParameter("Length"FunctionParameter.NUMBER);
        
    fp1.setLowerLimit(1);        
        
    fp1.setDefault(20); //Edit this value to set a new default
        
        
    var fp2 = new FunctionParameter("Percent"FunctionParameter.NUMBER);
        
    fp2.setLowerLimit(0);    
        
    fp2.setDefault(1);  //Edit this value to set a new default (0.1 to 100) percent
        //tested on forex EURUSD at 1%
    }
    var 
    xOpCl null;
    var 
    xUpEnv null;
    var 
    xMidEnv null;
    var 
    xLoEnv null;
    var 
    Type true;        //use exponential moving average; false = sma
    var bInit false;

    function 
    main(LengthPercent){

        if(
    bInit == false){
            
    xOpCl   efsInternal("OpenClose");      
            
    xUpEnv  getSeries(upperEnv (Length,Type,Percent,getSeries.xOpCl));
            
    xMidEnv getSeries(middleEnv(Length,Type,Percent,getSeries.xOpCl));
            
    xLoEnv  getSeries(lowerEnv (Length,Type,Percent,getSeries.xOpCl));
            
    bInit true;
        }

      return new Array(
    xUpEnv.getValue(0), xMidEnv.getValue(0), xLoEnv.getValue(0));
    }
    function 
    OpenClose(){
      return (
    open(0)+close(0))/2;

    Last edited by red49er; 01-12-2013, 06:27 PM.

    Comment


    • #3
      Hi Nigel,

      Thanks very much for that. Exactly what I needed. (Thanks to Alexis too.) Much appreciated.

      Regards,
      Paul.

      Comment


      • #4
        Glad to help out...

        Comment


        • #5
          Hi,

          Is it possible to add a parameter to display an alert when the close price comes within a certain percentage of the upper or lower channel please? I've tried adapting alert code from the forum here but am new to EFS and am struggling. It would have to operate on the current bar without beeping on every tick if possible - only when it crosses the threshold.

          Thanks and regards,
          Paul.

          Comment


          • #6
            Have a look at this thread and try to use the alert .efs I posted recently.
            http://forum.esignal.com/showthread....tion-parameter
            See how you get on... if you really get stuck I'm at [email protected]

            Regards
            Nigel

            Comment

            Working...
            X