Study Example 3
Previous  Top  Next

A/D Oscillator using the ExpMovingAverageOfFunc:

Another way to do this is a compromise between the one-day-at-a-time method and the all-the-days-at-once method. Here we have a separate study one-day-at-a-time study for the base indicator. We call ExpMovingAverageOfFunc which calls the base indicator and does the exponential smoothing of it.

sub ComputeDRF3 {
my($range) = getHigh($ioffset)-getLow($ioffset);
if($range<1e-6) {
return 0.5;
return (getHigh($ioffset) - getOpen($ioffset) +
getClose($ioffset) - getLow($ioffset))/2/$range;
sub ComputeADOscillator3 {
return ExpMovingAverageOfFunc { ComputeDRF3(@_) } 0, 0.3;

The base indicator study ComputeDRF3 computes the range and returns the value for the day $ioffset. The ComputeADOscillator3 indicator calls ExpMovingAverageOfFunc to exponentially smooth the base indicator with a smoothing constant of 0.3.