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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      66 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      141 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      76 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      47 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      51 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X