Price Trend Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
This is a fairly simple indicator for ThinkorSwim that shows the price trend in the candles.

Created by Drew Griffith.

Color candlesticks based on price movement. New highs are green; New lows are red; Sideways trading are grey.


thinkScript Code

Rich (BB code):
declare upper;

input trail = 1;
input displace = 1;
input aggregationperiod = aggregationperiod.day;

def new_high = close > highest(high(period = aggregationperiod), trail)[displace];
def new_low = close < lowest(low(period = aggregationperiod), trail)[displace];

def greenprice = if new_high then yes else if new_low then no else new_high[1];
def redprice = if new_low then yes else if new_high then no else new_low[1];

plot bullish = greenprice;
plot neutral = !greenprice and !redprice;
plot bearish = redprice;

plot rating =
if greenprice then 1
else if redprice then .5
else 0;

def paintbars = yes;

bullish.setdefaultcolor(color.uptick);
bullish.setpaintingstrategy(paintingstrategy.boolean_points);
bullish.setlineweight(3);
bullish.hide();
neutral.setdefaultcolor(color.gray);
neutral.setpaintingstrategy(paintingstrategy.boolean_points);
neutral.setlineweight(3);
neutral.hide();
bearish.setdefaultcolor(color.downtick);
bearish.setpaintingstrategy(paintingstrategy.boolean_points);
bearish.setlineweight(3);
bearish.hide();
rating.hide();
rating.hidebubble();

defineglobalcolor("bullish", color.uptick);
defineglobalcolor("neutral", color.gray);
defineglobalcolor("bearish", color.downtick);
assignpricecolor(if !paintbars then color.current else if greenprice then globalcolor("bullish") else if redprice then globalcolor("bearish") else globalcolor("neutral"));

Shareable Link

http://tos.mx/gxwvi5
 
Last edited:
H

HighBredCloud

Active member
@BenTen hmm...very curious to see to see how this particular trend stacks up against Mobius SuperTrend...SuperTrend with Laguerre RSI and a Mobius version of a SuperTrend that I found somewhere down the grapevine...I don't think that version of the Mobius SuperTrend is on this site...I will share the code once I do the test to make sure how it compares and perhaps a NEW SuperTrend can be enhanced.
 
H

HighBredCloud

Active member
OK...So incase any one is interested how this PriceTrend compares to the rest of the trend indicators here are the results on a 15 min chart...Everything you see is in default settings.

From left to right:

Heikin Ashi
Standard Candlesticks
Blast Off SuperTrend with Laguerre RSI by @netarchitech
SuperTrend by Mobius found on this site
CandleTrend by Mobius from my archives
PriceTrend



As you can see the PriceTrend indicator stacks up quite nicely and makes the entries precise with the specific candle color...What is really surprising to me is the CandleTrend by Mobius that I found in my archives...it has an option for higher aggregation period which will display the color of candles based on the aggregation period selected. For example...If you select a 15 min time aggregation but you're trading on a 5 min chart...the color trend will paint the candles based on the 15 min time frame on the 5 min chart...hence, the multi time frame as with everything else that we have seen. Very cool feature.

On both the PriceTrend and the Mobius CandleTrend the painting of the candles is somewhat sensitive and does change midway through the candles sometimes. This could be because its more sensitive or because of the higher timeframe my test was done at. Looking at both the CandleTrend and the PriceTrend simultaneously netted the best results from what I found in this test. I never really had all of them up and running at the same time until I stumbled upon this PriceTrend indicator post.

This leaves me to questions...is it possible to somehow merge the the Mobius CandleTrend and the PriceTrend together and form one Super Candle Price Trend Indicator?

The least accurate from my test was actually the original and most popular SuperTrend by Mobius...on a higher timeframe such as 15 min it just hit way to late although the candles did not change as much during the same time frame as on the Price Trend and Candle Trend...Same could be said about the Super Trend with Laguerre RSI...

Since @netarchitech helped with the Blast Off SuperTrend and did exactly what I wanted perhaps I can get an opinion on this new idea of enhancing the existing SuperTrends?
 
Last edited by a moderator:
H

HighBredCloud

Active member
Looks to me the Standard Candlesticks is best.
@horserider In this particular example yes...it's not the same scenario in a choppy market. A trend indicator that does not respond to a trending market will not respond well to a choppy market. The best way to tell how a trend indicator such as the ones I've posted above behave is showing how they actually follow a trend like in the example above. You can tell the differences in reaction time between them once they are side by side.

I wish there was an indicator that reads just like the Heikin Ashi candles but one that uses regular candle sticks for a more precise entry exit.
 
vvcv

vvcv

New member
@HighBredCloud

I'm sure you've tried, but have you tried a price line with HA? During non-US market hours, I use Heikin Ashi with a 1 SMA (which is just a price line). In a long position, for example, I will exit (if other conditions are met) when the HA body stops making higher highs and the SMA (price line) moves below the HA body that is the 3rd highest low in the move -which is usually 3-5 HA bars back. If there is a HA body well beyond the height of the other previous HA bodies, I will use that tall body, as the exit signal, when the price line drops below 50% of the bodies height. I also turn wicks off to stay out of those false breakouts.

The first 2-3 opening hours of the US market i can not use this thesis at all. This method may not be for every entry/exit, but it does give me a 'heads up' for what may be happening soon. \

hehe, just struck me that you didn't ask for any of this...sorry for my 2cent ramble. :)
 
H

HighBredCloud

Active member
@vvcv can you post a pic on what you mean? And which price line indicator are you referring to? Recently I combined Heikin Ashi and the PriceTrend SuperTrend...seems to work good together...butI kept the wicks on there...See the pic below...on the left is Heikin Ashi with PriceTrend SuperTrend and on the right regular candlesticks with some type of a Mobius SuperTrend I found.

 
H

HighBredCloud

Active member
@vvcv is this what you mean? You set the Simple Moving average to 1 period and turned the wicks off the Heikin Ashi...ans as long at the price lone to be above the HA candles its a long and if the price line is below the candles than its a short?

 
vvcv

vvcv

New member
@HighBredCloud

here are a couple of examples on the chart you posted. The image says 'no sorts' but should say no 'shorts'. Hope this give you a basic idea. It's a very 'paranoidy-conservative approach when i really want to lock in a good profit. The more the profit, the quicker i am to use this method.
 
H

HighBredCloud

Active member
@HighBredCloud

here are a couple of examples on the chart you posted. The image says 'no sorts' but should say no 'shorts'. Hope this give you a basic idea. It's a very 'paranoidy-conservative approach when i really want to lock in a good profit. The more the profit, the quicker i am to use this method.
@vvcv I see what you mean now...I am a visual person so that helps out...But I am wondering if using other indicators such as True momentum indicator or even the SMIEUO would stack up to the 1 period SMA...I haven't tested a 1 SMA before but I think its very very sensitive unless this is used on higher timeframes such as 15 min if not greater...
 
vvcv

vvcv

New member
@HighBredCloud

I think i should mention that this method is used on the S&P E-mini during overnight or after 3 hours of the US trading day. I think it works successfully for me due to the volume in this mini. In oil, sugar, DOW mini, copper for a few example, I would not use this at all. These markets bounce too far too fast because of low volume on either side of the trade. I've never traded intraday equities, so can't comment. But my guess is if the volume is high ie. apple/goog/Cat...it may work. Just wanted to point that out.
 
vvcv

vvcv

New member
@HighBredCloud

I've thought about that too. I should also mention that I do trade multiple times a day and very often i'm out of a move within 10 minutes. I jump in and as soon as I can, i move my stop to the entry price. At this point i move the stop up (like a automated trailing stop would do) and start looking for the price line (SMA) to drop below the HA. I don't think i would use this for any other type of trading, it's a quick in/out thesis for me.
 
H

HighBredCloud

Active member
@HighBredCloud

I've thought about that too. I should also mention that I do trade multiple times a day and very often i'm out of a move within 10 minutes. I jump in and as soon as I can, i move my stop to the entry price. At this point i move the stop up (like a automated trailing stop would do) and start looking for the price line (SMA) to drop below the HA. I don't think i would use this for any other type of trading, it's a quick in/out thesis for me.
@vvcv That's kind of how I trade...what time frame do you find the SMA priceline to work the best on? I typically try to trade the 15 min as the signal time frame then I enter on the 5 min for a more precise entry...,however, I feel that the SMA price line on the 5 min may be way too sensitive...
 
vvcv

vvcv

New member
@HighBredCloud

yeah, me too. I use the 15 and 5 minute. I do use this method, and follow the trade on the 5m. My 15m chart are candles w/o wick and used mainly to spot trends. I've also found that the 50% trend retracements adhere pretty well on the 15. I wanted to mention before that i'm a visual person too. I've got my MFA in photography and a minor in finance. So yeah, i use color on my charts due to their psychological effects. I try to keep a lot of blue and green on my charts (keeps my reactions or 'overreactions' calmed...whenever i see 'RED', i've found that i act too quickly. There's a reason firetrucks are red. :)

I'd be interested to get a brief description of your trading method(s). We can move to email if you would prefer. I've been thinking of getting some software to record videos of my trading. I'm hoping to get a visual archive of my failures to try and learn from them. I wouldn't mind collaborating with someone to get another's perspective. Let me know what you think, my public email is [email protected].
 
H

HighBredCloud

Active member
@vvcv I am trying not complicate things more than I already am. I use two types of charts on both the 5 and 15 min timeframes...Heikin Ashi and regular candlesticks simply because they fit into my vertical monitor set up. I also use two lower studies on each chart...its a little more than I would like to use but to be honest some of the basic indicators that @netarchitech enhanced became really good indicators.

I am formulating a new trading strategy as up until now I used to only trade tick charts when I was trading ETF such as NUGT until I got my ass handed to me by the volatility of NUGT...then I stopped trading ETF's and moved towards the direction of 5 min and 15 min.

For me trading a 1 min or 2 min time frames is suicide...too many whipsaws...false trends or breakouts/breakdowns...etc. You know what the say...the higher the timeframe the bigger the move.

You can e-mail me at [email protected] but I would suggest to start a thread in the strategy section of the forum so that others can also read and hopefully benefit from what we have to say. Anyways...my biggest obstacle as a trader is picking my spots and sitting on my hands until I see a formation. I blame this bad habit on my scalping days. I used to think 1 min chart was too long so that should tell you how anxious I was when it came to my trades...I wanted to be in and out and not deal with the "pain" when sitting in the position and being in the RED...So I would pick up crazy amounts of shares...like 10K of NUGT and I would hope to make about .$10 and be out and done for the day...

For the times it worked it was great...but there were also time times where the ETF went against all basic knowledge and logic and quickly became negative to a point of almost blowing up my account. Hence I am here trying a new thing and with the help of great people here that helped me the ideas I had to create indicators that hopefully will help others who share a similar trading style as mine succeed.

I actually want to record a video and explain a strategy and post it here with all the new indicators that @netarchitech and @tomsk other members of the team help make come true...but before I do that I need to make the strategy works and that the indicator works the way I envisioned it in my head...I wish I could just trade a naked chart but I just don't have that "feel" like others do. I am very visual and too OCD...just as @tomsk as he had the pleasure of dealing with me on a new indicator called CSA...Big thanks to him for putting up with my requests but I do think they will benefit others...so a win win hopefully.

I agree with the whole color thing...trading very mental...So anything that helps you keep a level head should be implemented. I too find some indicators that I found here to be really in your face with colors...That bothers me...Having a cool relaxing not so much in your face palette hopefully prevents you as a trader from making rash decisions...
 
vvcv

vvcv

New member
@HighBredCloud

Thanks a lot for the method you describe. I'm going to check out the CSA indicator. First glance and I like it already.

I wanted to show you a trade i placed tonight with OnDemand. I won't get too much into the method, because i'm in the testing phase with a couple of ideas.

First up is the Schaff Trend and MACD indicators. They are such a powerful tool when used together. I don't understand why all the MACD people are not looking at the Schaff indicator, i've never seen it mentioned. It alone has kept me on the right side of many many trade entries. Seriously. I've added an MA and grouped it with the RSI Laguerre since this post i did on it. I'd be more than happy to share my experience with it if you're (or anyone is interested).

The middle indicator on the bottom is new to me, but from i can tell, it has great power to ignore some very minor retracements and keeping the trade alive. I mention this because you commented on sitting on your hands (i hope i assumed correctly in that you're trying to stay in a winning trade for more profit). Osc. indicators, like Schaff can knock me out too early at times, i hope this guy can keep me in. You will notice the slight pullback after my entry is not phased by the Fish MA indicator. Was very nice, crossing fingers for a nice pair with Schaff.

As for the MACD, I decided to use it just to help confirm the Schaff. I use Schaff with the MACD settings of 12,26,9.

The chart on left with 15m standard no wick candles, the middle is 5m w/no wick candles, and my trading chart is a 5m HA candle with a SMA ribbon indicator of mine.

The thesis of this trade was based around volume and the HA movement we talk about above in this thread. I wanted to show you/everyone my entry. The priority, however, was waiting to find a high volume support/resistance line on the 15m chart. I will be working with all these tools more. Everything gave me a lot of confidence going for the trade.

The first image is the trade, and the 2nd shows how high volume, at a strong resistance, made for a very nice trend reversal and catching that trend at the beginning.

But yeah, I'd like to get a thread started on a trading topic that we can both use. Since we are both 15/5 minute traders, seems like it could turn out to be productive. I'd like to see about finding/making a system, or even better, a single indicator that 1. Shows very strong volume increase 2. Shows the direction the market may move during this volume pump. So, i guess a volume based indicator. For example, I use the DOM from Generic Trade. It would be great to develop an indicator that basically visualizes a DOM data for you. So, for example, their DOM shows numbers traded and numbers to be traded at price points. Then the DOM places 5 dots on the 5 highest volume price areas. It's such fantastic information/data that i've been able to trade the DOM with no charts in front of me. They were scalps of course, but the data and how it's shown is just perfect. I could imagine an indicator doing/showing the same type of data would be good for longer trades. Monkey bars and the TPO indicator just don't do it right. Good idea, but falls short...at least for me. \\

Anyway, here are the images from my first trade with this setup.





This second image shows a false break below resistance after my trade (yellow up arrow), exactly why i avoid the support/resistance breakout trades. Just large black pools of big money waiting for those break outs. So what happened here? For those curious, the price breaks below resistance at 3088 on the S&P e-mini, and at 3085 is where the big money was waiting. They gladly snatched up all those shorts, and at around 3094 (where shorts probably places their stops, the big money starts snatching up all those stops and price takes off. Volume quickly dies and more shorts come in at 3098, and again, as indicated buy a slight boost in volume, big money gets back in, stops are called again and price continues. Classic big money dark pools a few ticks below resistance break down.
 
Last edited:
H

HighBredCloud

Active member
@netarchitech What is your opinion on possibly implementing the Schaff indicator into the PercentR_Mac as an added option? I have those two side by side and from the looks of it the Schaff indicator would eliminate a false pullback that the PercentR_Mac would display. I really like how @vvcv has the Schaff in a dynamic color that changes...Let me know your thoughts but those two may go really well together.

@vvcv...I have tried the Laguerre RSI before...but to be frank...I don't see it being very much accurate...I find it being too late for most moves on a 5 min chart compared to the PercentR_Mac that @netarchitech enhanced with the addition of two moving average lines. Perhaps you could take a look and see how that stacks up against the Laguerre RSI with Schaff as I am doing the same exact thing...So then we can see whose indicators are more precise without being biased.

I have not used FISH before either...I'd be willing to test it out to see what that is all about.

In regards to the MACD that you posted...There is so much going on there that even after take out the Bollinger bands I am having difficulty reading it. Perhaps because I am used to MACD_FREMA..., however, after stripping down the version of the MACD that you posted I still find that MACD_FREMA enhanced by @netarchitech is easier to read and the signals come on faster with the FREMA changes colors.

I would love to hear what you have to say about the MACD_FREMA and the PercentR_MAC with your tests and how they possibly respond with your way of trading.

I will include the scripts below for each. In the mean time I am very intrigued with the Schaff indicator and I could definitely see how it can keep you in a trade for longer. Hopefully @netarchitech can do his magic and implement the Schaff indicator into PercentR_MAC.

I am not familiar with DOM...I think it would be a good idea to start a thread on strategy...Perhaps we can do so once we actually test out some of the indicators that were mentioned here and collectively collaborate a strategy that works. This seems to be the biggest issue right now as I am still looking at several indicators at once trying to find which ones work best together or come to some sort of confluence that could trigger a trade.

MACD_FREMA Script: Disable the PLOT X and Y on the MACD...

# filename: MR__EZ_MACD_FREMA_
# original source: https://usethinkscript.com/threads/blast-off-indicator-for-thinkorswim.621/post-7785
# current source: https://usethinkscript.com/threads/adding-breakouts-and-dss-to-macd-indicator-for-thinkorswim.957/post-8463

# MACD with a more Normal Distribution
# Mobius
# V01.09.2015
#Hint: Plots a Gaussian distribution. If Normal Distribution is met, then at minimum, 68.2% of the close values should be inside a One Standard Deviation Envelope and 95.4% of the close values should be inside a 2 Standard Deviation Envelope.

# V11.01.2019 - netarchitech added standard TOS Breakout Signals per HighBredCloud request
# V11.01.2019 - netarchitech added Ehlers and Mobius Forward/Reverse EMA per HighBredCloud request
# V11.07.2019 - netarchitech added multiple Moving Average selection per HighBredCloud request
# V11.08.2019 - netarchitech added cloud feature to MACD_Value - MACD_Avg lines per HighBredCloud request

declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input showBreakoutSignals = yes;
input ma_length = 21; #Length(180-200 for floating S/R , 55 for swing entry)


# Four Pole Filter
script g {
input length = 4;
input betaDev = 2;
input price = OHLC4;
def c;
def w;
def beta;
def alpha;
def G;
c = price;
w = (2 * Double.Pi / length);
beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
alpha = (-beta + Sqrt(beta * beta + 2 * beta));
G = Power(alpha, 4) * c +
4 * (1 – alpha) * G[1] – 6 * Power( 1 - alpha, 2 ) * G[2] +
4 * Power( 1 - alpha, 3 ) * G[3] - Power( 1 - alpha, 4 ) * G[4];
plot Line = G;
}
# Modified MACD
plot MACD_Value = g(length = fastLength) - g(length = slowLength);
MACD_Value.Hide();
plot MACD_Avg = g(price = MACD_Value, length = MACDLength);
MACD_Avg.Hide();
addCloud(MACD_Value, MACD_Avg, Color.GREEN, Color.RED);

plot Diff = MACD_Value - MACD_Avg;
plot ZeroLine = 0;

MACD_Value.SetDefaultColor(GetColor(1));
MACD_Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));

ZeroLine.SetDefaultColor(GetColor(4));
ZeroLine.HideTitle();

plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
Upsignal.SetLineWeight(3);
DownSignal.SetHiding(!showBreakoutSignals);
Downsignal.SetLineWeight(3);

UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.HideTitle();
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.HideTitle();

# Forward / Reverse EMA
# (c) 2017 John F. Ehlers
# Ported to TOS 07.16.2017
# Mobius

# Inputs:
input AA = .1;

# Vars:
def CC;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;
plot EMA_Signal;
plot plot0;

CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];

EMA_Signal = EMA – AA * RE8;
EMA_Signal.AssignValueColor(if EMA_Signal > EMA_Signal[1]
then Color.MAGENTA
else Color.CYAN);
EMA_Signal.SetLineWeight(3);

plot0 = if IsNaN(close) then Double.NaN else 0;
plot0.SetDefaultColor(Color.GRAY);
plot0.HideTitle();

#addCloud(0, Signal, color.RED, color.GREEN);

# Multi-moving average Component

#input length = 14; #hint Length: Number of periods to average the data.
input movingAverageType = {default "Simple MA", "Exponential MA", "Wilders Smoothing", "Weighted MA", "Hull MA", "Adaptive MA", "Triangular MA", "Variable MA", "Dema MA", "Tema MA", "EHMA", "THMA"};
input displace = 0;

def avg_MACD_Value = ExpAverage(2 * ExpAverage(MACD_Value, ma_length / 2) - ExpAverage(MACD_Value, ma_length), Round(Sqrt(ma_length)));
def avg_MACD_Avg = ExpAverage(2 * ExpAverage(MACD_Avg, ma_length / 2) - ExpAverage(MACD_Avg, ma_length), Round(Sqrt(ma_length)));

plot X;
X.SetDefaultColor(CreateColor(0, 102, 204));
X.SetLineWeight(3);
plot Y;
Y.SetDefaultColor(Color.WHITE);
Y.SetLineWeight(3);

switch (movingAverageType) {
case "Simple MA":
X = Average(MACD_Value, ma_length);
Y = Average(MACD_Avg, ma_length);

case "Exponential MA":
X = ExpAverage(MACD_Value, ma_length);
Y = ExpAverage(MACD_Avg, ma_length);

case "Wilders Smoothing":
X = WildersAverage(MACD_Value, ma_length);
Y = WildersAverage(MACD_Avg, ma_length);

case "Weighted MA":
X = wma(MACD_Value, ma_length);
Y = wma(MACD_Avg, ma_length);

case "Hull MA":
X = HullMovingAvg(MACD_Value, ma_length);
Y = HullMovingAvg(MACD_Avg, ma_length);

case "Adaptive MA":
X = MovAvgAdaptive(MACD_Value, ma_length);
Y = MovAvgAdaptive(MACD_Avg, ma_length);

case "Triangular MA":
X = MovAvgTriangular(MACD_Value, ma_length);
Y = MovAvgTriangular(MACD_Avg, ma_length);

case "Variable MA":
X = VariableMA(MACD_Value, ma_length);
Y = VariableMA(MACD_Avg, ma_length);

case "Dema MA":
X = DEMA(MACD_Value, ma_length);
Y = DEMA(MACD_Avg, ma_length);

case "Tema MA":
X = TEMA(MACD_Value, ma_length);
Y = TEMA(MACD_Avg, ma_length);

case EHMA:
X = ExpAverage(2 * ExpAverage(MACD_Value, ma_length / 2) - ExpAverage(MACD_Value, ma_length), Round(Sqrt(ma_length)));
Y = ExpAverage(2 * ExpAverage(MACD_Avg, ma_length / 2) - ExpAverage(MACD_Avg, ma_length), Round(Sqrt(ma_length)));

case THMA:
X = WMA(WMA(MACD_Value, (ma_length / 2) / 3) * 3 - WMA(MACD_Value, (ma_length / 2) / 2) - WMA(MACD_Value, (ma_length / 2)), (ma_length / 2));
Y = WMA(WMA(MACD_Avg, (ma_length / 2) / 3) * 3 - WMA(MACD_Avg, (ma_length / 2) / 2) - WMA(MACD_Avg, (ma_length / 2)), (ma_length / 2));
}
;



PercentR_MAC: in the settings under inputs select smoothing on both PercentR and Moving averages...Change the moving averages to 3 for line 1 and 5 for line 2. Keep PercentR setting at 14 periods on 5 min and change to 9 periods on 15 min chart.

# filename: MR__EZ_PercentR_MAC_
# idea source: @HighBredCloud and https://usethinkscript.com/threads/moving-average-crossover-rsi-indicator-for-thinkorswim.185/

# Code: Thanson Stevens, @korygill and netarchitech

# V11.11.2019 - netarchitech added multiple-choice smoothing per HighBredCloud request
# V11.12.2019 - netarchitech modified several variables per HighBredCloud request
# V11.12.2019 - netarchitech modified several inputs per HighBredCloud request


declare lower;

# PercentR_MAC

input length = 14;
def over_Bought = 80;
def over_Sold = 20;

def lowBand = 10; #Smoothing LowerBand
def data = close;
def lower = low; #Research Lower = Low?

def highest = Highest(high, length);
def divisor = highest - Lowest(low, length);
def PI = 3.14159265359;
def a1 = Exp(-PI * Sqrt(2) / lower);
def coeff2 = 2 * a1 * Cos(Sqrt(2) * PI / lower);
def coeff3 = - Power(a1, 2);
def coeff1 = 1 - coeff2 - coeff3;
def filt = coeff1 * (data + (data[1])) / 2 + coeff2 * (filt[1]) + coeff3 * (filt[2]);

input PercentRMALength1 = 3;
input PercentRMALength2 = 5;
input PercentRMAType = AverageType.SIMPLE;

# plot and smooth PercentR
plot "%R" = if divisor equals 0 then 0 else 100 - 100 * (highest - close) / divisor;
"%R".DefineColor("OverBought", GetColor(9)); #GetColor(9));
"%R".DefineColor("Normal", GetColor(7));
"%R".DefineColor("OverSold", GetColor(1)); #GetColor(1));
"%R".AssignValueColor(if "%R" > over_Bought then "%R".Color("OverBought") else if "%R" < over_Sold then "%R".Color("OverSold") else "%R".Color("Normal"));
"%R".SetLineWeight(3);
"%R".Hide();

# plot and smooth the PercentR Moving Averages
def PercentRMA5 = MovingAverage(PercentRMAType, "%R", PercentRMALength1);
plot PercentRMovAvg5 = PercentRMA5;
PercentRMovAvg5.SetDefaultColor(Color.GREEN);
PercentRMovAvg5.SetLineWeight(3);
PercentRMovAvg5.hide();

def PercentRMA8 = MovingAverage(PercentRMAType, "%R", PercentRMALength2);
plot PercentRMovAvg8 = PercentRMA8;
PercentRMovAvg8.SetDefaultColor(Color.RED);
PercentRMovAvg8.SetLineWeight(3);
PercentRMovAvg8.hide();

input applySelectSmoothing = yes;

def smooth_it = EhlersSuperSmootherFilter(if divisor equals 0 then 0 else 100 - 100 * (highest - close) / divisor, lowBand);
def smooth_MA5 = EhlersSuperSmootherFilter(MovingAverage(PercentRMAType, "%R", PercentRMALength1));
def smooth_MA8 = EhlersSuperSmootherFilter(MovingAverage(PercentRMAType, "%R", PercentRMALength2));


input SelectSmoothingType = {default "PercentR Only", "MAs Only", "PercentR & MAs", "No Smoothing"};

plot X;
X.AssignValueColor(if "%R" > over_Bought then "%R".Color("OverBought") else if "%R" < over_Sold then "%R".Color("OverSold") else "%R".Color("Normal"));
X.SetLineWeight(3);
plot Y;
Y.SetDefaultColor(Color.GREEN);
Y.SetLineWeight(2);
plot Z;
Z.SetDefaultColor(Color.RED);
Z.SetLineWeight(2);

switch (SelectSmoothingType) {
case "PercentR Only":
X = if applySelectSmoothing and "%R" then smooth_it else "%R";
Y = if applySelectSmoothing and PercentRMA5 then PercentRMA5 else PercentRMA5;
Z = if applySelectSmoothing and PercentRMA8 then PercentRMA8 else PercentRMA8;
case "MAs Only":
X = if applySelectSmoothing and "%R" then "%R" else "%R";
Y = if applySelectSmoothing and PercentRMA5 then smooth_MA5 else PercentRMA5;
Z = if applySelectSmoothing and PercentRMA8 then smooth_MA8 else PercentRMA8;
case "PercentR & MAs":
X = if applySelectSmoothing and "%R" then smooth_it else "%R";
Y = if applySelectSmoothing and PercentRMA5 then smooth_MA5 else PercentRMA5;
Z = if applySelectSmoothing and PercentRMA8 then smooth_MA8 else PercentRMA8;
case "No Smoothing":
X = if applySelectSmoothing and"%R" then "%R" else "%R";
Y = if applySelectSmoothing and PercentRMA5 then PercentRMA5 else PercentRMA5;
Z = if applySelectSmoothing and PercentRMA8 then PercentRMA8 else PercentRMA8;
}

plot OverBought = over_Bought;
OverBought.SetDefaultColor(Color.DARK_RED);
OverBought.HideTitle();

plot OverSold = over_Sold;
OverSold.SetDefaultColor(Color.DARK_GREEN);
OverSold.HideTitle();

plot fifty_line = 50;
fifty_line.SetDefaultColor(GetColor(8));
fifty_line.HideTitle();
fifty_line.SetStyle(Curve.SHORT_DASH);


# plot the Breakout Signals
input showBreakoutSignals = no;

plot UpSignal = if "%R" crosses above OverSold then OverSold else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.SetLineWeight(3);
UpSignal.HideTitle();

plot DownSignal = if "%R" crosses below OverBought then OverBought else Double.NaN;
DownSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.SetLineWeight(3);
DownSignal.HideTitle();


AddCloud(0, over_Sold, Color.DARK_GREEN, Color.DARK_GREEN);
AddCloud(over_Bought, 100, Color.DARK_RED, Color.DARK_RED);


# Gmode

def lengthRSI = 14;
def price = close;

def averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(averageType, price - price[1], lengthRSI);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), lengthRSI);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
RSI.SetDefaultColor(CreateColor(0, 102, 204));
RSI.SetLineWeight(3);
#RSI.HideTitle();
RSI.HideBubble();
RSI.Hide();

def n1 = 9; #Channel Length
def n2 = 26; #Average Length
def n3 = 13; #Short length
def multi = no; #Multi-exchange?

def src0 = hlc3;

def src1 = hlc3(period = AggregationPeriod.MONTH);
def src2 = hlc3(period = AggregationPeriod.MONTH);
def src3 = hlc3(period = AggregationPeriod.MONTH);
def src4 = hlc3(period = AggregationPeriod.MONTH);

script tci {

input src = hlc3;
input n1 = 9; #Channel Length
input n2 = 26; #Average Length
plot tci = MovAvgExponential((src - MovAvgExponential(src, n1)) / (0.025 * MovAvgExponential(AbsValue(src - MovAvgExponential(src, n1)), n1)), n2) + 50;
tci.Hide();
}

#mf(src) => rsi(sum(volume * (change(src) <= 0 ? 0 : src), n3), sum(volume * (change(src) >= 0 ? 0 : src), n3))

script mf {

input src = hlc3;
input n3 = 13; #Short length


def rsi = reference RSI();


#plot mf = rsi(Sum(volume * (if Average(src) <= 0 then 0 else src), n3), Sum(volume * (if Average(src) >= 0 then 0 else src), n3));
plot mf = RSI(n3, src);
mf.Hide();
}

script willy {

input src = hlc3;
input n2 = 26; #Average Length
plot willy = 60 * (src - Highest(src, n2)) / (Highest(src, n2) - Lowest(src, n2)) + 80;
willy.Hide();

}

#csi(src) => avg(rsi(src, n3),tsi(src0,n1,n2)*50+50)

script csi {

input src = hlc3;
input n1 = 9; #Channel Length
input n2 = 26; #Average Length
input n3 = 13; #Short length

def rsi = reference RSI();

plot csi = RSI(n3, src) + TrueStrengthIndex(n1, n2) / 2 * 50 + 50;
csi.Hide();

}

script godmode {

input src = hlc3;
def rsi = reference RSI();
plot godmode = (tci(src) + CSI(src) + mf(src) + willy(src)) / 4;
godmode.Hide();

}

script tradition {

input src = hlc3;
input n3 = 13; #Short length

def rsi = reference RSI();

plot tradition = (tci(src) + mf(src) + RSI(n3, src)) / 3;
tradition.Hide();

}


def wt1 = if multi then (godmode(src0) + godmode(src1) + godmode(src2) + godmode(src3) + godmode(src4) / 5) else tradition(src0);

def wt2 = SimpleMovingAvg(wt1, 6);

def extended = if wt2 < 20 then wt2 + 5 else if wt2 > 80 then wt2 - 5 else Double.NaN;

plot wta = wt1;
wta.SetDefaultColor(Color.GREEN);
wta.SetLineWeight(2);
wta.Hide();

plot wtb = wt2;
wtb.SetDefaultColor(Color.RED);
wtb.SetLineWeight(2);
wtb.Hide();

plot ext = extended; #Caution!
ext.SetPaintingStrategy(PaintingStrategy.POINTS);
ext.SetDefaultColor(Color.YELLOW);
ext.SetLineWeight(3);


I would love to hear your findings with the two indicators above...I will do my own testing further with FISH and Schaff and let you know my opinion.
 
H

HighBredCloud

Active member
@vvcv are you able to post the study of the Schaff indicator with the dynamic colored lines? I would like to see how the ENTRY and EXIT points are reflected on the dynamic colored version.
 
vvcv

vvcv

New member
@HighBredCloud

Thanks for the indicators. I'll be testing them this week.

My Schaff variation has two Shaff lines (Trend and Wave) and an EMA. Trade the Wave in the direction of the Trend line. For example, if the Trend Line is on top, then enter when the Wave Line is on the bottom/oversold area. You can use the EMA cross as a confirmation. Also, if the MACD Value line is moving up, you can use the Schaff Wave in oversold area to enter first position. Schaff Wave will go up and come back down to the oversold area where you can enter into a second position - if the Schaff Trend or MACD Value are still in up trend. Put another way, the Schaff Wave Line lets you see the 'waves' inside a MACD trend move.

Code:
#STSW = Schaff Trend Line and Schaff Wave Line
#Schaff Trend Line = Used for quick up/down trend declaration
#Schaff Wave Line = Trade Wave in the direction of trend as
#declared by Trend Line.
#Schaff Wave Line can be used alone to enter trend
#declared by the MACD.
#Schaff Wave can be used with the EMA for signals

declare lower;

input fastLengthTrend = 48;
input slowLengthTrend = 104;
input KPeriodTrend = 36;
input DPeriodTrend = 8;
input averageTypeTrend = AverageType.EXPONENTIAL;
input fastLengthWave = 12;
input slowLengthWave = 26;
input KPeriodWave = 9;
input DPeriodWave = 2;
input over_bought = 75;
input over_sold = 25;
input averageTypeWave = AverageType.EXPONENTIAL;

def macdTrend = MovingAverage(averageTypeTrend, close, fastLengthTrend) - MovingAverage(averageTypeTrend, close, slowLengthTrend);
def macdWave = MovingAverage(averageTypeWave, close, fastLengthWave) - MovingAverage(averageTypeWave, close, slowLengthWave);
def fastK1Trend = FastKCustom(macdTrend, KPeriodTrend);
def fastK1Wave = FastKCustom(macdWave, KPeriodWave);
def fastD1Trend = MovingAverage(averageTypeTrend, fastK1Trend, DPeriodTrend);
def fastD1Wave = MovingAverage(averageTypeWave, fastK1Wave, DPeriodWave);
def fastK2Trend = FastKCustom(fastD1Trend, KPeriodTrend);
def fastK2Wave = FastKCustom(fastD1Wave, KPeriodWave);
plot STCTrend = MovingAverage(averageTypeTrend, fastK2Trend, DPeriodTrend);
plot STCWave = MovingAverage(averageTypeWave, fastK2Wave, DPeriodWave);
plot OverBought = over_bought;
plot OverSold = over_sold;

STCTrend.SetDefaultColor(GetColor(8));
STCWave.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));

STCTrend.DefineColor("Up", GetColor(1));
STCTrend.DefineColor("Down", GetColor(0));
STCTrend.AssignValueColor(if STCTrend > STCTrend[1] then STCTrend.Color("Up") else STCTrend.Color("Down"));
STCWave.DefineColor("Up", GetColor(1));
STCWave.DefineColor("Down", GetColor(0));
STCWave.AssignValueColor(if STCWave > STCWave[1] then STCWave.Color("Up") else STCWave.Color("Down"));

input lengthWave = 10;
plot AvgExpWave = ExpAverage(STCWave, lengthWave);
AvgExpWave.SetDefaultColor(GetColor(1));
Here's a look at a DOM that shows High Volume levels. Give it a look, and when considering an indicator like the TPO, you can use that data (which i've marked with colored lines on the image) to make a better TPO type indicator which would point out this kind of data. I placed a red line at a high volume area. So, when trading for example, you would look at that price as very difficult to move further down below it. So, you would place a short just below this high volume area, or look for a bounce of this price. If an indicator can point that out....wow!

 

Top