NexusFi: Find Your Edge


Home Menu

 





Tradingview RSI code to Thinkscript


Discussion in ThinkOrSwim

Updated
    1. trending_up 4,251 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Tradingview RSI code to Thinkscript

  #1 (permalink)
kris00l
Plainsboro, NJ USA
 
Posts: 1 since Dec 2018
Thanks Given: 0
Thanks Received: 0

Can you please help me to figure out Tradingview RSI code to Thinkscript?

Thanks

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #2 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79


kris00l View Post
Can you please help me to figure out Tradingview RSI code to Thinkscript?

Thanks


here's mine version. not tradingview's one

 
Code
declare lower;
input length = 14;
input os = 10;
input ob = 90;
def gain = if close > close[1] then close - close[1] else 0;
def loss = if close < close[1] then close[1] - close else 0;
def firstgain = Sum(gain, length) / length;
def firstloss = Sum(loss, length) / length;
def avgain = (firstgain[1] * (length - 1) + gain) / length;
def avloss = (firstloss[1] * (length - 1) + loss) / length;
def rs = avgain / avloss;
plot overbought = ob;
plot oversold = os;
plot rsi = 100 - (100 / (1 + rs));

Follow me on Twitter Reply With Quote
  #3 (permalink)
bluedragon
Los Angeles, United States
 
Posts: 20 since Dec 2018
Thanks Given: 0
Thanks Received: 3


This is the one im using

 
Code
RSI divergence, by Mobius 

 

 

declare lower;  

 

input nRSI = 5; #hint nRSI: RSI periods  

input nTrend = 100; #hint nTrend: RSI Trend Line periods  

input over_Bought = 70; #hint over_Bought: Over Bought Line  

input over_Sold = 30; #hint over_Sold: Over Sold Line  

input MidLine = 50; #hint MidLine: MidLine  

input TrendLine = {EMA, SMA, default LRL, WMA};  

input AlertOn = yes;  

 

def o = open;  

def h = high;  

def l = low;  

def c = close;  

def NetChgAvg = WildersAverage(c - c[1], nRSI);  

def TotChgAvg = WildersAverage(AbsValue(c - c[1]), nRSI);  

def ChgRatio = if TotChgAvg != 0  

                           then NetChgAvg / TotChgAvg  

                           else 0;  

 

plot RSI = 50 * (ChgRatio + 1);  

plot OverSold = over_Sold;  

plot OverBought = over_Bought;  

plot RSItrend;  

 

switch (TrendLine) {  

case EMA:  

        RSItrend = ExpAverage(RSI, nTrend);  

case SMA:  

        RSItrend = Average(RSI, nTrend);  

case LRL:  

        RSItrend = InertiaAll(RSI, nTrend);  

case WMA:  

        RSItrend = WMA(RSI, nTrend);  

}  

 

def lowestLow = if RSI > over_Sold  

                              then l  

                              else if RSI < over_Sold and l < lowestLow[1]  

                                      then l  

                                     else lowestLow[1];  

def lowestRSI = if RSI > MidLine  

                            then RSI  

                            else if RSI < MidLine and RSI < lowestRSI[1]  

                                    then RSI  

                                    else lowestRSI[1];  

def divergentLow = if RSI < over_Sold and l <= lowestLow[1] and RSI > lowestRSI[1]  

                                   then over_Sold  

                                   else Double.NaN;  

 

plot DLow = divergentLow;  

        DLow.SetPaintingStrategy(PaintingStrategy.POINTS);  

        DLow.SetLineWeight(2);  

        DLow.SetDefaultColor(Color.YELLOW);  

 

def highestHigh = if RSI < over_Bought  

                               then h  

                               else if RSI > over_Bought and h > highestHigh[1]  

                                       then h  

                                      else highestHigh[1];  

def highestRSI = if RSI < MidLine  

                             then RSI  

                             else if RSI > MidLine and RSI > highestRSI[1]  

                                     then RSI  

                                     else highestRSI[1];  

def divergentHigh = if RSI > over_Bought and h >= highestHigh and RSI < highestRSI  

                                    then over_Bought  

                                   else if RSI < over_Bought and c < o  

                                           then Double.Nan  

                                           else divergentHigh[1];  

 

plot DHigh = divergentHigh;  

        DHigh.SetPaintingStrategy(PaintingStrategy.POINTS);  

        DHigh.SetLineWeight(2);  

        DHigh.SetDefaultColor(Color.YELLOW);  

 

RSI.DefineColor("OverBought", GetColor(5));  

RSI.DefineColor("Normal", GetColor(7));  

RSI.DefineColor("OverSold", GetColor(1));  

RSI.AssignValueColor(if RSI > over_Bought  

                                      then RSI.Color("OverBought" 

                                      else if RSI < over_Sold  

                                              then RSI.Color("OverSold"); 

                                             else RSI.Color("Normal"); 

 

);  

OverSold.SetDefaultColor(Color.BLUE);  

OverBought.SetDefaultColor(Color.BLUE);  

 

def AlertCond1 = RSI crosses RSItrend;  

 

# Alert(AlertCond1, "RSI crossed RSI Trend Line", Alert.Bar, Sound.Bell);  

 

# End Code Wilders RSI with Divergence

Reply With Quote




Last Updated on December 23, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts