# Triangular Moving Average (TMA) Bands

#### KelvinHand

##### Well-Known Member
TMA Bands mentioned in few forums, Here the modified sample using fibo numbers.

You need to drag n drop to the price chart.

Code:
``````_SECTION_BEGIN("TrueTMABand");
HalfLength      = Param("HalfLength", 63, 1, 999);
ATRPeriod       = Param("ATRPeriod", 110,1,1000);

ATRMultiplier1   = Param("ATR Multiplier 1", 2.1);
ATRMultiplier2   = Param("ATR Multiplier 2", 3.4);
ATRMultiplier3   = Param("ATR Multiplier 3", 5.5);

cMidB = ParamColor("Mid Band", colorGreen);

cUprB1 = ParamColor("Upper Band 1", colorRed);
cLwrB1 = ParamColor("Lower Band 1", colorBlue);

cUprB2 = ParamColor("Upper Band 2", colorRed);
cLwrB2 = ParamColor("Lower Band 2", colorBlue);

cUprB3 = ParamColor("Upper Band 3", colorRed);
cLwrB3 = ParamColor("Lower Band 3", colorBlue);

HalfLength=Max(HalfLength,1);

midBand = Null;
uprBand = Null;
LwrBand = Null;

iatr= ATR(ATRPeriod+10);

for (i=0; i<BarCount; i++)
{

dSum = (HalfLength+1)* Close[i];
sumw = (HalfLength+1);

for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
{
if(i+j>=BarCount) break;

dSum  += k* Close[i+j];
sumw += k;

if (j<=i)
{
dSum  += k*Close[i-j];
sumw += k;
}
}

MidBand[i] = dSum/sumw;

}

UprBand1 = MidBand+iATR*ATRMultiplier1;
LwrBand1 = MidBand-iATR*ATRMultiplier1;

UprBand2 = MidBand+iATR*ATRMultiplier2;
LwrBand2 = MidBand-iATR*ATRMultiplier2;

UprBand3 = MidBand+iATR*ATRMultiplier3;
LwrBand3 = MidBand-iATR*ATRMultiplier3;

Plot(MidBand, "MidBand",  cMidB);

Plot(UprBand1, "UprBand1", cUprB1);
Plot(LwrBand1, "LwrBand1", cLwrB1);

Plot(UprBand2, "UprBand2", cUprB2);
Plot(LwrBand2, "LwrBand2", cLwrB2);

Plot(UprBand3, "UprBand3", cUprB3);
Plot(LwrBand3, "LwrBand3", cLwrB3);
_SECTION_END();``````