• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by faisamtrader, Today, 10:31 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Tyler  
    Started by ChazJ, Today, 09:48 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by maxie, Today, 10:01 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Melissa  
    Started by Bionian, Today, 09:36 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by tomd, Today, 09:48 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Ariana  
    Working...
    X