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 NullPointStrategies, Today, 05:17 AM
    0 responses
    24 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    120 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X