DYO: Rainbow Oscillator example


Q:  I have recently begun an effort to finally get rid of my old TS2000i and use only Ensign and have run into a snag.  I'm having a real problem trying to convert Easy Language into DYO's.  So I was hoping you could convert this one script for me.  It's relatively simple and perhaps I can use it as a blueprint of sorts to help me get started with DYO's. It's called Rainbow Oscillator (from TASC magazine) and certainly could be shared with other Ensign users.

Easy Language Script:

RAINBOWOSC {Function}

INPUTS: PRICE(NUMERIC),LENGTH(NUMERIC),LEVAL(NUMERIC);
VARS: AVGAVGS(0),HIPRICE(0),LOPRICE(0),AVGVAL(0);
ARRAY: AVG[10](0);

AVGAVGS=0;
AVG[1]=average(PRICE,LENGTH);
AVG[2]=average(AVG[1],LENGTH);
AVG[3]=average(AVG[2],LENGTH);
AVG[4]=average(AVG[3],LENGTH);
AVG[5]=average(AVG[4],LENGTH);
AVG[6]=average(AVG[5],LENGTH);
AVG[7]=average(AVG[6],LENGTH);
AVG[8]=average(AVG[7],LENGTH);
AVG[9]=average(AVG[8],LENGTH);
AVG[10]=average(AVG[9],LENGTH);

HIPRICE=HIGHEST(PRICE,LEVAL);
LOPRICE=LOWEST(PRICE,LEVAL);
FOR VALUE1=1 TO LEVAL BEGIN
  AVGAVGS=AVGAVGS+AVG[VALUE1];
END;
AVGVAL=AVGAVGS/LEVAL;

IF HIPRICE-LOPRICE <> 0 THEN
  RAINBOWOSC=100*((CLOSE-AVGVAL)/(HIPRICE-LOPRICE));

Rainbow Oscillator {Indicator}

INPUTS: P(CLOSE), LEN(6),LEVALS(6);
VARS: POSNEG(0); {len(0);
len=Jrc_Fractal24(c,4)/4;}

IF CURRENTBAR > LEN *LEVALS THEN BEGIN
  {PLOT1(RAINBOWBW(P,LEN,LEVALS),"URB");}
  PLOT2(0,"0");{(-RAINBOWBW(P,LEN,LEVALS),"LRB");}
POSNEG=RAINBOWOSC(P,LEN,LEVALS);

IF POSNEG > 0 THEN
  PLOT3(POSNEG,"RAINBOWOSC")
ELSE
  PLOT4(POSNEG,"RAINBOWOSC");
END;

A:  I think this is the implementation of your EasyLanguage example.

Template:  1345-RainbowOsc

The implementation requires the use of 2 DYO studies and the configuration of each is shown above.  Have the 1st DYO do all the averages, and the 2nd DYO do the rainbow oscillator formula.   I think the visual of what you want plotted is accomplished with the Histogram marker shown.

The LEN parameters are the 6 values in the 1st DYO in the Number fields on the 10 lines.
The LEVAL parameter is the Number field (also a 6) on the 2nd DYO's Lines A, B and C.

Template:  1345-RainbowOsc


Last modified 8/8/08 12:32 PM