Rex Entry / Exit Oscillator For ThinkOrSwim

blackbeard12

New member
Hey guys, I encourage you to hop on trading view and throw up "Rex Indicator," very powerful exit indicator that I'm sure some of y'all would like, if anyone knows how to convert it, the code is below. Def worth checking out, beautiful especially with range bars.
 
Last edited by a moderator:

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

Hi @blackbeard12, take it for a spin, let us know what your thoughts are and how you're currently using it.

Bs2uTuC.png


Ruby:
#REX Indicator System V1.0 for ThinkOrSwim
#
#VERSION
# 2020.05.03 @diazlaz - initial port/interpretation.
#
#LINK
#https://www.tradingview.com/script/m08Wp5xr-REX-by-vitelot/
#
#INSTRUCTION
#Best used as an exit indicator at default settings.
#Also doing well in entering positions by using TEMA(14)
#for REX and SMA(14) as signal.
#
#You need to tune it yourself according to your trading style.
#Use at your own risk.
#
#CREDITS
#Vitelot/Yanez/Vts Oct 2019
#

declare lower;

input rex_ma_type = {"EMA", default "SMA", "Tenkan", "TEMA"};
input sig_ma_type = {"EMA", default "SMA", "Tenkan", "TEMA"};
input smoothing = 14;
input smoothing_sig = 14;

#def tvb = 3*close-open-high-low;
def tvb = 3*close - (open+high+low);

def rex;
switch (rex_ma_type) {
case "EMA":
    rex = ExpAverage(tvb,smoothing);
case "SMA":
    rex = Average(tvb,smoothing);
case "Tenkan":
    rex = 0.5 * (highest(tvb, smoothing) + lowest(tvb, smoothing));
case "TEMA":
    rex = 3 * (ExpAverage(tvb,smoothing) - ExpAverage(ExpAverage(tvb,smoothing), smoothing)) + ExpAverage(ExpAverage(ExpAverage(tvb,smoothing), smoothing), smoothing);
}

def sig;
switch (sig_ma_type) {
case "EMA":
    sig = ExpAverage(rex,smoothing_sig);
case "SMA":
    sig = Average(rex,smoothing_sig);
case "Tenkan":
    sig = 0.5 * (highest(rex, smoothing_sig) + lowest(rex, smoothing_sig));
case "TEMA":
    sig = 3 * (ExpAverage(rex,smoothing_sig) - ExpAverage(ExpAverage(rex,smoothing_sig), smoothing_sig)) + ExpAverage(ExpAverage(ExpAverage(tvb,smoothing_sig), smoothing_sig), smoothing_sig);
}

AddLabel(1, "REX", COLOR.ORANGE);
plot pRex = rex;
pRex.SetLineWeight(2);

plot pSig = sig;
plot pZeroline = 0;

#END of REX for ThinkOrSwim 1.0
 
Gave the REX script a quick back test. Lots of options. Thanks for converting this. It's going to take some tweaking if it's going to fit into my system.
 
@Joshua can you code for the REX INDICATOR for my watchlist to show a light blue color in the column for every time the pRex touches (coming from the bottom) and/or crosses up above the pSig? I'll be using this on a 5M chart but would be great if it worked for all timeframes. Your time is much appreciated.
Ruby:
#REX Indicator System V1.0 for ThinkOrSwim
#
#VERSION
# 2020.05.03 @diazlaz - initial port/interpretation.
#
#LINK
#https://www.tradingview.com/script/m08Wp5xr-REX-by-vitelot/
#
#INSTRUCTION
#Best used as an exit indicator at default settings.
#Also doing well in entering positions by using TEMA(14)
#for REX and SMA(14) as signal.
#
#You need to tune it yourself according to your trading style.
#Use at your own risk.
#
#CREDITS
#Vitelot/Yanez/Vts Oct 2019
#

declare lower;

input rex_ma_type = {"EMA", default "SMA", "Tenkan", "TEMA"};
input sig_ma_type = {"EMA", default "SMA", "Tenkan", "TEMA"};
input smoothing = 14;
input smoothing_sig = 14;

#def tvb = 3*close-open-high-low;
def tvb = 3*close - (open+high+low);

def rex;
switch (rex_ma_type) {
case "EMA":
rex = ExpAverage(tvb,smoothing);
case "SMA":
rex = Average(tvb,smoothing);
case "Tenkan":
rex = 0.5 * (highest(tvb, smoothing) + lowest(tvb, smoothing));
case "TEMA":
rex = 3 * (ExpAverage(tvb,smoothing) - ExpAverage(ExpAverage(tvb,smoothing), smoothing)) + ExpAverage(ExpAverage(ExpAverage(tvb,smoothing), smoothing), smoothing);
}

def sig;
switch (sig_ma_type) {
case "EMA":
sig = ExpAverage(rex,smoothing_sig);
case "SMA":
sig = Average(rex,smoothing_sig);
case "Tenkan":
sig = 0.5 * (highest(rex, smoothing_sig) + lowest(rex, smoothing_sig));
case "TEMA":
sig = 3 * (ExpAverage(rex,smoothing_sig) - ExpAverage(ExpAverage(rex,smoothing_sig), smoothing_sig)) + ExpAverage(ExpAverage(ExpAverage(tvb,smoothing_sig), smoothing_sig), smoothing_sig);
}

AddLabel(1, "REX", COLOR.ORANGE);
plot pRex = rex;
pRex.SetLineWeight(2);

plot pSig = sig;
plot pZeroline = 0;

#END of REX for ThinkOrSwim 1.0
 
Last edited by a moderator:
Watchlist columns must basically be hard-coded. There is no additional screen that pops up in which to adjust their settings. You can only select the aggregation period to be used, and whether or not to include extended hours. The vast majority of this particular indicator is dedicated to settings selection, so you will have to edit them manually, comment/uncomment them if you want to change them.

Ruby:
def smoothing = 14;
def smoothing_sig = 14;

#def tvb = 3*close-open-high-low;
def tvb = 3*close - (open+high+low);

def rex;
#switch (rex_ma_type) {
#case "EMgsA":
    #rex = ExpAverage(tvb,smoothing);
#case "SMA":
    rex = Average(tvb,smoothing);
#case "Tenkan":
    #rex = 0.5 * (highest(tvb, smoothing) + lowest(tvb, smoothing));
#case "TEMA":
    #rex = 3 * (ExpAverage(tvb,smoothing) - ExpAverage(ExpAverage(tvb,smoothing), smoothing))  + #ExpAverage(ExpAverage(ExpAverage(tvb,smoothing), smoothing), smoothing);
#}

def sig;
#switch (sig_ma_type) {
#case "EMA":
    #sig = ExpAverage(rex,smoothing_sig);
#case "SMA":
    sig = Average(rex,smoothing_sig);
#case "Tenkan":
    #sig = 0.5 * (highest(rex, smoothing_sig) + lowest(rex, smoothing_sig));
#case "TEMA":
    #sig = 3 * (ExpAverage(rex,smoothing_sig) - ExpAverage(ExpAverage(rex,smoothing_sig), #smoothing_sig)) + ExpAverage(ExpAverage(ExpAverage(tvb,smoothing_sig), smoothing_sig), smoothing_sig);
#}

plot x = rex;

x.AssignValueColor(
    if crosses(rex,sig,crossingDirection.ABOVE) then color.cyan
    else color.BLACK);
AssignBackgroundColor(
    if crosses(rex,sig,crossingDirection.ABOVE) then color.cyan
    else color.BLACK);
 
Watchlist columns must basically be hard-coded. There is no additional screen that pops up in which to adjust their settings. You can only select the aggregation period to be used, and whether or not to include extended hours. The vast majority of this particular indicator is dedicated to settings selection, so you will have to edit them manually, comment/uncomment them if you want to change them.

Ruby:
def smoothing = 14;
def smoothing_sig = 14;

#def tvb = 3*close-open-high-low;
def tvb = 3*close - (open+high+low);

def rex;
#switch (rex_ma_type) {
#case "EMgsA":
    #rex = ExpAverage(tvb,smoothing);
#case "SMA":
    rex = Average(tvb,smoothing);
#case "Tenkan":
    #rex = 0.5 * (highest(tvb, smoothing) + lowest(tvb, smoothing));
#case "TEMA":
    #rex = 3 * (ExpAverage(tvb,smoothing) - ExpAverage(ExpAverage(tvb,smoothing), smoothing))  + #ExpAverage(ExpAverage(ExpAverage(tvb,smoothing), smoothing), smoothing);
#}

def sig;
#switch (sig_ma_type) {
#case "EMA":
    #sig = ExpAverage(rex,smoothing_sig);
#case "SMA":
    sig = Average(rex,smoothing_sig);
#case "Tenkan":
    #sig = 0.5 * (highest(rex, smoothing_sig) + lowest(rex, smoothing_sig));
#case "TEMA":
    #sig = 3 * (ExpAverage(rex,smoothing_sig) - ExpAverage(ExpAverage(rex,smoothing_sig), #smoothing_sig)) + ExpAverage(ExpAverage(ExpAverage(tvb,smoothing_sig), smoothing_sig), smoothing_sig);
#}

plot x = rex;

x.AssignValueColor(
    if crosses(rex,sig,crossingDirection.ABOVE) then color.cyan
    else color.BLACK);
AssignBackgroundColor(
    if crosses(rex,sig,crossingDirection.ABOVE) then color.cyan
    else color.BLACK);
@Joshua your time and detailed explanation is mush appreciated. This is exactly what I needed.

4:47am 10/21/21
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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