Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can a method return a DataSeries Object?

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

    Can a method return a DataSeries Object?

    Can a method return a DataSeries Object?

    Such as if

    return dataseriesobj1-dataseriesobj2;

    I am guessing the answer is no, would help a lot if there was a way....as i need to run EMA calcs on the difference and i use it a number of places in my code. I can duplicate the code out of a method if necessary.

    #2
    Believe you would not need to create a DataSeries method to achieve this. DataSeries objects are tied to the bars. If you have math you wanted tied to the bars, just create a regular DataSeries object, .Set() the math to it, and then you will be able to access this value from your code multiple times just by calling the DataSeries with whichever index you wanted.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Simpler and probably more flexible and powerful would be to create a new DataSeries and populate it with the difference. Then calculate off the new DataSeries.

      #region Variables

      Code:
      private DataSeries _dsDiff = null;
      In Initialize() method

      Code:
      this._dsDiff    = new DataSeries(this);
      In OnBarUpdate() method

      Code:
      this._dsDiff.Set(dataseries1[0]-dataseries2[0]);

      Comment


        #4
        Thanks, i just left my last calculation outside the method so i was able to set a dataseries object minus my double variable and still be left with a dataseries object. Works fine, lots of ways to do the same thing in c# and i am sure its prob not the best but i am figuring it out.

        Combining unmanaged orders, multiple time frames, intrabar backtesting and custom indicators on my first ninja programming task is proving to be interesting.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        650 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        577 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X