Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
Node js : find the same RSI as tradingview

the following code works but does not give me the same value as on tradingview. I don't understand the problem

                var rsi_gain = 0;
                var rsi_loss = 0;

                for (let i = 18; i <= 20; i++) {
                    
                    rsi_gain += (content[i][4] > content[i - 1][4]) ? (content[i][4] - content[i - 1][4]) : 0;
                    rsi_loss += (content[i][4] < content[i - 1][4]) ? (content[i - 1][4] - content[i][4]) : 0;

                }
                
                
                // Calcul Average Gain
                var AVG_gain = (rsi_gain / 3); // (Gains / Periode)


                // Calcul Average Loss
                var AVG_loss = (rsi_loss / 3); // (Pertes / Periode)
   
                
                //RS
                var RS = (AVG_gain / AVG_loss);
         
                
                //RSI
                var RSI = 100 - (100 / (1 + RS));

My result with these values (48979.05,48861.92,48964.83) : 53.23 Tradingview result : 62.61

image : https://www.zupimages.net/viewer.php?id=21/51/y7ik.jpeg

Thank you

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The first N bars (length) are calculated by using a simple moving average, afterwards you have to apply a exponential average.

https://www.tradingview.com/pine-script-reference/v5/#fun_ta{dot}rsi

https://www.tradingview.com/pine-script-reference/v5/#fun_ta{dot}rma

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!