LSMA Indicator

 
Can someone PLEASE tell me how this EA is printing the colors on the chart?? I cannot see how the individual colors are determiend and then displayed on the chart?! Is there an alternative to this LSMA indicator that I can understand better?? Here is the code....

//+------------------------------------------------------------------+
//| |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, FX Sniper "
#property link "https://www.metaquotes.net/
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Green
#property indicator_color3 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
int width;
extern int Rperiod = 20;
extern int Draw4HowLongg = 1500;
int Draw4HowLong;
int shift;
int i;
int loopbegin;
double sum[];
int length;
double lengthvar;
double tmp ;
double wt[];
int c;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{

//---- 2 additional buffers are used for counting.
IndicatorBuffers(5);

//---- drawing settings
SetIndexBuffer(2,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(0,ExtMapBuffer3);
SetIndexBuffer(3,sum);
SetIndexBuffer(4,wt);

SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,4);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,4);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,4);
//---- initialization done
return(0);

}

int start()
{
Draw4HowLong = Bars - Rperiod - 5;
length = Rperiod;
loopbegin = Draw4HowLong - length - 1;

for(shift = loopbegin; shift >= 0; shift--)
{
sum[1] = 0;
for(i = length; i >= 1 ; i--)
{
lengthvar = length + 1;
lengthvar /= 3;
tmp = 0;
tmp = ( i - lengthvar) * Close[length-i+shift];
sum[1]+=tmp;
}

wt[shift] = sum[1]*6/(length*(length+1));


//========== COLOR CODING ===========================================

ExtMapBuffer3[shift] = wt[shift]; //red
ExtMapBuffer2[shift] = wt[shift]; //green
ExtMapBuffer1[shift] = wt[shift]; //yellow


if (wt[shift+1] > wt[shift])
{
ExtMapBuffer2[shift] = EMPTY_VALUE;
}
else if (wt[shift+1] < wt[shift])
{
ExtMapBuffer1[shift] = EMPTY_VALUE; //-1 red/greem tight
}
else
{
ExtMapBuffer1[shift] = EMPTY_VALUE; //EMPTY_VALUE;
ExtMapBuffer2[shift] = EMPTY_VALUE; //EMPTY_VALUE;
}
}

return(0);
}
Reason: