Tuesday, July 5, 2011

Amibroker Code: NYSE McClellan Oscillator

Below is the code I use to caclculate $NYMO in Amibroker. It is the ratio adjusted version described by Stockcharts.com.  This code will only work if your data provider has advancing and declining issues.  My data provider is Norgate, so if you are not using them, replace the #NYSEADV and #NYSEDEC with the appropriate symbols.


-------------------------------------------------------------------------------------------------------------------------
/*

McClellan Oscillator

*/

SetForeign("#NYSEADV");

adv = C;

RestorePriceArrays();



SetForeign("#NYSEDEC");

dec = C;

RestorePriceArrays();



Rana = (adv - dec)/(adv+dec);

NAMa = EMA( rana, 19 ) - EMA( rana, 39);

r =NAMa*1000;

Plot( NAMa*1000, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style")  );

PlotOHLC( r,r,50,r, "", IIf( r > 50, colorRed, colorGreen ), styleCloud | styleClipMinMax, -70, 70 );

Plot(0, "0", colorWhite);



0 comments:

Post a Comment