Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding DataSeries on running strategy

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

    Adding DataSeries on running strategy

    Hi There

    I would like to add a dataSeries to a running strategy. So I want to force the code to go to OnSateChange to enable me to add the additional item.

    The problem is that you can not set the State to an earlier state. Is there any work around, ie can I stop and restart the script ?

    Thanks

    #2
    Thank you for your question GKonheiser. The only way to do this that I can think of would be to create a new instance of your Strategy during runtime. While your strategy will not be enabled or running normally, static members will be available, and a DispatcherTimer can be used to drive methods like OnBarUpdate with data series from the host script. I am including publicly available MSDN C# documentation for the DispatcherTimer method.

    A timer that is integrated into the Dispatcher queue which is processed at a specified interval of time and at a specified priority.


    Note that you can not set the sub-strategy's state directly. I recommend creating an external variable you can set, and setting up your sub-strategies conditional blocks like

    Code:
    [FONT=Courier New]
    public State ExternalState;
    protected override void OnStateChange()
    {
        if (State == State.Configure || ExternalState == State.Configure)
        {
            // ...
        }
    }[/FONT]
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    637 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    571 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X