Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy being disabled automatically

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

    strategy being disabled automatically

    HI,

    I want to separate strategies for entering the market from the one that manages positions created by the former. So I write below as a test for the position manager. Initially it runs well, correctly printing my position and quantity manually entered. However somehow it's disabled automatically after a few minutes. Why is that?

    Regards,
    Steven



    protected override void OnBarUpdate()
    {

    Print("PositionMgmt: Position: " + PositionAccount.MarketPosition.ToString() + " Total Quantity: " + PositionAccount.Quantity.ToString());

    Print("PositionMgmt: Instrumebt: " + PositionAccount.Instrument.MasterInstrument.Name);

    Print("PositionMgmt: Averate Price: " + PositionAccount.AveragePrice.ToString());

    //ExitLong(1);//Add your custom strategy logic here.

    }

    #2
    Traditionally NinjaTrader strategies are completely isolated from one another and cannot see or influence one another's orders. This is by design - so that, for instance, two strategies can be displayed on the same chart yet have separate performance reports. This is in contrast to, for instance, TradeStation, where strategies on a chart make up PARTS of the overall strategy, and there is always exactly one overall strategy per chart; ergo, one performance report.

    One of your strategies would become disabled when its expected position becomes out of sync with the account's position, if two strategies on the same account and instrument are enabled for live trading. This is true whether they are on the same chart or not. There are properties you can set on the strategy to tell it to keep going and ignore this, but that would not achieve your objective in that they would not see each others' orders.

    You would need to access the Account object directly to obtain and manipulate the other strategy's orders - this only works live not in back-testing - and understand that doing things this way is in violation of the NinjaTrader's general design and means that any performance reports would be incomplete. You would basically be writing it more like an add-on than like a strategy.
    Last edited by QuantKey_Bruce; 11-24-2023, 07:11 AM.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Originally posted by i019945nj View Post
      HI,

      I want to separate strategies for entering the market from the one that manages positions created by the former. So I write below as a test for the position manager. Initially it runs well, correctly printing my position and quantity manually entered. However somehow it's disabled automatically after a few minutes. Why is that?

      Regards,
      Steven



      protected override void OnBarUpdate()
      {

      Print("PositionMgmt: Position: " + PositionAccount.MarketPosition.ToString() + " Total Quantity: " + PositionAccount.Quantity.ToString());

      Print("PositionMgmt: Instrumebt: " + PositionAccount.Instrument.MasterInstrument.Name);

      Print("PositionMgmt: Averate Price: " + PositionAccount.AveragePrice.ToString());

      //ExitLong(1);//Add your custom strategy logic here.

      }
      Hello i019945nj,

      Thank you for your post.

      To understand why the strategy is becoming disabled, you may check the Log tab of the Control Center for any relevant messages regarding the disable. You could also enable TraceOrders in State.SetDefaults and check the output sent to the NinjaScript Output tab for additional details regarding the strategy's behavior when it comes to orders being submitted, canceled, ignored, updated, etc:Although PositionAccount allows the strategy to get information about the live account position, the Exit() methods such as ExitLong() would only be able to exit a position that was opened by the same strategy and not positions that were opened manually. This is noted in the help guide - see the Tips on the ExitLong() page for example:You may be able to work around some of the limitations and the order handling rules in place for the Managed Approach (listed on this page) by using the Unmanaged Approach instead:


      Otherwise, you could consider using more of an Add-On type of approach and access the Account class. There are methods that you can subscribe to for order, position, and execution updates and you may create orders with CreateOrder() then submit them with Submit():These options are considered more advanced and would require keeping track of Order objects.

      Please let us know if we may be of further assistance.

      Comment


        #4
        Hi Bruce and Emily,

        Pretty much fine information which will keep me busy for a while. Happy Thanksgiving.

        Regards,
        Steven

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        46 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        66 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 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