MT4-style MACD For ThinkOrSwim

OGK

New member
VIP
This is a plain MACD similar to the one on the mt4

hHWNF9G.png


see script below
 
Last edited by a moderator:
I am trying to make my TOS look like my MT4 chart. There is a free MT4 indicator MACD indicator that I use, I was able to find an exact match for it on Tradingview and have been looking for a possible code for TOS. I tried using ChatGPT to convert it but it keeps giving me new scripts but all have errors and are useless. Can anyone help convert this free indicator code from pinescript to thinkscript.
Tradingview url


Code:
//@author=LucemAnb
study(title="MT4 MACD ⛏", overlay=false)

src = input(title="Source", type=input.source, defval=close)
fastMA = input(title="Fast moving average", type = input.integer, defval = 12, minval = 7)
slowMA = input(title="Slow moving average", type = input.integer, defval = 26, minval = 7)
signalLength = input(9, "Signal Length", minval=1)

[currMacd,_,_] = macd(close[0], fastMA, slowMA, 9)
[prevMacd,_,_] = macd(close[1], fastMA, slowMA, 9)

signal = sma(currMacd, signalLength)
plotColor = currMacd > 0 ? currMacd > prevMacd ? color.lime : color.green : currMacd < prevMacd ? color.maroon : color.red
plot(currMacd, style = plot.style_columns, transp=20, color = plotColor, linewidth = 3, title="Macd Bars")
plot(signal, color=color.white, transp=0, title="Macd Signal")
find below

CSS:
#/ This is a ToS indicator
#//@author=LucemAnb
#study(title="MT4 MACD ⛏", overlay=false)
# Request from useThinkScript.com memeber
# Converted by Sam4Cok@Samer800 - 08/2023 - Same MACD4C indicator
declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.SIMPLE;

def na = Double.NaN;
def last = IsNaN(close);

def movFast = ExpAverage(close, fastLength);
def movSlow = ExpAverage(close, slowLength);
def currMacd = movFast - movSlow;
def currAvg = MovingAverage(averageType, currMacd, MACDLength);

plot Avg = currAvg;
plot Diff = currMacd;
plot ZeroLine = if last then na else 0;

Avg.SetDefaultColor(Color.WHITE);
Diff.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Diff.SetLineWeight(3);
Diff.AssignValueColor(if Diff >= 0 then
                      if Diff > Diff[1] then Color.GREEN else Color.DARK_GREEN else
                      if Diff < Diff[1] then Color.RED else Color.DARK_RED);
ZeroLine.SetDefaultColor(Color.DARK_GRAY);

#-- END of CODE
 
Last edited by a moderator:

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
380 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