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 CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    52 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    29 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    194 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    355 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    274 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X