Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

mean value

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

    mean value

    Hello,

    How can I get/calculate mean of a value
    (in NS)
    from the beginning of a day, when there is a new value per each bar.

    I was trying to find it but without success.

    Thank you
    emuns

    #2
    Hello emuns,

    When you say mean are you referring to the average of the open, high, low, and close of a bar such as a daily bar?

    Print(Open[0] + High[0] + Low[0] + Close[0] / 4);

    Similar to the Typical.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      I have an indicator which shows average liquidity in a market during every bar. So there is an integer per one bar. My goal is now to get average liquidity per "entire" session, which is from the time I have connected to data-feed till real time. So the question is how to programmatically count all the integers and divided it with number of items?

      I was also thinking about some MA, to be able to see how the average value was evolving in history, but MA is too volatile and it reflects rather situation in recent history depending on period settings... Or is there some better way how to get not too volatile results without necessity to set too high period value?

      Thank you,
      emuns

      Comment


        #4
        Hello emuns, thanks for your reply.

        You can use a for loop to iterate through the bars.

        e.g.:

        int sum = 0;
        for(int i = MaxLookBack-1; i >= 0, i--)
        {
        sum += MySeries[i];
        }

        double m = sum/MaxLookBack

        You can also check if the current bar is the first bar of the session with IsFirstBarOfSession.

        Best regards,

        -ChrisL



        Comment


          #5
          Hello Chris,

          thank you very much for your answer. But I suppose that I can´t use IsFirstBarOfSession because it is not possible to download
          historical
          level 2 data. So I need to start the calculation from the time, I connect to a data feed…?!

          Best,
          emuns

          Comment


            #6
            Hello emuns,

            If your calculations are being stored to a custom series, Bars.IsFirstBarOfSession would be true on the first bar of a session should you want to loop from the current bar to the first bar of the session in your custom series with stored custom calculated values.

            This is if there are values saved since the beginning of the session.

            It is correct level 2 data would not be provided historically. OnMarketDepth() will begin triggering in real-time data only.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X