Thread: Translate pinescript code to c++

  1. #1
    Registered User
    Join Date
    Nov 2021
    Posts
    1

    Translate pinescript code to c++

    What would be the c++ equivalent for this line of pinescript below?


    max := math.max(max, math.abs(series[i]))

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    Code:
    #include <iostream>
    #include <vector>
    #include <algorithm> // max
    #include <cmath>     // abs
     
    int main()
    {
        std::vector<int> series {-3, 4, 2, -9, 7, -1};
     
        int max = std::abs(series[0]);
     
        for (std::size_t i = 1; i < series.size(); ++i)
            max = std::max(max, std::abs(series[i]));
     
        std::cout << max << '\n';
    }
    A little inaccuracy saves tons of explanation. - H.H. Munro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. looking to translate standard code for integers
    By Brolaf Broski in forum C Programming
    Replies: 5
    Last Post: 11-14-2013, 06:28 PM
  2. Please translate
    By Ron in forum C Programming
    Replies: 24
    Last Post: 07-31-2008, 06:37 AM
  3. translate
    By limitmaster in forum C++ Programming
    Replies: 9
    Last Post: 08-13-2006, 01:55 AM
  4. just translate !
    By black in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 07-03-2002, 02:14 AM
  5. Can anyone translate this into C? from C++?
    By Wizard_D in forum C Programming
    Replies: 2
    Last Post: 12-19-2001, 02:44 PM

Tags for this Thread