Triangular Moving Average (TMA) Bands

KelvinHand

Well-Known Member
#1
TMA Bands mentioned in few forums, mostly MT4,
Here the modification using fibo numbers.

This is the sample code given:


sample code
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();
 
Last edited:
#2
Thanks KelvinHand. But the problem is that I use neither MT4 nor Amibroker, so I don't understand this code.

But my software does provide for TMA, so can you please post the logic of this strategy in plain language ?

Also, please post a chart so that we can understand this.
 

KelvinHand

Well-Known Member
#3
Thanks KelvinHand. But the problem is that I use neither MT4 nor Amibroker, so I don't understand this code.

But my software does provide for TMA, so can you please post the logic of this strategy in plain language ?

Also, please post a chart so that we can understand this.

Look at the tma band at the price chart:
http://www.traderji.com/metatrader/74616-controversial-indicator-pollan-new-experiments.html

I think the logic of this strategy in plain language: BUY LOW SELL HIGH!
 
Last edited:

KelvinHand

Well-Known Member
#4
If i reconstruct the sample code, it can be seen like this:


Code:
HalfLength      = Param("HalfLength", 61, 1, 999);
ATRPeriod       = Param("ATRPeriod", 110,1,1000);

ATRMultiplier1   = Param("ATR Multiplier 1", 1.8);
ATRMultiplier2   = Param("ATR Multiplier 2", 2.2);
ATRMultiplier3   = Param("ATR Multiplier 3", 2.6);

ATRMultiplier4   = Param("ATR Multiplier 4", 3.0);
ATRMultiplier5   = Param("ATR Multiplier 5", 3.4);
ATRMultiplier6   = Param("ATR Multiplier 6", 3.8);

ATRMultiplier7   = Param("ATR Multiplier 7", 4.2);
ATRMultiplier8   = Param("ATR Multiplier 8", 4.6);
ATRMultiplier9   = Param("ATR Multiplier 9", 5.0);


cMidB = ParamColor("Mid Band", colorGreen);
cUprB = ParamColor("Upper Band", colorRed);
cLwrB = ParamColor("Lower Band", ColorRGB(30,144,255));

HalfLength=Max(HalfLength,1);

midBand = Null;

 p = Close;
 sma = MA(P, 1);
 iatr= ATR(ATRPeriod);

 iLmt = BarCount-1 - (HalfLength);
  
 for (i=0; i<BarCount; i++)
 {
 
    dSum = (HalfLength+1)* sma[i];
    sumw = (HalfLength+1);
         
    for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
    {
        if(i+j>=BarCount) break;

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

        if (j<=i)
        {
          dSum  += k*sma[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;


 UprBand4 = MidBand+iATR*ATRMultiplier4;
 LwrBand4 = MidBand-iATR*ATRMultiplier4;

 UprBand5 = MidBand+iATR*ATRMultiplier5;
 LwrBand5 = MidBand-iATR*ATRMultiplier5;

 UprBand6 = MidBand+iATR*ATRMultiplier6;
 LwrBand6 = MidBand-iATR*ATRMultiplier6;


 UprBand7 = MidBand+iATR*ATRMultiplier7;
 LwrBand7 = MidBand-iATR*ATRMultiplier7;

 UprBand8 = MidBand+iATR*ATRMultiplier8;
 LwrBand8 = MidBand-iATR*ATRMultiplier8;

 UprBand9 = MidBand+iATR*ATRMultiplier9;
 LwrBand9 = MidBand-iATR*ATRMultiplier9;

Plot(MidBand, "MidBand",  cMidB, styleNoLabel|styleNoTitle);

Plot(UprBand1, "UprBand1", cUprB, styleNoLabel|styleNoTitle);
Plot(LwrBand1, "LwrBand1", cLwrB, styleNoLabel|styleNoTitle);

Plot(UprBand2, "UprBand2", cUprB, styleNoLabel|styleNoTitle|styleBar);

Plot(LwrBand2, "LwrBand2", cLwrB, styleNoLabel|styleNoTitle|styleBar);

Plot(UprBand3, "UprBand3", cUprB, styleNoLabel|styleNoTitle|styleBar);
Plot(LwrBand3, "LwrBand3", cLwrB, styleNoLabel|styleNoTitle|styleBar);


Plot(UprBand4, "UprBand4", cUprB, styleNoLabel|styleNoTitle|styleBar);
Plot(LwrBand4, "LwrBand4", cLwrB, styleNoLabel|styleNoTitle|styleBar);


Plot(UprBand5, "UprBand5", cUprB, styleNoLabel|styleNoTitle|styleBar);
Plot(LwrBand5, "LwrBand5", cLwrB, styleNoLabel|styleNoTitle|styleBar);


Plot(UprBand6, "UprBand6", cUprB, styleNoLabel|styleNoTitle|styleBar);
Plot(LwrBand6, "LwrBand6", cLwrB, styleNoLabel|styleNoTitle|styleBar);


Plot(UprBand7, "UprBand7", cUprB, styleNoLabel|styleNoTitle);
Plot(LwrBand7, "LwrBand7", cLwrB, styleNoLabel|styleNoTitle);

Plot(UprBand8, "UprBand8", cUprB, styleNoLabel|styleNoTitle|styleThick);
Plot(LwrBand8, "LwrBand8", cLwrB, styleNoLabel|styleNoTitle|styleThick);

Plot(UprBand9, "UprBand9", cUprB, styleNoLabel|styleNoTitle|styleThick);
Plot(LwrBand9, "LwrBand9", cLwrB, styleNoLabel|styleNoTitle|styleThick);
 
Last edited:
#5
Kelvin - had to reply since my name is Michael Hand and not too many with that surname. I'm interested in TMA (true/nrp version) but don't know how to deal with loads of code. I use mt4 and only understand how to load an indi if it's ex4 or mq4.
 

amibrokerfans

Well-Known Member
#6
Dear Sir,

I only know better in Amibroker & MetaTrader.
There are plenty of code resources can be found in the website.
I just need to cut and paste within hour to come out the script.
So only Simple and Easy, No other consideration.
dear KelvinHand

i want to draw yr attention on below pic. its from 9.10.2012 to 25.10.2012, 1H TF, EURUSD.
red line for sell. green line for buy. white line for exit.
u can see almost all 15 trades r ended with win!( 1 or 2 with minimum loss )
its about ssa end-point(adv) and tma band.

dear, did u work on ssa??

 
Last edited:

KelvinHand

Well-Known Member
#8
dear KelvinHand

i want to draw yr attention on below pic. its from 9.10.2012 to 25.10.2012, 1H TF, EURUSD.
red line for sell. green line for buy. white line for exit.
u can see almost all 15 trades r ended with win!( 1 or 2 with minimum loss )
its about ssa end-point(adv) and tma band.

dear, did u work on ssa??

Saw the MT4 code, quite complex. not easy. Need a lot of Brain Power
 

KelvinHand

Well-Known Member
#9
Kelvin - had to reply since my name is Michael Hand and not too many with that surname. I'm interested in TMA (true/nrp version) but don't know how to deal with loads of code. I use mt4 and only understand how to load an indi if it's ex4 or mq4.
If you had HANDon MT4 ex4 & mq4 before, not too difficult for you with Amibroker. Just that whether you want to dirty you HAND with AFL.

Copy and Paste the script into a text editor and save it, click or drag drop that it.
 

Similar threads