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

Managed vs Unmanaged

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

    Managed vs Unmanaged

    I am using an unmanaged Strategy to handle special situation while other Strategies are managed. So I have both managed and unmanaged Strategies defined, of course I won't use them at the same time. For this special unmanaged strategy, I have to declare this:

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    IsUnmanaged = true;
    }
    }


    The problem is, OnStateChange() can be called for all Strategies either managed or unmanged, in other words, IsUnmanaged can be set to either "true" or "false". How do I resolve it? Thanks.

    #2
    Hello localappleseed,

    The OnStateChange override is defined in every strategy so each one will have its own individual SetDefaults state. In this example, this specific strategy would be unmanaged. All other strategies which don't have IsUnmanaged = true; defined in their code won't be managed by default.

    When you set variables like this it will have no effect on other strategies, this is being set only for that one strategy.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I got the following errors even I declared IsUnamanged = true. I am not sure why it is still in managed?
      Error on calling 'OnBarUpdate' method on bar 0: Strategy 'LLL2/212851947': 'SubmitOrderUnmanaged' method can't be called on managed strategies.

      protected override void OnBarUpdate()
      {
      ...
      myExit = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, 100, GetCurrentAsk()+0.1, 0, "", "Buying 100");
      ...
      }

      Comment


        #4
        Hello localappleseed,

        If you just made that change but didn't remove/re apply the strategy you would see that error. Any changes to your strategies SetDefaults or its Class structure like user inputs would require re applying it.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Yes, per your guideline, it worked! But it looks like I have to remove, shutdown and re-start Strategy to make it work. Removing and reapply Strategy was not enough.
          Thanks a lot.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mizzouman1, Today, 07:35 AM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by RubenCazorla, Today, 09:07 AM
          2 responses
          13 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by i019945nj, 12-14-2023, 06:41 AM
          7 responses
          82 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by timmbbo, 07-05-2023, 10:21 PM
          4 responses
          158 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by tkaboris, Today, 08:01 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X