#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