Repaints MACD Multi-Timeframe Indicator For ThinkOrSwim

Repaints

cando13579

Member
VIP
The Moving Average Convergence Divergence (MACD) indicator has several advantages for traders, including:
  • Simple and reliable
    The MACD is a popular tool for both beginners and experienced traders because it's easy to use and provides reliable information.

  • Identifies trends
    The MACD can help traders determine the direction and strength of price trends, such as uptrends, downtrends, or sideways movements.

  • Shows momentum
    The MACD can help traders understand the speed and force of price changes.

  • Generates signals
    The MACD can signal potential trend reversals when the MACD line crosses above or below the signal line.

  • Shows overbought and oversold conditions
    The distance between the MACD line and the zero line can indicate overbought or oversold conditions.

  • False signals
    The MACD as well as most other oscillators generate false signals, in choppy markets or during periods of low volatility (however, in trending markets, oscillators have a high degree of accuracy).

  • Lags behind price action
    Is late in identifying signals because it uses historical data. This can lead to traders being whipsawed in and out of positions.

  • Longer-term outlooks
    The MACD is a short-term indicator and not found to be accurate in foretelling the overall direction of an instrument. This script seeks to overcome that short-coming by adding a higher aggregation. Beware, this does cause repainting. Example a higher aggregation of 4hr on a 15min chart will repaint the previous 16 bars repeatedly until the 4hr candle closes.
Author states:
MACD histogram is dark green when increasing buying momentum, and you'll see the green get lighter when buy momentum is decreasing. As well, MACD histogram is dark red when increasing sell momentum, and you'll see the red get lighter when sell momentum is decreasing.

mod note: The ToS platform does not provide the ability to use multiple timeframes in scan, watchlists, or conditional orders. MTF studies can ONLY be used as plots on a chart.

OzJywYk.png


Original Tradingview script can be found:
https://www.tradingview.com/script/ALl6HNoj-MACD-Multi-Timeframe-Indicator/

New ThinkOrSwim code is in the next post.
 
Last edited by a moderator:

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

looks like this.
try this

CSS:
#
# Charles Schwab & Co. (c) 2007-2024
#

declare lower;
input timeframe  = AggregationPeriod.MIN;
input source     = FundamentalType.CLOSE;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

def na = Double.NaN;
def last = isNaN(close);
def current = GetAggregationPeriod();
def tf = Max(Current, Timeframe);
def src = Fundamental(source, Period = tf);

def movAvgFast = MovingAverage(averageType, src, fastLength);
def movAvgSlow = MovingAverage(averageType, src, slowLength);

plot macdLine = movAvgFast - movAvgSlow;
plot signalLine = MovingAverage(averageType, macdLine, MACDLength);

plot histLine = macdLine - signalLine;
plot ZeroLine = if last then na else 0;

plot UpSignal = if macdLine crosses above signalLine then signalLine else na;
plot DownSignal = if macdLine crosses below signalLine then signalLine else na;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

macdLine.SetDefaultColor(GetColor(1));
signalLine.SetDefaultColor(GetColor(8));
histLine.SetDefaultColor(GetColor(5));
histLine.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
histLine.SetLineWeight(3);
histLine.DefineColor("Positive and Up", Color.GREEN);
histLine.DefineColor("Positive and Down", Color.DARK_GREEN);
histLine.DefineColor("Negative and Down", Color.RED);
histLine.DefineColor("Negative and Up", Color.DARK_RED);
histLine.AssignValueColor(if histLine >= 0 then if histLine > histLine[1] then histLine.color("Positive and Up") else
 histLine.color("Positive and Down") else
                if histLine < histLine[1] then histLine.color("Negative and Down") else histLine.color("Negative and Up"));
ZeroLine.SetDefaultColor(Color.DARK_GRAY);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.POINTS);

#-- END of CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
504 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.
Back
Top