Repaints MTF ElvisTrend For ThinkOrSwim

Repaints

Je$ter

New member
Something I came up with yesterday while I was mad after taking a couple ugly trades. Indicator just shows green/yellow/red if 3 moving averages (default to 8/13/21) are stacked. Green if stacked trending bullish. Red if stacked trending bearish. Yellow if they aren't stacked/no trend. Perfect for someone trading on a low time frame while wanting to keep an eye on the overall trend. The pictures are this week's /ES chart 5 minute with the 10 minute trend. I put pictures up for both on the chart and as a lower indicator. Edited to clean up the code a bit.


Code:
# Multi-Timeframe ElvisTrend
# Copyright (C) 2023 darkelvis twitter.com/TheOGdarkelvis
# Indicator uses a set of stacked moving averages to identify trend. Stacked low to high *should* indicate an uptrend, stacked high to low *should* indicate a downtrend, when moving averages are not stacked there is no trend. Green indicates bullish, red for bearish, and yellow for no trend.

declare lower;

##Settings

input AvgType = averageType.EXPONENTIAL;
input Fast_MA = 8;
input Mid_MA = 13;
input Slow_MA = 21;
input Show_Labels = yes;
input Timeframe = aggregationPeriod.HOUR;

##Calculations

def price = close;
def FastValue = MovingAverage(AvgType, close(period=Timeframe),Fast_MA);
def MidValue = MovingAverage(AvgType, close(period=Timeframe), Mid_MA);
def SlowValue = MovingAverage(AvgType, close(period=Timeframe), Slow_MA);
def bullish = FastValue >= MidValue AND MidValue >= SlowValue;
def bearish = FastValue <= MidValue AND MidValue <= SlowValue;
def no_trend = FastValue >= MidValue and MidValue <= SlowValue or FastValue <= MidValue and MidValue >= SlowValue;

##Label

AddLabel(Show_Labels, If bullish then "LONG ONLY" else "", if bullish then color.green else color.black);
AddLabel(Show_Labels, If bearish then "SHORT ONLY" else "", if bearish then color.red else color.black);
AddLabel(Show_Labels, If no_trend then "SIT ON YOUR HANDS" else "", if no_trend then color.yellow else color.black);

##Background cloud

AddCloud(if bullish then Double.POSITIVE_INFINITY else Double.NaN,if bullish then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN);
AddCloud(if bearish then Double.POSITIVE_INFINITY else Double.NaN,if bearish then Double.NEGATIVE_INFINITY else Double.NaN, Color.PINK);
AddCloud(if no_trend then Double.POSITIVE_INFINITY else Double.NaN,if no_trend then Double.NEGATIVE_INFINITY else Double.NaN, Color.YELLOW);
 
Last edited:

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

Something I came up with yesterday while I was mad after taking a couple ugly trades. Indicator just shows green/yellow/red if 3 moving averages (default to 8/13/21) are stacked. Green if stacked trending bullish. Red if stacked trending bearish. Yellow if they aren't stacked/no trend. Perfect for someone trading on a low time frame while wanting to keep an eye on the overall trend. The pictures are this week's /ES chart 5 minute with the 10 minute trend. I put pictures up for both on the chart and as a lower indicator.


Code:
# Multi-Timeframe ElvisTrend
# Copyright (C) 2023 darkelvis twitter.com/TheOGdarkelvis
# Indicator uses a set of stacked moving averages to identify trend. Stacked low to high *should* indicate an uptrend, stacked high to low *should* indicate a downtrend, when moving averages are not stacked there is no trend. Green indicates bullish, red for bearish, and yellow for no trend.

declare lower;

##Settings

input AvgType = averageType.EXPONENTIAL;
input Fast_MA = 8;
input Mid_MA = 13;
input Slow_MA = 21;
input Show_Labels = yes;
input Timeframe = aggregationPeriod.HOUR;

##Calculations

def price = close;
def FastValue = MovingAverage(AvgType, close(period=Timeframe),Fast_MA);
def MidValue = MovingAverage(AvgType, close(period=Timeframe), Mid_MA);
def SlowValue = MovingAverage(AvgType, close(period=Timeframe), Slow_MA);


##Label

AddLabel(Show_Labels, If FastValue >= MidValue AND MidValue >= SlowValue then "LONG ONLY" else "BLANK", if FastValue >= MidValue AND MidValue >= SlowValue then color.green else color.black);

AddLabel(Show_Labels, If FastValue <= MidValue AND MidValue <= SlowValue then "SHORT ONLY" else "BLANK", if FastValue <= MidValue AND MidValue <= SlowValue then color.red else color.black);

AddLabel(Show_Labels, If FastValue >= MidValue and MidValue <= SlowValue then "SIT ON YOUR HANDS" else "BLANK", if FastValue >= MidValue and MidValue <= SlowValue then color.yellow else color.black);

AddLabel(Show_Labels, If FastValue <= MidValue and MidValue >= SlowValue then "SIT ON YOUR HANDS" else "BLANK", if FastValue <= MidValue and MidValue >= SlowValue then color.yellow else color.black);

##Background cloud

AddCloud(if FastValue >= MidValue and MidValue>= SlowValue then Double.POSITIVE_INFINITY else Double.NaN,if FastValue >= MidValue and MidValue>= SlowValue then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN);

AddCloud(if FastValue <= MidValue and MidValue <= SlowValue then Double.POSITIVE_INFINITY else Double.NaN,if FastValue <= MidValue and MidValue <= SlowValue then Double.NEGATIVE_INFINITY else Double.NaN, Color.PINK);

AddCloud(if FastValue >= MidValue and MidValue <= SlowValue then Double.POSITIVE_INFINITY else Double.NaN,if FastValue >= MidValue and MidValue <= SlowValue then Double.NEGATIVE_INFINITY else Double.NaN, Color.YELLOW);

AddCloud(if FastValue <= MidValue and MidValue >= SlowValue then Double.POSITIVE_INFINITY else Double.NaN,if FastValue <= MidValue and MidValue >= SlowValue then Double.NEGATIVE_INFINITY else Double.NaN, Color.YELLOW);
Can you add a candlestick painting strategy to this please? I tried to do it but wasn't able to.
 
Can you add a candlestick painting strategy to this please? I tried to do it but wasn't able to.
Cleaned up the code and added colored candles...


Code:
# Multi-Timeframe ElvisTrend
# Copyright (C) 2023 darkelvis twitter.com/TheOGdarkelvis
# Indicator uses a set of stacked moving averages to identify trend. Stacked low to high *should* indicate an uptrend, stacked high to low *should* indicate a downtrend, when moving averages are not stacked there is no trend. Green indicates bullish, red for bearish, and yellow for no trend.

declare lower;

##Settings

input AvgType = averageType.EXPONENTIAL;
input Fast_MA = 8;
input Mid_MA = 13;
input Slow_MA = 21;
input Show_Labels = yes;
input Timeframe = aggregationPeriod.HOUR;

##Calculations

def price = close;
def FastValue = MovingAverage(AvgType, close(period=Timeframe),Fast_MA);
def MidValue = MovingAverage(AvgType, close(period=Timeframe), Mid_MA);
def SlowValue = MovingAverage(AvgType, close(period=Timeframe), Slow_MA);
def bullish = FastValue >= MidValue AND MidValue >= SlowValue;
def bearish = FastValue <= MidValue AND MidValue <= SlowValue;
def no_trend = FastValue >= MidValue and MidValue <= SlowValue or FastValue <= MidValue and MidValue >= SlowValue;

##Label

AddLabel(Show_Labels, If bullish then "LONG ONLY" else "", if bullish then color.green else color.black);
AddLabel(Show_Labels, If bearish then "SHORT ONLY" else "", if bearish then color.red else color.black);
AddLabel(Show_Labels, If no_trend then "SIT ON YOUR HANDS" else "", if no_trend then color.yellow else color.black);

##Background cloud

AddCloud(if bullish then Double.POSITIVE_INFINITY else Double.NaN,if bullish then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN);
AddCloud(if bearish then Double.POSITIVE_INFINITY else Double.NaN,if bearish then Double.NEGATIVE_INFINITY else Double.NaN, Color.PINK);
AddCloud(if no_trend then Double.POSITIVE_INFINITY else Double.NaN,if no_trend then Double.NEGATIVE_INFINITY else Double.NaN, Color.YELLOW);

##Color Candles

AssignPriceColor(if bullish then color.GREEN else if bearish then color.RED else color.yellow);
 
Cleaned up the code and added colored candles...


Code:
# Multi-Timeframe ElvisTrend
# Copyright (C) 2023 darkelvis twitter.com/TheOGdarkelvis
# Indicator uses a set of stacked moving averages to identify trend. Stacked low to high *should* indicate an uptrend, stacked high to low *should* indicate a downtrend, when moving averages are not stacked there is no trend. Green indicates bullish, red for bearish, and yellow for no trend.

declare lower;

##Settings

input AvgType = averageType.EXPONENTIAL;
input Fast_MA = 8;
input Mid_MA = 13;
input Slow_MA = 21;
input Show_Labels = yes;
input Timeframe = aggregationPeriod.HOUR;

##Calculations

def price = close;
def FastValue = MovingAverage(AvgType, close(period=Timeframe),Fast_MA);
def MidValue = MovingAverage(AvgType, close(period=Timeframe), Mid_MA);
def SlowValue = MovingAverage(AvgType, close(period=Timeframe), Slow_MA);
def bullish = FastValue >= MidValue AND MidValue >= SlowValue;
def bearish = FastValue <= MidValue AND MidValue <= SlowValue;
def no_trend = FastValue >= MidValue and MidValue <= SlowValue or FastValue <= MidValue and MidValue >= SlowValue;

##Label

AddLabel(Show_Labels, If bullish then "LONG ONLY" else "", if bullish then color.green else color.black);
AddLabel(Show_Labels, If bearish then "SHORT ONLY" else "", if bearish then color.red else color.black);
AddLabel(Show_Labels, If no_trend then "SIT ON YOUR HANDS" else "", if no_trend then color.yellow else color.black);

##Background cloud

AddCloud(if bullish then Double.POSITIVE_INFINITY else Double.NaN,if bullish then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN);
AddCloud(if bearish then Double.POSITIVE_INFINITY else Double.NaN,if bearish then Double.NEGATIVE_INFINITY else Double.NaN, Color.PINK);
AddCloud(if no_trend then Double.POSITIVE_INFINITY else Double.NaN,if no_trend then Double.NEGATIVE_INFINITY else Double.NaN, Color.YELLOW);

##Color Candles

AssignPriceColor(if bullish then color.GREEN else if bearish then color.RED else color.yellow);
Awesome thank you!
 
this study is great!!
https://usethinkscript.com/threads/mtf-elvistrend-for-thinkorswim.14140/#post-117207
I like the candle color change.
only problem I see is when they are stacked but a reversal is happening, they stay the color till the emas get un aligned and then turn yellow.
can they turn yellow when the emas are decreasing distance between them and un stacked.
and stay red or green when the distance increases and are stacked.
 
Last edited by a moderator:
this is great, is there a way to add a watchlist column that changes colors like the chart does?
shared watchlist column script link: http://tos.mx/pbmjfMI
Click here for --> Easiest way to load shared links
eWMRN7n.png

Ruby:
#ElvisTrend
# Copyright (C) 2023 darkelvis twitter.com/TheOGdarkelvis
# Indicator uses a set of stacked moving averages to identify trend.
#Stacked low to high *should* indicate an uptrend,
#stacked high to low *should* indicate a downtrend,
#when moving averages are not stacked there is no trend.
#Green indicates bullish, red for bearish, and yellow for no trend.

declare lower;

##Settings
input AvgType = averageType.EXPONENTIAL;
input Fast_MA = 8;
input Mid_MA = 13;
input Slow_MA = 21;

##Calculations
def price = close;
def FastValue = MovingAverage(AvgType, close,Fast_MA);
def MidValue = MovingAverage(AvgType, close, Mid_MA);
def SlowValue = MovingAverage(AvgType, close, Slow_MA);
def bullish = FastValue >= MidValue AND MidValue >= SlowValue;
def bearish = FastValue <= MidValue AND MidValue <= SlowValue;
def no_trend = FastValue >= MidValue and MidValue <= SlowValue or FastValue <= MidValue and MidValue >= SlowValue;

##Label
AddLabel(yes,
if bullish then "LONG ONLY" else
if bearish then "SHORT ONLY" else
if no_trend then "SIT ON YOUR HANDS" else " ");

AssignBackgroundColor(
if bullish then color.green else
if bearish then color.red else
if no_trend then color.yellow else color.black);
 
this study is great!!
https://usethinkscript.com/threads/mtf-elvistrend-for-thinkorswim.14140/#post-117207
I like the candle color change.
only problem I see is when they are stacked but a reversal is happening, they stay the color till the emas get un aligned and then turn yellow.
can they turn yellow when the emas are decreasing distance between them and un stacked.
and stay red or green when the distance increases and are stacked.
I have tried playing with your idea but moving averages are not perfectly linear. The averages are always moving slightly away or slightly together. The results provided no usable information.

We would need to combine it with another indicator or introduce some smoothing.
If enough people express interest. I will give it another go.
 
thank you for all your help, the watchlist is great. I found a workaround. not sure what script it was on the site but when the candle crosses the ema line in the opposite of the script the candles turn gray.

thanks again.
 
Is there a way to do this but instead of EMA's being stacked, the candle just closes above the top EMA its green, in the middle of the 3 EMA's its yellow, candle closes below the bottom EMA its red.

The EMA's don't need to be in any particular order though.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
230 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