ThinkScript: Custom Labels Not Updating When Switching Tickers

Sidnne

New member
I'm brand new to thinkscript, just dove into it this weekend. I'm building myself a script that places labels on my 1-min chart that turn green when certain parameters I'm looking for are met on higher time frames. I've gotten most of it to work, except my "MACD Fade" labels don't update when I change tickers. In order to get them to update, I have to make some kind of edit in the script and click "apply." The rest of them update fine, and I don't understand why the "MACD Fade" ones won't update. Any help would be appreciated.

By "MACD Fade" I mean the MACD histogram is "fading" into buying pressure, or simply, the current bar on the MACD histogram is a greater value than the previous bar.

1693888098710.png



This is the current code that I'm working with. I'm sure it's very amateur-ish, but like I said, I've just started learning it a couple days ago.

Code:
##FIFTEEN MINUTE TRP SETUP

def IsUp = close(period = AggregationPeriod.FIFTEEN_MIN) > open(period = AggregationPeriod.FIFTEEN_MIN);
def IsDown = close(period = AggregationPeriod.FIFTEEN_MIN) < open(period = AggregationPeriod.FIFTEEN_MIN);
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high(period = AggregationPeriod.FIFTEEN_MIN) - low(period = AggregationPeriod.FIFTEEN_MIN), 20);
def trpfifteentrue =
    IsDown[1] and
    IsUp[0] and
    high(period = AggregationPeriod.FIFTEEN_MIN)[1] > high(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    open(period = AggregationPeriod.FIFTEEN_MIN)[1] > high(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    open(period = AggregationPeriod.FIFTEEN_MIN)[1] > close(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    close(period = AggregationPeriod.FIFTEEN_MIN)[1] < close(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    low(period = AggregationPeriod.FIFTEEN_MIN)[1] > low(period = AggregationPeriod.FIFTEEN_MIN)[0];

AddLabel(yes, "TRP15", if trpfifteentrue then Color.GREEN else Color.RED);

##THREE MINUTE AWESOME OSCILLATOR

def AO = Average(hl2(period = AggregationPeriod.THREE_MIN), 5) - Average(hl2(period = AggregationPeriod.THREE_MIN), 34);
def Zero = 0;

def true = AO is greater than AO from 1 bars ago;
def false = AO is less than AO from 1 bars ago;

AddLabel(yes, "AO3", if true then Color.GREEN else Color.RED);

##FIVE MINUTE MACD FADE

def fastLength = 10;
def slowLength = 26;
def MACDLength = 9;
input averageType = AverageType.WILDERS;

plot Diff5 = MACD(fastLength, slowLength, MACDLength, averageType, AggregationPeriod.FIVE_MIN).Diff;

AddLabel(yes, "5MACD Fade", if Diff5 > Diff5[1] is true then Color.GREEN else Color.RED);

##THIRTY MINUTE TRP SETUP

def IsUpthirty = close(period = AggregationPeriod.THIRTY_MIN) > open(period = AggregationPeriod.THIRTY_MIN);
def IsDownthirty = close(period = AggregationPeriod.THIRTY_MIN) < open(period = AggregationPeriod.THIRTY_MIN);
def IsDojithirty = IsDoji();
def avgRangethirty = 0.05 * Average(high(period = AggregationPeriod.THIRTY_MIN) - low(period = AggregationPeriod.THIRTY_MIN), 20);
def trpthirtytrue =
    IsDownthirty[1] and
    IsUpthirty[0] and
    high(period = AggregationPeriod.THIRTY_MIN)[1] > high(period = AggregationPeriod.THIRTY_MIN)[0] and
    open(period = AggregationPeriod.THIRTY_MIN)[1] > high(period = AggregationPeriod.THIRTY_MIN)[0] and
    open(period = AggregationPeriod.THIRTY_MIN)[1] > close(period = AggregationPeriod.THIRTY_MIN)[0] and
    close(period = AggregationPeriod.THIRTY_MIN)[1] < close(period = AggregationPeriod.THIRTY_MIN)[0] and
    low(period = AggregationPeriod.THIRTY_MIN)[1] > low(period = AggregationPeriod.THIRTY_MIN)[0];

AddLabel(yes, "TRP30", if trpthirtytrue then Color.GREEN else Color.RED);

##HOURLY 200 EMA

def length = 200;
def price = close(period = AggregationPeriod.HOUR);
def displace = 0;
def ema = ExpAverage(price[-displace], length);
def condition = close(period = AggregationPeriod.HOUR) > ema;
AddLabel(yes, "200 1hr", if condition then Color.GREEN else Color.RED);

##THREE MACD UP SIGNAL

def Valuethree = MovingAverage(averageType, close(period = AggregationPeriod.THREE_MIN), fastLength) - MovingAverage(averageType, close(period = AggregationPeriod.THREE_MIN), slowLength);

def Avgthree = MovingAverage(averageType, Valuethree, MACDLength);

def Diffthree = Valuethree - Avgthree;
def ZeroLinethree = 0;

def UpSignalthree = if Valuethree crosses above Valuethree[1] then  Valuethree else Double.NaN;

AddLabel(yes, "3MACD UP", if UpSignalthree is true then Color.GREEN else Color.RED);

##FIVE MACD UP SIGNAL

def Valuefive = MovingAverage(averageType, close(period = AggregationPeriod.FIVE_MIN), fastLength) - MovingAverage(averageType, close(period = AggregationPeriod.FIVE_MIN), slowLength);

def Avgfive = MovingAverage(averageType, Valuefive, MACDLength);

def Difffive = Valuefive - Avgfive;
def ZeroLinefive = 0;

def UpSignalfive = if Valuefive crosses above Valuefive[1] then  Valuefive else Double.NaN;

AddLabel(yes, "5MACD UP", if UpSignalfive is true then Color.GREEN else Color.RED);

##TEN MACD FADE

def Diff10 = MACD(fastLength, slowLength, MACDLength, averageType, AggregationPeriod.TEN_MIN);

AddLabel(yes, "10MACD Fade", if Diff10 > Diff10[1] then Color.GREEN else Color.RED);

##FIFTEEN MACD FADE

def Diff15 = MACD(fastLength, slowLength, MACDLength, averageType, AggregationPeriod.FIFTEEN_MIN);

AddLabel(yes, "15MACD Fade", if Diff15 > Diff15[1] then Color.GREEN else Color.RED);

##THIRTY MACD FADE
##TEN MACD UP SIGNAL
##FIFTEEN MACD UP SIGNAL
##THIRTY MACD UP SIGNAL
##HOURLY MACD UP SIGNAL
 
I'm brand new to thinkscript, just dove into it this weekend. I'm building myself a script that places labels on my 1-min chart that turn green when certain parameters I'm looking for are met on higher time frames. I've gotten most of it to work, except my "MACD Fade" labels don't update when I change tickers. In order to get them to update, I have to make some kind of edit in the script and click "apply." The rest of them update fine, and I don't understand why the "MACD Fade" ones won't update. Any help would be appreciated.

By "MACD Fade" I mean the MACD histogram is "fading" into buying pressure, or simply, the current bar on the MACD histogram is a greater value than the previous bar.

View attachment 19653


This is the current code that I'm working with. I'm sure it's very amateur-ish, but like I said, I've just started learning it a couple days ago.

Code:
##FIFTEEN MINUTE TRP SETUP

def IsUp = close(period = AggregationPeriod.FIFTEEN_MIN) > open(period = AggregationPeriod.FIFTEEN_MIN);
def IsDown = close(period = AggregationPeriod.FIFTEEN_MIN) < open(period = AggregationPeriod.FIFTEEN_MIN);
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high(period = AggregationPeriod.FIFTEEN_MIN) - low(period = AggregationPeriod.FIFTEEN_MIN), 20);
def trpfifteentrue =
    IsDown[1] and
    IsUp[0] and
    high(period = AggregationPeriod.FIFTEEN_MIN)[1] > high(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    open(period = AggregationPeriod.FIFTEEN_MIN)[1] > high(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    open(period = AggregationPeriod.FIFTEEN_MIN)[1] > close(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    close(period = AggregationPeriod.FIFTEEN_MIN)[1] < close(period = AggregationPeriod.FIFTEEN_MIN)[0] and
    low(period = AggregationPeriod.FIFTEEN_MIN)[1] > low(period = AggregationPeriod.FIFTEEN_MIN)[0];

AddLabel(yes, "TRP15", if trpfifteentrue then Color.GREEN else Color.RED);

##THREE MINUTE AWESOME OSCILLATOR

def AO = Average(hl2(period = AggregationPeriod.THREE_MIN), 5) - Average(hl2(period = AggregationPeriod.THREE_MIN), 34);
def Zero = 0;

def true = AO is greater than AO from 1 bars ago;
def false = AO is less than AO from 1 bars ago;

AddLabel(yes, "AO3", if true then Color.GREEN else Color.RED);

##FIVE MINUTE MACD FADE

def fastLength = 10;
def slowLength = 26;
def MACDLength = 9;
input averageType = AverageType.WILDERS;

plot Diff5 = MACD(fastLength, slowLength, MACDLength, averageType, AggregationPeriod.FIVE_MIN).Diff;

AddLabel(yes, "5MACD Fade", if Diff5 > Diff5[1] is true then Color.GREEN else Color.RED);

##THIRTY MINUTE TRP SETUP

def IsUpthirty = close(period = AggregationPeriod.THIRTY_MIN) > open(period = AggregationPeriod.THIRTY_MIN);
def IsDownthirty = close(period = AggregationPeriod.THIRTY_MIN) < open(period = AggregationPeriod.THIRTY_MIN);
def IsDojithirty = IsDoji();
def avgRangethirty = 0.05 * Average(high(period = AggregationPeriod.THIRTY_MIN) - low(period = AggregationPeriod.THIRTY_MIN), 20);
def trpthirtytrue =
    IsDownthirty[1] and
    IsUpthirty[0] and
    high(period = AggregationPeriod.THIRTY_MIN)[1] > high(period = AggregationPeriod.THIRTY_MIN)[0] and
    open(period = AggregationPeriod.THIRTY_MIN)[1] > high(period = AggregationPeriod.THIRTY_MIN)[0] and
    open(period = AggregationPeriod.THIRTY_MIN)[1] > close(period = AggregationPeriod.THIRTY_MIN)[0] and
    close(period = AggregationPeriod.THIRTY_MIN)[1] < close(period = AggregationPeriod.THIRTY_MIN)[0] and
    low(period = AggregationPeriod.THIRTY_MIN)[1] > low(period = AggregationPeriod.THIRTY_MIN)[0];

AddLabel(yes, "TRP30", if trpthirtytrue then Color.GREEN else Color.RED);

##HOURLY 200 EMA

def length = 200;
def price = close(period = AggregationPeriod.HOUR);
def displace = 0;
def ema = ExpAverage(price[-displace], length);
def condition = close(period = AggregationPeriod.HOUR) > ema;
AddLabel(yes, "200 1hr", if condition then Color.GREEN else Color.RED);

##THREE MACD UP SIGNAL

def Valuethree = MovingAverage(averageType, close(period = AggregationPeriod.THREE_MIN), fastLength) - MovingAverage(averageType, close(period = AggregationPeriod.THREE_MIN), slowLength);

def Avgthree = MovingAverage(averageType, Valuethree, MACDLength);

def Diffthree = Valuethree - Avgthree;
def ZeroLinethree = 0;

def UpSignalthree = if Valuethree crosses above Valuethree[1] then  Valuethree else Double.NaN;

AddLabel(yes, "3MACD UP", if UpSignalthree is true then Color.GREEN else Color.RED);

##FIVE MACD UP SIGNAL

def Valuefive = MovingAverage(averageType, close(period = AggregationPeriod.FIVE_MIN), fastLength) - MovingAverage(averageType, close(period = AggregationPeriod.FIVE_MIN), slowLength);

def Avgfive = MovingAverage(averageType, Valuefive, MACDLength);

def Difffive = Valuefive - Avgfive;
def ZeroLinefive = 0;

def UpSignalfive = if Valuefive crosses above Valuefive[1] then  Valuefive else Double.NaN;

AddLabel(yes, "5MACD UP", if UpSignalfive is true then Color.GREEN else Color.RED);

##TEN MACD FADE

def Diff10 = MACD(fastLength, slowLength, MACDLength, averageType, AggregationPeriod.TEN_MIN);

AddLabel(yes, "10MACD Fade", if Diff10 > Diff10[1] then Color.GREEN else Color.RED);

##FIFTEEN MACD FADE

def Diff15 = MACD(fastLength, slowLength, MACDLength, averageType, AggregationPeriod.FIFTEEN_MIN);

AddLabel(yes, "15MACD Fade", if Diff15 > Diff15[1] then Color.GREEN else Color.RED);

##THIRTY MACD FADE
##TEN MACD UP SIGNAL
##FIFTEEN MACD UP SIGNAL
##THIRTY MACD UP SIGNAL
##HOURLY MACD UP SIGNAL

you have a wrong input parameter for macd() , in diff5 formula, and others.
there is no price input for macd, no 2nd aggregation input. if you want mtf for macd , copy the macd code , paste it into your study, and modify it.

https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MACD
 

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