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:
@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.
@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....

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
238 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.