Repaints The Smarter MTF MACD For ThinkOrSwim

Repaints

rad14733

Options Expert
VIP
Lifetime
Here is the Smarter MACD code that I have from TOS Indicators...

Ruby:
#TOS Indicators
#Home of the Volatility Box
#Indicator Name: Smarter MACD
#Full tutorial here: tosindicators.com/indicators/smarter-macd

declare lower;
input lever = {default "Fast", "Slow", "Medium"};
input mode = {default "Aggressive", "Conservative"};

def fastLength;
def slowLength;
def averageType;
switch(lever){
case "Fast":
    fastLength = 3;
    slowLength = 8;
    averageType = AverageType.Exponential;
case "Slow":
    fastLength = 10;
    slowLength = 20;
    averageType = AverageType.Simple;
case "Medium":
    fastLength = 12;
    slowLength = 26;
    averageType = AverageType.Exponential;
}

def outputLength;
switch(mode){
case "Aggressive":
    outputLength = fastLength;
case "Conservative":
    outputLength = slowLength;
}
def higherTF = if getAggregationPeriod() < AggregationPeriod.Five_Min then AggregationPeriod.Five_Min
else if getAggregationPeriod() < AggregationPeriod.Fifteen_Min then AggregationPeriod.Fifteen_Min
else if getAggregationPeriod() < AggregationPeriod.Thirty_Min then AggregationPeriod.Thirty_Min
else if getAggregationPeriod() < AggregationPeriod.Hour then AggregationPeriod.Hour
else if getAggregationPeriod() < AggregationPeriod.Day then AggregationPeriod.Day
else if getAggregationPeriod() < AggregationPeriod.Week then AggregationPeriod.Week
else if getAggregationPeriod() < AggregationPeriod.Month then AggregationPeriod.Month
else AggregationPeriod.Year;
def Value = MovingAverage(averageType, close(period = higherTF), fastLength) - MovingAverage(averageType, close(period = higherTF), slowLength);
plot smarterMACD = MovingAverage(averageType, Value, outputLength);
def upSwitch = if smarterMACD > smarterMACD[1] then 1 else if smarterMACD < smarterMACD[1] then 0 else upSwitch[1];
def downSwitch = if smarterMACD < smarterMACD[1] then 1 else if smarterMACD > smarterMACD[1] then 0 else downSwitch[1];
smarterMACD.setLineWeight(2);
smarterMACD.AssignValueColor(if upSwitch then color.green else if downSwitch then color.red else color.gray);
 
Thanks again. Unfortunately, it doesn't work with smarter MACD and only works with the regular MACD. Smarter MACD uses some other formula for plotting and is a lot better than the standard MACD. I just don't understand it, but see that it works far better.

The Smarter MACD is simply the MACD plot from a higher timeframe.
Below is the label that you requested for the repainting MTF Smarter MACD.
6T03HsZ.png


Understand that the OP recommends this indicator for the Daily Timeframe to spot overall reversals in trends.
https://tosindicators.com/indicators/smarter-macd
n8Dy9SM.png

On the Daily Timeframe the repainting has minimal effect as the goal is identifying trends.

Reading the current candle of the Smarter MACD or any repainter for anything will have less than optimal results due to the repainting on every tick.

Ruby:
#Indicator Name: TOS Indicators Smarter MACD  ********* Upper Label Only **************
#Full tutorial here: tosindicators.com/indicators/smarter-macd

input lever = {default "Fast", "Slow", "Medium"};
input mode = {default "Aggressive", "Conservative"};

def fastLength;
def slowLength;
def averageType;
switch(lever){
case "Fast":
    fastLength = 3;
    slowLength = 8;
    averageType = AverageType.Exponential;
case "Slow":
    fastLength = 10;
    slowLength = 20;
    averageType = AverageType.Simple;
case "Medium":
    fastLength = 12;
    slowLength = 26;
    averageType = AverageType.Exponential;
}

def outputLength;
switch(mode){
case "Aggressive":
    outputLength = fastLength;
case "Conservative":
    outputLength = slowLength;
}
def higherTF = if getAggregationPeriod() < AggregationPeriod.Five_Min then AggregationPeriod.Five_Min
else if getAggregationPeriod() < AggregationPeriod.Fifteen_Min then AggregationPeriod.Fifteen_Min
else if getAggregationPeriod() < AggregationPeriod.Thirty_Min then AggregationPeriod.Thirty_Min
else if getAggregationPeriod() < AggregationPeriod.Hour then AggregationPeriod.Hour
else if getAggregationPeriod() < AggregationPeriod.Day then AggregationPeriod.Day
else if getAggregationPeriod() < AggregationPeriod.Week then AggregationPeriod.Week
else if getAggregationPeriod() < AggregationPeriod.Month then AggregationPeriod.Month
else AggregationPeriod.Year;
def Value = MovingAverage(averageType, close(period = higherTF), fastLength) - MovingAverage(averageType, close(period = higherTF), slowLength);
def smarterMACD = MovingAverage(averageType, Value, outputLength);

addlabel(yes,"MACD: " +round(smarterMACD,2), color.dark_orange);
 
Last edited:
The Smarter MACD is simply the MACD plot from a higher timeframe.
Below is the label that you requested for the repainting MTF Smarter MACD.
6T03HsZ.png


Understand that the OP recommends this indicator for the Daily Timeframe to spot overall reversals in trends.
https://tosindicators.com/indicators/smarter-macd
n8Dy9SM.png

On the Daily Timeframe the repainting has minimal effect as the goal is identifying trends.

Reading the current candle of the Smarter MACD or any repainter for anything will have less than optimal results due to the repainting on every tick.

Ruby:
#Indicator Name: TOS Indicators Smarter MACD  ********* Upper Label Only **************
#Full tutorial here: tosindicators.com/indicators/smarter-macd

input lever = {default "Fast", "Slow", "Medium"};
input mode = {default "Aggressive", "Conservative"};

def fastLength;
def slowLength;
def averageType;
switch(lever){
case "Fast":
    fastLength = 3;
    slowLength = 8;
    averageType = AverageType.Exponential;
case "Slow":
    fastLength = 10;
    slowLength = 20;
    averageType = AverageType.Simple;
case "Medium":
    fastLength = 12;
    slowLength = 26;
    averageType = AverageType.Exponential;
}

def outputLength;
switch(mode){
case "Aggressive":
    outputLength = fastLength;
case "Conservative":
    outputLength = slowLength;
}
def higherTF = if getAggregationPeriod() < AggregationPeriod.Five_Min then AggregationPeriod.Five_Min
else if getAggregationPeriod() < AggregationPeriod.Fifteen_Min then AggregationPeriod.Fifteen_Min
else if getAggregationPeriod() < AggregationPeriod.Thirty_Min then AggregationPeriod.Thirty_Min
else if getAggregationPeriod() < AggregationPeriod.Hour then AggregationPeriod.Hour
else if getAggregationPeriod() < AggregationPeriod.Day then AggregationPeriod.Day
else if getAggregationPeriod() < AggregationPeriod.Week then AggregationPeriod.Week
else if getAggregationPeriod() < AggregationPeriod.Month then AggregationPeriod.Month
else AggregationPeriod.Year;
def Value = MovingAverage(averageType, close(period = higherTF), fastLength) - MovingAverage(averageType, close(period = higherTF), slowLength);
def smarterMACD = MovingAverage(averageType, Value, outputLength);

addlabel(yes,"MACD: " +round(smarterMACD,2), color.dark_orange);
That works, thanks!
 
.ts file sitting on my desktop in plain view for which I had trouble importing into TOS as a new indicator.
I e-mailed .ts file to friend who has TOS and he was able to import. He said he had to rename file before
importing and then e-mailed a shared chart of imported new indicator. very confused......Why did he have to
rename .ts file before importing???

Can someone post code of below so I can copy code into TOS?

Don't know why I'm having so many problems importing a simple .ts file.

.ts file downloaded from UseThinkScripts is in Zip File.

Much Thanks
 

Attachments

  • Smarter-MACD-Indicator-for-ThinkOrSwim.zip
    1 KB · Views: 14
All you had to do was click on the zip file to open it, click on the .ts file to open it (or Right-Click and select Notepad), Copy the code and Paste it into a new Study and Save in TOS... It's ridiculous that someone would store the instructions in a zip file that just tells you to watch a video to learn how to import a .ts file... That's why I recommend members ALWAYS post the script code in posts rather than posting links or zips...

Ruby:
#TOS Indicators
#Home of the Volatility Box
#Indicator Name: Smarter MACD
#Full tutorial here: tosindicators.com/indicators/smarter-macd

declare lower;
input lever = {default "Fast", "Slow", "Medium"};
input mode = {default "Aggressive", "Conservative"};

def fastLength;
def slowLength;
def averageType;
switch(lever){
case "Fast":
    fastLength = 3;
    slowLength = 8;
    averageType = AverageType.Exponential;
case "Slow":
    fastLength = 10;
    slowLength = 20;
    averageType = AverageType.Simple;
case "Medium":
    fastLength = 12;
    slowLength = 26;
    averageType = AverageType.Exponential;
}

def outputLength;
switch(mode){
case "Aggressive":
    outputLength = fastLength;
case "Conservative":
    outputLength = slowLength;
}
def higherTF = if getAggregationPeriod() < AggregationPeriod.Five_Min then AggregationPeriod.Five_Min
else if getAggregationPeriod() < AggregationPeriod.Fifteen_Min then AggregationPeriod.Fifteen_Min
else if getAggregationPeriod() < AggregationPeriod.Thirty_Min then AggregationPeriod.Thirty_Min
else if getAggregationPeriod() < AggregationPeriod.Hour then AggregationPeriod.Hour
else if getAggregationPeriod() < AggregationPeriod.Day then AggregationPeriod.Day
else if getAggregationPeriod() < AggregationPeriod.Week then AggregationPeriod.Week
else if getAggregationPeriod() < AggregationPeriod.Month then AggregationPeriod.Month
else AggregationPeriod.Year;
def Value = MovingAverage(averageType, close(period = higherTF), fastLength) - MovingAverage(averageType, close(period = higherTF), slowLength);
plot smarterMACD = MovingAverage(averageType, Value, outputLength);
def upSwitch = if smarterMACD > smarterMACD[1] then 1 else if smarterMACD < smarterMACD[1] then 0 else upSwitch[1];
def downSwitch = if smarterMACD < smarterMACD[1] then 1 else if smarterMACD > smarterMACD[1] then 0 else downSwitch[1];
smarterMACD.setLineWeight(2);
smarterMACD.AssignValueColor(if upSwitch then color.green else if downSwitch then color.red else color.gray);
 
.ts file sitting on my desktop in plain view for which I had trouble importing into TOS as a new indicator.
I e-mailed .ts file to friend who has TOS and he was able to import. He said he had to rename file before
importing and then e-mailed a shared chart of imported new indicator. very confused......Why did he have to
rename .ts file before importing???

Can someone post code of below so I can copy code into TOS?

Don't know why I'm having so many problems importing a simple .ts file.

.ts file downloaded from UseThinkScripts is in Zip File.

Much Thanks
Or you can also import the file from from the thinkorswim platform,you extract the file and then open thinkorswim,select import file or indicator do not remember exactly select the ts file and voila.
 
Importing .ts (thinkScript) files into the ThinkOrSwim (TOS) platform from your local computer is done through the "Edit Studies and Strategies" menu. It is important to unzip any downloaded files first, as TOS cannot directly import zipped folders.
Here is the step-by-step process:
Step 1: Prepare the File
Locate the .ts file on your computer.
If the file is in a .zip folder, right-click and extract/unzip it to a known folder (e.g., your Desktop or Downloads folder).
Step 2: Import into ThinkOrSwim
Open the ThinkOrSwim desktop platform.
Go to the Charts tab.
Click on Studies (the flask icon) and select Edit Studies.
Ensure you are on the Studies tab (or Strategies if it is a strategy file).
Click the Import button at the bottom left-hand side of the window.
Navigate to the folder where you saved the .ts file, select it, and click Open.
The script will now appear in your list of available studies.
Click Apply and then OK to add it to your chart.
 

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