The Relative Strength Volatility-Adjusted Exponential Moving Average For ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
The Relative Strength Volume-Adjusted Exponential Moving Average (RS VA EMA) is a technical indicator proposed by Vitali Apirine to help identify trends. Its calculation is similar to that of the original EMA, however, the multiplier used in the formula is adjusted for the relative strength of volume.

The strength of volume is calculated as the difference between positive and negative volume flows. Volume flow is positive when the specified price is higher than the prior price; it is negative when the specified price is lower than the prior price.

This is also a built-in ToS indicator: RS_VA_EMA
https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RS-VA-EMA

vixS_CHARTS.png

https://www.tradingview.com/script/3aTtNsrv-TASC-2022-03-Relative-Strength-Volatility-Adjusted-EMA/

minor code fix, Bar Color, MTF - 08/2024

CSS:
# Indicator for TOS
#//  TASC Issue: March 2022 - Vol. 40, Issue 3
#//     Article: Relative Strength Moving Averages -
#//               Part 3: The Relative Strength
#//                        Volatility-Adjusted
#//                     Exponential Moving Average
#//                         (RS VolatAdj EMA)
#//  Article By: Vitali Apirine
#//    Language: TradingView's Pine Script v5
#// Provided By: PineCoders, for tradingview.com
#indicator('TASC 2022.03 RS VolatAdj EMA', overlay = true)
# Converted by Sam4Cok@Samer800    - 08/2024
# minor code fix, Bar Color, MTF - 08/2024
input colorBars = yes;
input timeframe = AggregationPeriod.FIVE_MIN;
input vixSelection = "VIX";                # 'VIX Selection'
input movAvgType = AverageType.EXPONENTIAL;
input chartSource = FundamentalType.CLOSE;      # 'Source'
input MovingAveragePeriod = 20;      # 'EMA Period'
input VolatilityStrengthPeriod = 20; # 'Volatility Strength Period'
input Multiplier = 10.0;             # 'Multiplier'

def na = Double.NaN;
def current = GetAggregationPeriod();
def tf = Max(current, timeframe);
def source = Fundamental(FundamentalType = chartSource, Period = tf);
#// Relative Strength Volatility-Adjusted EMA Function
Script rsvae {
input source = close;
input srcVIX = close;
input periodEMA = 20;
input periodVolatS = 20;
input multVolatS = 10;

    def source1 = CompoundValue(1, if !source[1] then source else source[1], source);
    def MULT = 2.0 / (max(1.0, periodEMA) + 1.0);
    def ALPH = 2.0 / (max(1.0, periodVolatS) + 1.0);
    def BETA = 1.0 - ALPH;
    def volatUp = if source > source1 then srcVIX else 0.0;
    def volatDn = if source < source1 then srcVIX else 0.0;
    def volatUpEMA = volatUp  * ALPH + if(volatUpEMA[1], volatUpEMA[1],volatUp) * BETA;
    def volatDnEMA = volatDn  * ALPH + if(volatDnEMA[1], volatDnEMA[1],volatDn) * BETA;
    def VolatPer =  AbsValue(volatUpEMA - volatDnEMA) / (volatUpEMA + volatDnEMA);
    def VolatS = if isNaN(VolatPer) then 0 else VolatPer;
    def rsVolatAdjEMA;
    def rsVolatAdjEMA1 = if rsVolatAdjEMA[1] then rsVolatAdjEMA[1] else source;
    def lastRSVAE = CompoundValue(1, rsVolatAdjEMA1, source);
    rsVolatAdjEMA = lastRSVAE + (source - lastRSVAE) * MULT * (1.0 +  VolatS * max(0.0, multVolatS));
    plot out = rsVolatAdjEMA;
}
def VIXvalue = close(Symbol = vixSelection, Period = tf);
def srcVIX = if isNaN(VIXvalue) then srcVIX[1] else VIXvalue;
def RSvolatAdjEMA = rsvae(source, srcVIX, MovingAveragePeriod, VolatilityStrengthPeriod, Multiplier);
def MovAvg        = MovingAverage(movAvgType, source, MovingAveragePeriod);

def MovAvgLine = MovAvg;
plot RSVAE = if RSvolatAdjEMA then RSvolatAdjEMA else na;

#-- cloud
AddCloud(RSVAE, MovAvgLine, Color.DARK_GREEN, Color.DARK_RED, yes);

#-- Bar Color.
def Col     = RSVAE > MovAvgLine; # ? #FF8C0033 : #2096F233

AssignPriceColor(if !colorBars then Color.CURRENT else if Col then Color.GREEN else COlor.RED);
                

#--- END of CODE
 
Last edited:
Script doesn't show any errors but does not show up on my chart. I'm using it on individual stocks.
 
Script doesn't show any errors but does not show up on my chart. I'm using it on individual stock

I just wanted to let you know that it worked fine for me on NVDA daily and weekly chart but didn't show up at all on lower time frames. Perhaps because it uses the VIX daily close as an input but not sure about that part.
 
It only works on higher timeframe but it doesn’t work in smaller timeframe. Original version from TradingView works on smaller timeframe.
 
A review of the original Tradingview code reveals that it was written for the daily timeframe
https://www.tradingview.com/script/3aTtNsrv-TASC-2022-03-Relative-Strength-Volatility-Adjusted-EMA/

Because as @Russ_in_Texas points out, it uses the daily VIX in its calculations.

Whether or not, Tradingview has the ability for this script to function on lower timeframes;
does not change the fact that the proper use of this indicator is on the daily chart.
The ToS version of this code only applies to the daily chart.


All that said, ThinkOrSwim has its own Relative Strength Volatility-Adjusted Exponential Moving Average
https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RS-VA-EMA
Which does not use the daily VIX and therefore 'might' work on the lower timeframes.
Hope this helps.


@Morris @Russ_in_Texas @jackaltr8s
 
Last edited:
It only works on higher timeframe but it doesn’t work in smaller timeframe. Original version from TradingView works on smaller timeframe.
just fixed the code. added MTF option, and bar color.
https://usethinkscript.com/threads/...nential-moving-average-for-thinkorswim.19356/

the chart post by @samer800 is 5 min chart. Lower timeframe doesn't work
just fixed the code. added MTF option, and bar color.
https://usethinkscript.com/threads/...nential-moving-average-for-thinkorswim.19356/
 

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