This is created by Karthik marar sir...don't know whether it will help u or not...
Enjoy...
HTML:
//Step MA Based on the Popular MetaTrader Indicator
//Version V.1.0 dated 18-07-2012
//Coded by Karthik Marar
//Copyright www.tatechnics.in
//======================== Indicator============================
_SECTION_BEGIN("StepMA");
Kv = Param("Sensitivity", 1.25,0.1,2,0.1);
PeriodWATR = Param("PeriodWATR",14,1,100,1);
AvgRange[0]=0;
for (i=PeriodWATR-1;i>=0;i--)
{
dK = 1+1.0*(PeriodWATR-i)/PeriodWATR;
AvgRange=AvgRange+ dK*abs(High[i]-Low[i]);
}
WATR = AvgRange/PeriodWATR;
StepSize=Kv*WATR;
smax = Low+2*StepSize;
smin = High-2*StepSize;
trend[0] = 1;
Linebuffer[0] = C[0];
Linemax[0] = C[0];
Linemin[0] = C[0];
Linemid[0] = C[0];
for(i = PeriodWatr; i < BarCount; i++)
{
if(Close[i]>smax[i-1]) trend[i]=1;
else
{
if(Close[i]<smin[i-1]) trend[i]=-1;
else
trend[i] = trend[i-1];
}
//--------------------
if(trend[i] > 0 AND smin[i]<smin[i-1]) smin[i]=smin[i-1];
if(trend[i] < 0 AND smax[i]>smax[i-1]) smax[i]=smax[i-1];
if (trend[i] >0 ) LineBuffer[i]=smin[i]+StepSize[i];
else
{
if (trend[i] <0) LineBuffer[i]=smax[i]-StepSize[i];
else
LineBuffer[i] = LineBuffer[i-1];
}
}
Plot (lineBuffer,"",colorYellow,1);
Plot (C,"StepMA V.1.0",IIf(C>Linebuffer,colorLime,colorRed),styleBar);
_SECTION_END();
_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
GfxSetTextColor( ColorHSB( 82, 82, 82 ) );
GfxSetBkMode(0);
GfxSelectFont("Tahoma", Status("pxheight")/12 );
GfxTextOut( "StepMA", Status("pxwidth")/2, Status("pxheight")/3 );
GfxSelectFont("Tahoma", Status("pxheight")/36 );
GfxTextOut( "www.Tatechnics.in", Status("pxwidth")/2, Status("pxheight")/2 );
_SECTION_END();_SECTION_END();
You will see the instability OR so called repaint when used.