# Bolton Smith TMA

Hey,
I’d like to play around with a new script idea.

I’d like to test out Bolton Smith’s TMA.

My understand is that we need to wait for a clustering of the triple moving average (5,15,30)… Clustering to me is when they come, perhaps within 0.5% of each other.

Then I want to see when the 15 period moves above 30, with the 5 on top. And then I want to see where the 5 falls below the 15.
is this something that can also be backtested. ?

Thanks Jonathan. Sure - you can use a couple of WITHINRANGE() functions for when any values are within X% of each other:

```MA1 = MA(BARS=5, CALC=Close);
MA2 = MA(BARS=15, CALC=Close);

WITHINRANGE(MA1, MA2, PERCENT=0.50)```

For the other test you can use something like this:

`(MA15 CrossesAbove MA30) and (MA5 > MA15)`

[postquote quote=65063]

```Hmm what did I do wrong here?

```
`MA1 = MA(BARS=5, CALC=Close); MA2 = MA(BARS=15, CALC=Close); MA3 = MA(BARS=30, CALC=Close); WITHINRANGE(MA1, MA2, MA3, PERCENT=0.10)`

Also this one came up.

You can only have two variables in a WITHINRANGE() function, so if using three MAs you would need two WITHINRANGE() functions.