NexusFi: Find Your Edge


Home Menu

 





Multiple Timeframe for MACD


Discussion in ThinkOrSwim

Updated
    1. trending_up 5,900 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

Multiple Timeframe for MACD

  #1 (permalink)
gcorrea
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

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 
rmejia's Avatar
 rmejia 
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
Reply With Quote
Thanked by:
  #3 (permalink)
LorraineP
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?

Reply With Quote
  #4 (permalink)
 
rmejia's Avatar
 rmejia 
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441


LorraineP View Post
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 View Post
My main chart is 5 minutes and wanted to have MACD for 15 and 60 minute on my 5 minutes chart.


Reply With Quote




Last Updated on August 16, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts