{ Indicator: _CrossOverMA Purpose: on chart: shows fast and slow simple moving averages on radarscreen: shows price, fast and slow moving averages, and number of bars since MA crossover has occurred Note in RS: sort BarsLong in descending order to see all stocks that just recently had Long Trigger sort BarsShort in descending order to see all stocks that just recently had Short Trigger Author: MarkSanDiego Version: 06/22/08 initial 02/08/14 code cleaned } input: Price(close), FastLength(12), SlowLength(26), UpColor(green), DnColor(red); var: FastMA(0), SlowMA(0), Dir(0), // trade direction BarsLong(100), // bars since Long trigger BarsShort(100), // bars since Short trigger RS( GetAppInfo(aiApplicationType) = 2 ); // true if indicator inserted in a Radarscreen FastMA = AverageFC(Price, FastLength); // test with simple moving average so others can try SlowMA = AverageFC(Price, SlowLength); If Dir = 1 then BarsLong = BarsLong + 1; if Dir = -1 then BarsShort = BarsShort + 1; if RS then Plot1(Price,"Price"); Plot2(FastMA,"Fast MA"); Plot3(SlowMA, "Slow MA"); if FastMA crosses over SlowMA then begin BarsLong = 0; Dir = 1; if RS then begin // radarscreen SetPlotColor(1, black); SetPlotBGColor(1, UpColor); end else begin SetPlotColor(1, UpColor); // chart end; end; If FastMA crosses under SlowMA then begin BarsShort = 0; Dir = -1; if RS then begin // radarscreen SetPlotColor(1, black); SetPlotBGColor(1, DnColor); end else begin // chart SetPlotColor(1, DnColor); end; end; if RS then begin if Dir = 1 then begin Plot4(BarsLong,"Bars Long", black); SetPlotBGColor(4, UpColor); end; if Dir = -1 then begin Plot5(BarsShort,"Bars Short", black); SetPlotBGColor(5, DnColor); end; end;