Tarzan Indicator For ThinkOrSwim

tradebyday

Active member
Hello community,

I do not know if any of you will even want to try and accomplish this, but I myself will definitely be giving it a go (though I am very lack luster in coding). I have provided the script from MT4 below (which I believe is based in python?) as the guy who transferred it to tradingview's pinescript has hidden his source code. But this indicator is called "Tarzan" and is quite a useful trend indicator on the smaller time frames for futures and has shown promise in FX as well (where it was originally discovered by a colleague of mine). I am creating this thread to document my attempts at transferring this indicator over to TOS, but anyone else that wants to take a stab at it, please be my guess. It is a rather simple indicator based on a few MA's and the RSI. It essentially allows you to notice when price is trending or consolidating when combined with a decent trend system, helping you avoid some false signals. The less losses we take, the more gains we keep. Here is a link of what it is supposed to look like visually, and ultimately is the goal https://www.tradingview.com/script/bcVnD20w-PpSignal-Trazan-MT4-System/
 
Last edited by a moderator:
interesting. please share your results and findings after you test.

Took a first pass at it:

sWhqNU9.png


Ruby:
#Tarzan indicator to TOS V1.0
#
#CREDITS
# unknown
#
#CHANGELOG
# 2020.04.01 1.0 @diazlaz - Initial Port
#
#LINKS
# https://usethinkscript.com/threads/converting-tarzan-indicator-to-tos.2031/
# https://www.tradingview.com/script/bcVnD20w-PpSignal-Trazan-MT4-System/
#

declare lower;

input length = 5; 
input ma_length = 50;
input koridor  = 5;

input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);

def ma = average(RSI, 50);
plot upper = ma + koridor;
upper.SetDefaultColor(GetColor(8));
plot lower = ma - koridor;
lower.SetDefaultColor(GetColor(8));

plot k = ma;
k.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
k.AssignValueColor(if rsi > upper then COLOR.GREEN else if rsi < lower then COLOR.RED else COLOR.GRAY);

#End of Tarzan indicator to TOS V1.0
 
Very interesting indeed! Did a quick test on some different stocks and timeframes and the results is looking really good.
Thanks @tradebyday for bringing it here and thanks @diazlaz for the port.

Will share more results as i have more data later.
 
Dang you're fast! I went golfing today and was going to try and finish up my attempt after dinner but I guess I will put mine to the side for a few and test yours out. @horserider may be right in terms of its usefulness. I simply wanted to bring this out for testing on TOS since it is the platform I use on a daily basis. Great job @diazlaz !!!
 
@tradebyday it's interesting, there are a number of ways to interpret and improve upon it, let me know if you find any other ways to use it or any optimizations. i usually gravitate to simpler less complex indicators over the more complicated ones.
 
Definitely, this is meant to be used alongside others, so I do not know how it will be stand alone. But I do want to tweak it and play with the moving averages and such so I will share anything that makes it better or just simply more interesting
 
Image-66666666666666666.jpg


RSI bands stripped down version. Maybe someone likes the colors and 50 and OB/OS lines. Just changed the lengthbb to 50
 
@horserider The colors definitely make it easier to read (if using it to trade the crossovers). I want to take this and apply it to other lower indicators as well in a "plug-n-play" type format. I'll share if anything promising shows up but am going into this not expecting much. May try some sort of smoothing to the RSI or an RSI based indicator and see what happens
 
Can play with the inputs here and see what can get. Same idea just derivative RSI. Maybe bblength 50 and 8,8,8,13 ????

Code:
#  Derivative RSI Oscillator
#  Can be used alone as a smoother RSI or as part of the Carting Wealth strategy when combined    with the MACD and MAs Charting Wealth study.
#  By Horserider 12/25/2019
#

declare lower;

input length = 14;
input length1 = 5;
input length2 = 3;
input length3 = 9;
input price = close;
input overbought = 4;
input oversold = -4;

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

def RSI = (50 * (ChgRatio + 1) - 50);

#################################
plot  ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.YELLOW);
ZeroLine.SetLineWeight(1);

plot ob = overbought;
ob.SetDefaultColor(Color.GRAY);
ob.SetLineWeight(1);

plot os = oversold;
os.SetDefaultColor(Color.GRAY);
os.SetLineWeight(1);

input averageType = AverageType.EXPONENTIAL;
input averageType2 = averageType.SIMPLE;
def x = MovingAverage(averageType,RSI, length1);
def x2 = MovingAverage(averageType, x, length2);
def xs = MovingAverage(averageType2, x2 , length3);
def rsi__linediff = x2 - xs;

plot RSI_Line = rsi__linediff;
RSI_Line.SetDefaultColor(GetColor(1));

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

input AverageTypeBB = {default SMA, EMA, HMA};
input displaceBB = 0;
input lengthBB = 5;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;


plot midline ;


switch (AverageTypeBB) {
case SMA:

    midline   = reference BollingerBands( RSI_Line, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up).Midline;
case EMA:


    midline   = reference BollingerBands( RSI_Line, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).Midline;
case HMA:


    midline   = reference BollingerBands( RSI_Line, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).Midline;
}

midline.SetDefaultColor(GetColor(3));
 
Just off preliminary testing with the original Tarzan indicator, my favorite settings are as follows: 20,21,5,close,hull. These settings are very smooth and if you combine it with some heiken ashi candles and a moving average of choice, or simply use this indicator (https://tos.mx/CvBHnWg) with settings close,OHLC4,(moving avg value of choice),0 then you can find some decent trends to capitalize on in various tickers and time frame preferences. You can edit that indicator to the preferred type of moving average if you wish by editing the source. Going to try and combine Tarzan and what @horserider shared and see what becomes of it over the next week
 
Recommend the ultimate RSI. Search for it. Stripped down is same as this but with OB/OS/50 lines. Full version has more info.
 
@tradebyday I did the derivative rsi variation. Smoother curve as expected but signals slightly slower. Somehow I guess I erased it while playing around with different studies so not able to post the code. Not sure I will redo it either. No advantage to my trading so just sticking with ultimate RSI with a longer length.
 
@horserider that I understand. You want to grab entries as close to the tops and bottoms as possible. I will be playing with the ultimate RSI tarzan combo next couple days. We'll see if it improves on the original at all. Whether or not that makes it worth using is a different story haha
 
But the added bonus of color changes for the lines allowing delayed entries if it is a false signal, and the bands could allow early exits, so it does "look" better. I just want to test it. The Korridor in tarzan helps a bit with eliminating false signals, just look at the marketforce indicator mod I posted earlier in the other forum (granted the marketforce tarzan would probably do poorly in real trading, I thought the way it displayed the data was rather cool).
 
From a visual standpoint, I thought the indicator would look better. Maybe I just need this baby on a 50" TV... but anyways I do like how both the tarzan korridor around the moving avg AND the ultimate RSI color changes filter out range trades. Settings DEFINITELY need to be played with on a per asset traded basis and per time frame basis to find the sweet spot, but it does its job well when you find it. However, because of the visual strain for me I can not test this beyond /ES haha. Here is the code for people that have larger displays than mine...
Code:
#Tarzan + Ultimate RSI
#
#CREDITS
# unknown
#
#
#LINKS
#

declare lower;

input ma_length = 21;
input koridor  = 5;

# RSI Bands and Double RSI SMA Cross Long Term Trades
#Created by Horserider 7/20/2019

#RSI
input length = 20;
input over_Bought = 80;
input over_Sold = 20;
input price = close;
input averageType = AverageType.WILDERS;
input line = 50;

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

plot RSI = 50 * (ChgRatio + 1);
plot lline = 50;


#                ==== THE FIVE ====
RSI.DefineColor("Positive and Up", Color.GREEN);
RSI.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI.DefineColor("Negative and Down", Color.RED);
RSI.DefineColor("Negative and Up", Color.DARK_RED);
RSI.AssignValueColor(if RSI >= 50 then if RSI > RSI[1] then RSI.Color("Positive and Up") else RSI.Color("Positive and Down") else if RSI < RSI[1] then RSI.Color("Negative and Down") else RSI.Color("Negative and Up"));

# RSI 2
input length2 = 21;
input over_Bought2 = 80;
input over_Sold2 = 20;
input price2 = close;
input averageType2 = AverageType.WILDERS;

def NetChgAvg2 = MovingAverage(averageType2, price2 - price2[1], length2);
def TotChgAvg2 = MovingAverage(averageType2, AbsValue(price2 - price2[1]), length2);
def ChgRatio2 = if TotChgAvg2 != 0 then NetChgAvg2 / TotChgAvg2 else 0;

plot RSI2 = 50 * (ChgRatio2 + 1);

RSI2.DefineColor("Positive and Up", Color.GREEN);
RSI2.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI2.DefineColor("Negative and Down", Color.RED);
RSI2.DefineColor("Negative and Up", Color.DARK_RED);
RSI2.AssignValueColor(if RSI2 >= 50 then if RSI2 > RSI2[1] then RSI2.Color("Positive and Up") else RSI2.Color("Positive and Down") else if RSI2 < RSI2[1] then RSI2.Color("Negative and Down") else RSI2.Color("Negative and Up"));


AddCloud(RSI, RSI2, Color.GREEN, Color.RED);


#plot 5;

input AverageTypeBB = {default SMA, EMA, HMA};
input displaceBB = 0;
input lengthBB = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;

plot upperBand;
plot lowerBand;
def midline;


switch (AverageTypeBB) {
case SMA:
    upperBand = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up).UpperBand;
    lowerBand = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up).LowerBand;
    midline   = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up).Midline;
case EMA:
    upperBand = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).UpperBand;
    lowerBand = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).LowerBand;
    midline   = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).Midline;
case HMA:
    upperBand = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).UpperBand;
    lowerBand = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).LowerBand;
    midline   = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).Midline;
}

upperBand.SetDefaultColor(Color.GRAY);

lowerBand.SetDefaultColor(Color.GRAY);

def ma = ExpAverage(RSI, 50);
plot upper = ma + koridor;
upper.SetDefaultColor(GetColor(8));
plot lower = ma - koridor;
lower.SetDefaultColor(GetColor(8));

plot k = ma;
k.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
k.AssignValueColor(if RSI > upper then Color.GREEN else if RSI < lower then Color.RED else Color.GRAY);
 
Tarzan is similar to a strategy of that PETD that was annoying. It's an RSI with only the 50 and the strategy was stay long over 50, short under. I also think it was to demonstrate things are not overbought or oversold just because they are below certain level....
 
Hello, I am also very interested in this indicator, it seems very promissing at first glance. I have been playing around with this for 2 days I somehow I think it is awnsome in predicting reversal in forex currency pairs. However, it is never wise to trade reversal in forex pairs because of manipulation of big banks and they are not determined by supply and demand laws, so I am trying to experiment it on some other instruments that have supply and demand based price. Yet, somehow, this indicator just does not fit for those, one example is oil and other commodity like Cotton as well as gold. It does not make any sense, it works pretty well in predicting Spot Forex reversal but not other instruments that are intrinsically determined by supply and demand. Please, I would be happy if someone want to discuss and elaborate on this a little bit more.
 
@AlgofinC In regards to FX, unless you are trading hourly or higher TF then trading reversal is "safe" for scalping. But those higher TF you could be destroyed in the stop raids or other tactics taken by big money in FX, so definitely be careful there. Where I find its usefulness is positioning for reversal to VWAP on /ES futures. Try either on 10,000 tick chart, or 5min chart (if you want you can also do the /MES 4,000 tick chart). Using today, 4/17, as an example on the 10,000 tick chart... Long entry about 11am est, then second long entry at 3:10pm est, closing both out at 3:30pm est when price reached VWAP. /ES likes to touch VWAP AT LEAST once during RTH approx 80% of the time (last time I did a data check on that). So if you miss a VWAP tag play, then I would focus on a different strategy rest of day for /ES
 

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