Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Multiple Timeframe for MACD
Updated August 16, 2015
trending_up
5,897 views
thumb_up
1 thanks given
group
2 followers
forum
3 posts
attach_file
1 attachments
Multiple Timeframe for MACD
August 15th, 2015, 08:01 PM
Puerto Rico
Posts: 1 since Jan 2014
Thanks Given: 1
Thanks Received: 0
Hi, This is the first time I participate in your forum (and to be honest a newby on TOS ThinkScripts Programming).
I want to add a thinkscript code for a Multiple Time Frame for MACD. My main chart is 5 minutes and wanted to have MACD for 15 and 60 minute on my 5 minutes chart.
So far, this is what my 5 min TOS Chart currently has:
input averagefastLength = 9;
input averageslowLength = 27;
input macdLength = 7;
input averageType = {SMA , default EMA};
def diff = reference MACD(averagefastLength, averageslowLength, macdLength, averageType).Diff;
def exit = EntryPrice();
Your help on this type of aggregation will be very appreciated.
Thanks
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
August 15th, 2015, 08:56 PM
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441
Gave it a shot; it gets a bit fugly the higher the timeframe. The lines in bold were added/edited from the default MACD.
Code
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input TimeFrame = AggregationPeriod.Day;
plot Value = MovingAverage(averageType, close(period = TimeFrame), fastLength) - MovingAverage(averageType, close(period = TimeFrame), slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
https://tlc.thinkorswim.com/center/charting/thinkscript/tutorials/Chapter-12---Referencing-Secondary-Aggregation.html
https://tlc.thinkorswim.com/center/charting/thinkscript/reference/Constants/AggregationPeriod.html
Attached Files
Elite Membership required to download: _MACDmultipletimeframesSTUDY.ts
August 16th, 2015, 09:07 AM
Tyler, TX/USA
Posts: 21 since Jan 2015
Thanks Given: 6
Thanks Received: 8
I've used TOS . And I've used MacD and several variations of it on TOS. I believe it automatically changes when you change your time frame.
So I don't get why you are trying to recreate the wheel?
August 16th, 2015, 12:28 PM
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441
LorraineP
I've used
TOS . And I've used MacD and several variations of it on TOS. I believe it automatically changes when you change your time frame.
So I don't get why you are trying to recreate the wheel?
He wants to be able to have a different timeframe on the MACD from the chart:
gcorrea
My main chart is 5 minutes and wanted to have MACD for 15 and 60 minute on my 5 minutes chart.
Last Updated on August 16, 2015