Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Parsing an array of DataSeries to an indicator Constructor

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

    Parsing an array of DataSeries to an indicator Constructor

    Hi,

    I am trying to import an indicator into a strategy.
    The indicator that uses a large number of DataSeries, let say 5 Data Series ie (EURUSD,EURJPY, ect..)

    I am currently adding every series in to the indicator paramaters like this.
    ( the constructor gets large, and would like to simplify it)

    Strategy
    Code:
            private FXMom301bProduction FXMom; // Declare FXMom here
    ​
    
    else if (State == State.DataLoaded)
    {
    
    AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 1); //BarsInProgress index = 1 | Closes[1][0]
    AddDataSeries("EURGBP", Data.BarsPeriodType.Minute, 1); //BarsInProgress index = 2 | Closes[2][0]
    AddDataSeries("EURCAD", Data.BarsPeriodType.Minute, 1); //BarsInProgress index = 3 | Closes[3][0]​
    
    FXMom = FXMom301bProduction(
    Closes[1], // EURUSD_Close
    Closes[2], // EURGBP_Close
    Closes[3], // EURCAD_Close​
    )
    }


    Indicator
    Code:
    public class FXMom301bProduction : Indicator
    {​
    
            [NinjaScriptProperty]
            [Display(Name = "EURUSD_Close", GroupName = "Show_Index", Order = 1, Description = "...")]
            public ISeries<double> EURUSD_Close
            { get; set; }
    
            [NinjaScriptProperty]
            [Display(Name = "EURGBP_Close", GroupName = "Show_Index", Order = 1, Description = "...")]
            public ISeries<double> EURGBP_Close
            { get; set; }
    
            [NinjaScriptProperty]
            [Display(Name = "EURCAD_Close", GroupName = "Show_Index", Order = 1, Description = "...")]
            public ISeries<double> EURCAD_Close
            { get; set; }
    ​
    
    protected override void OnBarUpdate()
    {
    var EURUSD = EURUSD_Close[0];
    var EURGBP = EURUSD_Close[0];
    var EURCAD = EURUSD_Close[0];
    }
    }

    I'd rather do this send the data to the indicator in an array or matrix.
    Can this be done efficiently?
    Whats the best method for achieving this?

    Strategy

    DataArray[1] = Closes[1][0]; // Store ISeries in a array. would i put this in the OnBarUpdate? or Dataloaded?
    DataArray[2] = Closes[2][0];
    DataArray[3] = Closes[3][0];

    FXMom = FXMom301bProduction(DataArray[]) //send an array of data series (Close) to the indicator

    Indicator
    [NinjaScriptProperty]
    [Display(Name = "Fx Data", GroupName = "Show_Index", Order = 1, Description = "...")]
    public ISeries<double>[] Fx_Data
    { get; set; }​


    protected override void OnBarUpdate()
    {
    var EURUSD_Close = Fx_Data[1];
    var EURGBP_Close = Fx_Data[2];
    var EURCAD_Close = Fx_Data[3];​


    What is the ideal method of getting data into the indicator?
    thanks.
    Last edited by yertle; 09-03-2024, 10:28 PM.

    #2
    Hello yertle,

    There is not a way to send the data to the indicator and have it process normally. When hosting an indicator that uses extra series both the indicator and strategy need to have the same AddDataSeries statements so both process on each of those series.

    Comment


      #3
      Ok thanks,
      ​​sounds good.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      128 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      117 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X