Here is another channel upper and lower bands indicator, this one is made of a centered Triangular Moving Average with classic deviation from this mean, made of plus and minus ATR multiplicated value. Quiet popular in the forex trading community, it is the base of many more or less sophisticated strategy, do your homework with this one, you’ll find it is valuable for different market phase.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
// parameters // HalfLength = 50 // AtrLength = 100 // AtrMultiplier = 2.0 avg = average[1](close) sum = (HalfLength+1)*avg sumw = (HalfLength+1) k = HalfLength for j = 1 to HalfLength do k = k-1 sum = sum+(k*avg[j]) sumw = sumw+k next buffer1 = sum/sumw myrange = AverageTrueRange[AtrLength](close)*AtrMultiplier buffer2 = buffer1+myrange buffer3 = buffer1-myrange RETURN buffer1 coloured(0,220,0) as "TMA", buffer2 coloured(220,0,0) as "upper band", buffer3 coloured(0,220,0) as "lower band" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hello
please have you got the opportunity to modify code in order to obtain a centered simple moving avarage? thanks
Hi! Can you explain the ATR length and ATR half length? Should one of these nbit be the number of periods linked to TMA?
Just for information:
This calculate code is interesting, but it is not a Triangular Moving Average, but A Weighted Moving Average.
Nowadays with new version of PRT
So, to reduce the calculate time. It is possible to cancel from line 6 to 16 and change line 18 by:
Buffer1 = WeightedAverage[HalfLength](close) or
Buffer1 = average[HalfLength,2](close)
Thanks
Hola Lobo, soy nuevo en programación, pero me interesa ese indicador, en tu mensaje estas hablando en la modificación de código para adoptarlo a la nueva versión de prt, podrías colgar el código modificado competo please?
// TMA CENTER Channel by Dave modifié
// parameters
// HalfLength = 50
// AtrLength = 100
// AtrMultiplier = 2.0 perso = 3.6
// AtrLength1 = 100
// AtrMultiplier1 = perso = 6.1
avg = average[1](close)
sum = (HalfLength+1)*avg
sumw = (HalfLength+1)
k = HalfLength
for j = 1 to HalfLength do
k = k-1
sum = sum+(k*avg[j])
sumw = sumw+k
next
buffer1 = sum/sumw
myrange = AverageTrueRange[AtrLength](close)*AtrMultiplier
buffer2 = buffer1+myrange
buffer3 = buffer1-myrange
////////////////////////////////////////////////////////////
myrange1 = AverageTrueRange[AtrLength1](close)*AtrMultiplier1
buffer4 = buffer1+myrange1
buffer5 = buffer1-myrange1
////////////////////////////////////////////////////////////
RETURN buffer1 coloured(0,220,0) as “TMA”, buffer2 coloured(220,0,0) as “upper band”, buffer3 coloured(0,220,0) as “lower band”,buffer4 coloured(220,0,0) as “upper band1”, buffer5 coloured(0,220,0) as “lower band1”