Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using DataSeries as input to a function

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

    Using DataSeries as input to a function

    I extracted this calc of Standard Deviation from iVWAP. The 1st parameter is an array. I have tried to change it to IDataSeries to pass it a DataSeries instead but my indicator comes up blank. Is there a way to pass it a DataSeries rather than have to copy the data to an array first? (I changed the .Count to CurrentBar-1 in my test)

    Code:
     private double StandardDeviation(ArrayList array, double avg)                
            {
                int x = 0;
                double sd = 0;
                while (x < array.Count)
                {
                    sd += (((double)array[x] - avg) * ((double)array[x] - avg));
                    x++;
                }
                if (sd > 0)
                    sd = System.Math.Sqrt(sd / (array.Count));
                return sd;
            }

    #2
    Hello,

    Thanks for your forum post.

    This is how SMA method does it, cant think of any reason it shouldn't work for you.

    public SMA SMA(Data.IDataSeries input, int period)
    {

    }

    Let me know if I can be of further assistance.

    BrettNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Brett View Post
      Hello,

      Thanks for your forum post.

      This is how SMA method does it, cant think of any reason it shouldn't work for you.

      public SMA SMA(Data.IDataSeries input, int period)
      {

      }

      Let me know if I can be of further assistance.


      It doesn't work. I just went back to using an array.

      Comment


        #4
        Hello,

        I discussed this with Bertrand and looks like you need to create a separate indicator to house this. As they all provide iDataSeries interface by default. This needs to be whithen the confines of a separate indicator to allow you to do this. So you would have an indicator that just operates as a function/method if you wanted to further persue this.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        26 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        182 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        335 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        260 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X