#property copyright "© 2009 BJF Trading Group inc."
#property link "www.iticsoftware.com"
#define major 1
#define minor 0
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#property indicator_style1 DRAW_HISTOGRAM
#property indicator_style2 DRAW_HISTOGRAM
#property indicator_width1 2
#property indicator_width2 2
#property indicator_maximum 5.0
#property indicator_minimum -5.0
extern int MA1.period = 5;
extern int MA1.shift = 0;
extern int MA1.method = MODE_EMA;
extern int MA1.applied_price = PRICE_CLOSE;
extern int MA2.period = 10;
extern int MA2.shift = 0;
extern int MA2.method = MODE_EMA;
extern int MA2.applied_price = PRICE_CLOSE;
extern int MA3.period = 20;
extern int MA3.shift = 0;
extern int MA3.method = MODE_EMA;
extern int MA3.applied_price = PRICE_CLOSE;
extern int MA4.period = 50;
extern int MA4.shift = 0;
extern int MA4.method = MODE_EMA;
extern int MA4.applied_price = PRICE_CLOSE;
extern int MA5.period = 100;
extern int MA5.shift = 0;
extern int MA5.method = MODE_EMA;
extern int MA5.applied_price = PRICE_CLOSE;
double MAUpperBuf[];
double MALowerBuf[];
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void init()
{
SetIndexBuffer(0, MAUpperBuf);
SetIndexBuffer(1, MALowerBuf);
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexStyle(1, DRAW_HISTOGRAM);
SetIndexEmptyValue(0, 0.0);
SetIndexEmptyValue(1, 0.0);
/*
SetLevelValue(1, 1.0);
SetLevelValue(2, 2.0);
SetLevelValue(3, 3.0);
SetLevelValue(4, -1.0);
SetLevelValue(5, -2.0);
SetLevelValue(6, -3.0);
*/
IndicatorShortName("i-5MA");
}
void deinit()
{
}
void start()
{
int counted_bars = IndicatorCounted();
if (counted_bars < 0) return;
if (counted_bars > 0) counted_bars--;
int limit = Bars-counted_bars;
for (int i=limit-1; i >= 0; i--)
{
double MA1 = iMA(NULL, 0, MA1.period, MA1.shift, MA1.method, MA1.applied_price, i);
double MA2 = iMA(NULL, 0, MA2.period, MA2.shift, MA2.method, MA2.applied_price, i);
double MA3 = iMA(NULL, 0, MA3.period, MA3.shift, MA3.method, MA3.applied_price, i);
double MA4 = iMA(NULL, 0, MA4.period, MA4.shift, MA4.method, MA4.applied_price, i);
double MA5 = iMA(NULL, 0, MA5.period, MA5.shift, MA5.method, MA5.applied_price, i);
MAUpperBuf[i] = 0.0;
MALowerBuf[i] = 0.0;
if (MA1 > MA2) MAUpperBuf[i] = 1.0;
if (MA1 > MA2 && MA2 > MA3) MAUpperBuf[i] = 2.0;
if (MA1 > MA2 && MA2 > MA3 && MA3 > MA4) MAUpperBuf[i] = 3.0;
if (MA1 > MA2 && MA2 > MA3 && MA3 > MA4 && MA4 > MA5) MAUpperBuf[i] = 4.0;
if (MA1 < MA2) MALowerBuf[i] = -1.0;
if (MA1 < MA2 && MA2 < MA3) MALowerBuf[i] = -2.0;
if (MA1 < MA2 && MA2 < MA3 && MA3 < MA4) MALowerBuf[i] = -3.0;
if (MA1 < MA2 && MA2 < MA3 && MA3 < MA4 && MA4 < MA5) MALowerBuf[i] = -4.0;
}
}