Hi All. Is it possible to modify the built-in envelope indicator to use Open Close / 2 as the price source?
Announcement
Collapse
No announcement yet.
Envelope OpenClose/2
Collapse
X
-
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.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.blue, 2);
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(Length, Percent){
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, 07:27 PM.
-
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
-
Have a look at this thread and try to use the alert .efs I posted recently.
See how you get on... if you really get stuck I'm at [email protected]
Regards
Nigel
Comment
Comment