Could not see how calling the function @mradtke presented twice would give me what I wanted. It doesn't reference the base interval anywhere. But it did give me the idea of how to create a function to call twice and then do a ratio.

```
//--- Create values globally so they only have to calculated once
Daily = inHourly * 6.464; Weekly = Daily * 4.846; Monthly = Daily * 21; Quarterly = Daily * 63; Yearly = Daily * 252;
function TimeAdj(Time) { // Adjust time values to give desired ratios
global Hourly, Weekly, Monthly, Quarterly, Yearly;
switch (Time) {
case inHourly: result = Time; break;
case inDaily: result = Daily; break;
case inWeekly: result = Weekly; break;
case inMonthly: result = Monthly; break;
case inQuarterly: result = Quarterly; break;
case inYearly: result = Yearly; break;
default: result = Time / inHourly; break;;
} return result;
}
function BarsAdj (Bars, Time) {
factor = TimeAdj(Time) / TimeAdj(Interval()); if (Time > Interval()) factor = round(factor);
return Bars * factor;
}
function TAMA (Array, Bars, Time) { // Time adjusted moving average
if (Time > 0) Array = TimeFrameCompress(Array, Time); // Change time frame
else if (Time < 0) Bars = BarsAdj(Bars, abs(Time)); // Convert bars to current time frame
result = MA(Array, Bars); // Calculate moving average
if (Time > 0) result = TimeFrameExpand(result, Time); // Convert results back to current time
return result;
}
```

The last function is an example of how the time adjustment would be used for the MA() function.

If Time is 0, the function returns the same as just calling MA() with the specified number of bars. TAMA(C, 20, 0) is the same as MA(C, 20) based on the current time interval.

If the value of Time > 0, calculate the MA with bar length from the specified Time. TAMA(C, 20, inWeekly) keeps the moving average calculation on the weekly time interval no matter what the current time interval is.

If the value of Time < 0, convert the bar count from the base time to the current time. TAMA(C, 20, -inWeekly) so the MA will be pretty close to the original weekly moving average no matter what the current time frame is. If current time frame is daily, the MA would be converted a 100 bar daily MA.

The new moving average function now handles all three ways of calculating the moving average in relation to differing time frames. A similar approach could be used a lot of other indicators.

I was hoping for a simpler way of doing this, but this is as good as I came up with following Tomasz's suggestion.