Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 junkone, Today, 11:37 AM
    2 responses
    12 views
    0 likes
    Last Post junkone
    by junkone
     
    Started by frankthearm, Yesterday, 09:08 AM
    12 responses
    43 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by quantismo, 04-17-2024, 05:13 PM
    5 responses
    35 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by proptrade13, Today, 11:06 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    35 views
    0 likes
    Last Post love2code2trade  
    Working...
    X