Filthy Trends Fibonacci Indicator for ThinkorSwim

This indicator was designed to show how price is reacting in relation to the 5 Fibonacci ma lengths 8, 21, 34, 55, 89. Additionally, I have added in price in relation to VWAP as the top line of the code. I have found that moving averages act as moving supports/resistance for price. If these averages can "stack" for longs (all green/yellow) or for shorts (orange/red) price is much more likely to follow the trend because the moving averages push it in the desired direction. The Filthy Trends indicator allows you to see what moving averages are doing while also reducing screen clutter.

The indicator is laid out as follows:
  • Top Line= Price relation to VWAP
  • Following Lines = Price relation to ema lengths starting with 8 and descending in order
Colors:
  • Green= Price > MA and MA > then the next MA length for example green on the second line = 8 > 21 and Close > 8
  • Yellow = Price > MA and MA < the next MA length
  • Orange = Price < MA and MA > the next MA length
  • Red = Price < MA and MA < the next MA length
EdBhNGH.png


Code:
#Designed to find trends so you trade with them rather than against them

#Green means full bull trend, Red means full bear trend, Orange indicates that Price is starting to fall out of the trend to the downside, Yellow indicates price is falling out of trend to the upside

#Created by SneaySwings 1/28/2021

declare lower;

input price = close;
input displace = 0;
input length1 = 8;
input length2 = 21;
input length3 = 34;
input length4 = 55;
input length5 = 89;

def ema1 = ExpAverage(price[-displace], length1);
def ema2 = ExpAverage(price[-displace], length2);
def ema3 = ExpAverage(price[-displace], length3);
def ema4 = ExpAverage(price[-displace], length4);
def ema5 = ExpAverage(price[-displace], length5);

plot ema8 = 2;
ema8.setpaintingStrategy(paintingstrategy.LINE_VS_POINTS);
ema8.setLineWeight(3);
ema8.assignValueColor(if close > ema1 and ema1 > ema2 then color.green else if close < ema1 and ema1 < ema2 then color.red else if close > ema1 and ema1 < ema2 then color.yellow else color.dark_orange);

plot ema21 = 1;
ema21.setpaintingStrategy(paintingstrategy.LINE_VS_POINTS);
ema21.setLineWeight(3);
ema21.assignValueColor(if close > ema2 and ema2 > ema3 then color.green else if close < ema2 and ema2 < ema3 then color.red else if close > ema2 and ema2 < ema3 then color.yellow else color.dark_orange);

plot ema34 = 0;
ema34.setpaintingStrategy(paintingstrategy.LINE_VS_POINTS);
ema34.setLineWeight(3);
ema34.assignValueColor(if close > ema3 and ema3 > ema4 then color.green else if close < ema3 and ema3 < ema4 then color.red else if close > ema3 and ema3 < ema4 then color.yellow else color.dark_orange);

plot ema55 = -1;
ema55.setpaintingStrategy(paintingstrategy.LINE_VS_POINTS);
ema55.setLineWeight(3);
ema55.assignValueColor(if close > ema4 and ema4 > ema5 then color.green else if close < ema4 and ema4 < ema5 then color.red else if close > ema4 and ema4 < ema5 then color.yellow else color.dark_orange);

plot ema89 = -2;
def ma = movavgExponential(price, 144);
ema89.setpaintingStrategy(paintingstrategy.LINE_VS_POINTS);
ema89.setLineWeight(3);
ema89.assignValueColor(if close > ema5 and ema5 > ma then color.green else if close < ema5 and ema5 < ma then color.red else if close > ema5 and ema5 < ma then color.yellow else color.dark_orange);

#Vwap for the ****ing Boys
input timeFrame = {default DAY, WEEK, MONTH};

def cap = getAggregationPeriod();
def errorInAggregation =
    timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");

def yyyyMmDd = getYyyyMmDd();
def periodIndx;
switch (timeFrame) {
case DAY:
    periodIndx = yyyyMmDd;
case WEEK:
    periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case MONTH:
    periodIndx = roundDown(yyyyMmDd / 100, 0);
}
def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);

def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
    volumeVwap2Sum = volume * Sqr(vwap);
} else {
    volumeSum = compoundValue(1, volumeSum[1] + volume, volume);
    volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
    volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def pricev = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));

def VWAP = pricev;

plot vwap_decision = 3;
vwap_decision.setpaintingStrategy(paintingstrategy.LINE_VS_POINTS);
vwap_decision.setLineWeight(3);
vwap_decision.assignValueColor(if close > vwap then color.green else if close < vwap then color.red else if close crosses above vwap then color.lime else if close crosses below vwap then color.pink else color.current);

Link to indicator: http://tos.mx/cIx0HHy
 

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