Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I use an indicator to calculate values for a series?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I use an indicator to calculate values for a series?

    I'm writing a custom NinjaScript indicator in which I need to do several mathematical calculations and formulations on the data series. I'm new to C# but an expert in Mathematica and also ThinkScript. I would like to use some of the standard Ninja indicators for the intermediate calculations such as SUM or standard deviation in my script formulation. For example, I would like to sum up several values in a series such as the closing prices over n-candles: and use that value in my own calculations. The Ninja SUM indicator apparently does this summation but I can't just use it as a simple mathematical function in my own script because it's written as an indicator. So, how can I use an indicator to just do mathematical operations to calculate numerical values and return numbers in my own script to be stored in a variable name and further processed? This seems to be overly complicated to accomplish in C#. Isn't there a suite/library of mathematical, statistical functions and probability distributions to use for calculations? It should be very simple as it is in Mathematica or R or even ThinkScript. What about other time series processing such as calculating 1st differences or higher order, etc. ?

    Thank you for your guidance!

    #2
    Hello Dr Kerry,

    Thank you for your post and welcome to the NinjaTrader forums!

    The following post contains many helpful tips and resources related to using NinjaScript and C#:


    C# has its own Math class that you may want to look into using, depending on your scripting needs. The following publicly available link will take you to the Microsoft documentation regarding the Math class:
    Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.


    The SUM indicator that you have mentioned returns the sum of values over a specified period. The following page in our help guide has more information, including a code example of how you could use it inside of your own script:


    Here is the help guide page for Standard Deviation:


    The following reference sample demonstrates how to use a custom series to store calculations, and it may also be useful in your case:


    Please review these resources and feel free to reach out with any additional questions or concerns.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X