I am wondering whether McClellan Oscillator has been implemented and shared somewhere on this web site? If so, I don't need to rewrite the efs by myself. Thanks in advance.
McClellan Oscillator:
-------------------------------------------------------------------------
Function preMain() {
setStudyTitle("McClellan Oscillator");
addBand(0, PS_SOLID, 1, Color.lightgrey);
}
function main() {
var v = getValue("Open", 0, -39,"$ADD");
var sum = 0, s = 0, i = 0;
for(i = 0; i < 39; i++){
sum += v[i];
if(i < 19)
s += v[i];
}
return s / 19 - sum / 39
}
McClellan Summation index
-------------------------------------------------------------------------
Function preMain() {
//setPriceStudy(true);
setStudyTitle("Summation index");
addBand(0, PS_SOLID, 1, Color.lightgrey);
}
var sumi = 0;
function main() {
var v = getValue("Open", 0, -39,"$ADD");
var sum = 0, s = 0, i = 0;
for(i = 0; i < 39; i++){
sum += v[i];
if(i < 19)
s += v[i];
}
sumi += s / 19 - sum / 39;
return sumi;
}
I have tried unsucessfully several times to use these formulas but cannot because of syntax problems in line 1 .Could you please take another look at these formulas
The following formula should do everything you need. It has the option to have the moving average calculated as simple or exponential and also has the option to turn the summation on or off through the "Edit Studies" option.
JT47319
Other than the fact that the y-axis values are different in the Decision Point chart (they do note Ratio Adjusted on the Oscillator and Summation Index) the plots appear to be identical both in shape and in proportions.
I also traced some vertical lines at the turning points and they also seem to match.
Make sure you have the Exponential turned on because by default it is off.
Alex
JT47319
The attached modified efs should do what you asked. In the sample image below the original Summation Index is shown together with the revised plot
The lines and/or sections of code added by me are all commented.
Alex
Edit after post: See above in this thread for a revised version of the McClellan Oscillator
Mr. Montenegro:
Do you think you could add an option to add a Moving Average or an Expontial MA to your McClellan OSC2 formula?
Also, can you have the option to make the OSC line thicker for us blind folks? Thanks for your help......Greg
did you ever try this on a live chart? When I do and put it in the SI mode, it loads correctly. Then after a short time the current data point of the line shoots way up, or down, depending I guess on whether the new point is plus or minus.
Anyway, just wondered, maybe I have something screwed up.
By the way, why did you choose to use the open instead of the close?
bigtee
With regards to using the Open you may want to redirect the question to the person who wrote the efs. All I did was add the logic to paint the histogram.
Alex
Comment