Help me create Schaff MTF version



New member
Good Evening Everyone,
First post ever on this please go easy.. ;)
I am a transplant from Fidelity WealthLab since they "adjusted" their subscriptions....
I have been trading for about 25 years, so I am not a newbie to that portion of the game....
I have been following along the forum for about a month..
I have been trying to learn the code from all the great authors here....and I must say...I like the Thinkscript coding language....very simple....
and the GUI itself is pretty user to my question....
I am currently using the TMO_MTF (thx to Mobius and all the ones who came behind tweaking the visuals)
I also like Schaff, but am having trouble writing the code to produce a valid MTF display with all 3 indicators....(in this case 3m, 15m, 1H)
When I set the timeframe to 3m, the 3m line is fine, but the 15m and hourly are very coarse.....stair-stepped if you will...
Any help in correcting this would be greatly appreciated....thx (and I did hunt around the board, but could not find the version I am looking for or a solution inside of another code to fix the issue)

declare lower;

input fastLength = 23;
input slowLength = 50;
input KPeriod = 10;
input DPeriod = 3.0;
input over_bought = 95;
input over_sold = 5;
input averageType = AverageType.Exponential;

input agg = AggregationPeriod.THREE_MIN;
def macd = MovingAverage(averageType, close(period =agg), fastLength) - MovingAverage(averageType, close(period = agg), slowLength);
def fastK1 = FastKCustom(macd, KPeriod);
def fastD1 = MovingAverage(averageType, fastK1, DPeriod);
def fastK2 = FastKCustom(fastD1, KPeriod);
plot STC = MovingAverage(averageType, fastK2, DPeriod);
plot OverBought = over_bought;
plot OverSold = over_sold;

input agg1 = AggregationPeriod.FIFTEEN_MIN;
def macd1 = MovingAverage(averageType, close(period =agg1), fastLength) - MovingAverage(averageType, close(period = agg1), slowLength);
def fastK1_1 = FastKCustom(macd1, KPeriod);
def fastD1_1 = MovingAverage(averageType, fastK1_1, DPeriod);
def fastK2_1 = FastKCustom(fastD1_1, KPeriod);
plot STC_1 = MovingAverage(averageType, fastK2_1, DPeriod);

input agg2 = AggregationPeriod.HOUR;
def macd2 = MovingAverage(averageType, close(period =agg2), fastLength) - MovingAverage(averageType, close(period =agg2), slowLength);
def fastK1_2 = FastKCustom(macd2, KPeriod);
def fastD1_2 = MovingAverage(averageType, fastK1_2, DPeriod);
def fastK2_2 = FastKCustom(fastD1_2, KPeriod);
plot STC_2 = MovingAverage(averageType, fastK2_2, DPeriod);

Last edited by a moderator:


Well-known member
@bamafamily333 That is the way MTF works. It takes 15 minutes of data to plot the 15 minute plot. When you put the 15 minute plot on the 3 minute chart it causes the stair step. I do not think there is anyway around that.


New member
@horserider Thanks for the insight....I understand the math behind the creation of the bars, but for some reason thought the display would not be as "coarse" After taking another look at TMO_MTF, I see the stair stepping effect is doing the same thing..(i think the TMO shading threw me off)
hope to learn/contribute more in this great community....

Similar threads