Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

AddDataSeries - "Instrument Name" issue

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

    AddDataSeries - "Instrument Name" issue

    Hi everyone,
    I'm developing an indicator that needs an aditional Data Series, so, the code would be like:

    .....
    else if (State == State.Configure)
    {​
    AddDataSeries(string instrumentName, Data.BarsPeriodType.Tick, 1597);
    }
    ......

    The question is.... what should I write in the code for "string instrumentName"?
    I just want to add the data series for the same instrument where the indicator will be working.
    For example, one time will be "ES 09-22", but later on, it will be "ES 12-22".
    Or, could also be "NQ 09-22".

    I thought about setting a variable which the user can change in the indicator properties, but another issue comes...
    This indicator have to read historical data, which means that not only is necessary the data for the contract 09-22, but also 12-22, or even more (06-..., 03-..., etc.)
    In other words, the indicator have to have available all data that is loaded in the chart, which could be two years.

    Should I in that case add more than one data series like this?
    ...
    else if (State == State.Configure)
    {​
    AddDataSeries("ES 09-22", Data.BarsPeriodType.Tick, 1597);
    AddDataSeries("ES 12-22​", Data.BarsPeriodType.Tick, 1597);​
    .....
    }​
    ...

    Or is there another way to do so?


    The best result was setting blank the Data Series instrumentName, but in this case, the indicator throws an error on calling "Update" method at the bar where the contracts 09-22 and 12-22 overlaps.
    If the data loaded in the chart owns just to one contract, for example 09-22, everything works fine.
    ...
    else if (State == State.Configure)
    {​
    AddDataSeries("", Data.BarsPeriodType.Tick, 1597);
    }​
    ...​

    Thanks in advance for your support.

    #2
    Hello germanf,

    From the help guide:
    "Tips:
    4. For the instrument name parameter null could be passed in, resulting in the primary data series instrument being used."
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by alifarahani, Today, 09:40 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by RookieTrader, Today, 09:37 AM
    4 responses
    17 views
    0 likes
    Last Post RookieTrader  
    Started by PaulMohn, Today, 12:36 PM
    0 responses
    5 views
    0 likes
    Last Post PaulMohn  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    40 views
    0 likes
    Last Post love2code2trade  
    Started by junkone, Today, 11:37 AM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X