Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is there a way to assign an ISeries<> to a secondary data series?

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

    Is there a way to assign an ISeries<> to a secondary data series?

    Is there a way to assign a secondary data series to an ISeries<>? I need to use an SMA and it will only accept an ISeries<>

    Currently my understanding is that I can only assign a secondary data series to Series<> as below:



    private Series<double> signal ;


    protected override void OnStateChange()
    {
    if (State == State.Configure)
    {
    AddDataSeries(SecondaryDataSeriesBarType, SecondaryDataSeriesPeriod);

    }
    else if (State == State.DataLoaded)
    {
    signal = new Series<double>(BarsArray[1], MaximumBarsLookBack.Infinite);
    }
    }


    The SMA function requires an ISeries.

    #2
    Hello kenconcannon,

    Thank you for your inquiry.

    Are you just looking to supply a secondary data series as an input to the SMA? You can just use BarsArray and supply that to the SMA directly.

    The Help Guide page below demonstrates supplying the added data series as an input to the SMA using BarsArray:



    Please let me know if you have any further questions.

    Comment


      #3
      Thx Gaby,

      I was trying to add this to the data loaded state but I would get an error because signal is a Series<> not an ISeries<>:

      signal = SMA(ROC(BarsArray[1], rocPeriod), maPeriod);

      If I change the signal to ISeries<> like below:


      private ISeries<double> signal ;

      protected override void OnStateChange()
      {
      if (State == State.Configure)
      {
      AddDataSeries(SecondaryDataSeriesBarType, SecondaryDataSeriesPeriod);

      }
      else if (State == State.DataLoaded)
      {
      signal = new ISeries<double>(BarsArray[1], MaximumBarsLookBack.Infinite); <<<----- this is not valid

      signal = SMA(ROC(BarsArray[1], rocPeriod), maPeriod);
      }
      }​


      then I cannot specify the specific bar array.


      I know I can get the values in the OnBarUpdate event and just assign to the signal Series<>. I was just wondering if I can specify in the OnStateChange event instead like I can if I am just using a primary data series

      Comment


        #4
        Hello,

        Can you please clarify what are you trying to achieve with this line?

        Code:
        signal = new ISeries<double>(BarsArray[1], MaximumBarsLookBack.Infinite);
        If you are trying to assign the SMA to "signal", signal needs to be of type SMA, not an ISeries<double>.

        Code:
        private SMA signal;
        
        .
        .
        .
        
        else if (State == State.DataLoaded)
        {
        signal = SMA(ROC(BarsArray[1], rocPeriod), maPeriod);
        }
        For a working example you can take a look at SampleMultiInstrument in the NinjaScript Editor.

        Please let us know if you have any further questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 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
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X