Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to update the data series of an indicator

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

    How to update the data series of an indicator

    Hello, the best way is to explain by an example.

    I have a strategy that uses an SMA as an indicator, taking the VX 11-19 data series.
    I update the data series to VX 12-19, however the indicator still uses the original VX 11-19 data series. so the results would be wrong...

    How can I update the indicator data series to VX 12-19 inside the code?

    Thanks!

    #2
    Hello 7robert,

    Thanks for your post.

    Please update the AddDataSeries call in OnStateChange under State.Configure to reference the new expiry. Please then recompile your script and after NinjaScripts are recompiled, please remove your strategy and re-add it to ensure State.Configure gets called again to add the new data series.

    Code:
            private SMA SMA1;
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Strategy here.";
                    Name                                        = "MyCustomStrategy12";
                }
                else if (State == State.Configure)
                {
                    AddDataSeries("VX 12-19");
                }
                else if (State == State.DataLoaded)
                {
                    SMA1 = SMA(Closes[1], 20);
                }
            }
    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    I look forward to being of further assistance.

    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
    132 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
    118 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