Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Managed vs Unmanaged

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

    Managed vs Unmanaged

    Is code snippet below workable? Do I have to manage the cancellation of unused orders myself or will Ninja for me as I use same fromEntrySignal for all of 'em

    Is this kind of code considered "Managed" or "Unmanaged" code in Ninja vocabulary?

    Code:
            protected override void OnBarUpdate()
            {
    longEntryOrder1 = EnterLongStopLimit(0, true, target1Quantity + target2Quantity + target3Quantity, BuyPrice + tradeSlippage, BuyPrice, longOrderName);
            } 
    
            protected override void OnOrderUpdate(IOrder order)
            {
                if (order.OrderState == OrderState.Filled)
                {
    longExitOrder1 = ExitLongLimit(0, true, target3Quantity, longTarget3Price, "Target 3", longOrderName);
    longExitOrder2 = ExitLongLimit(0, true, target2Quantity, longTarget2Price, "Target 2", longOrderName);
    longExitOrder3 = ExitLongLimit(0, true, target1Quantity, longTarget1Price, "Target 1", longOrderName);
    longExitOrder4 = ExitLongStop (0, true, target1Quantity + target2Quantity + target3Quantity,   longStopLossPrice, "Stop Loss", longOrderName);
                 }
              }
    I am aware of the SetProfitTarget and SetStopLoss methods but there are two reasons for doing it using this methods

    a) I am keen on understanding applicability of above methods in this manner.
    b) Both Stop loss and target are meant to keep shifting. Targets are shifted as newer bars provide greater clarity of probability. target3 is meant to remain moving for as long as price chases it. Stop loss is plain vanilla % based trailing stop loss but I would

    #2
    cdjindia, that would be all managed mode still, here's an overview more detailed over both approaches and their methods offered -



    The orders would be liveUntilCancelled and thus would not expire, but only be cleared by the end of session handling (normal DAY orders, used per default).

    If you want to scale out then you would need to scale in first with your entry in managed mode as well to be able to to tie the exit qtys together.

    Comment


      #3
      Bertrand

      Thanks

      I had seen the thread http://www.ninjatrader.com/support/f...ead.php?t=3751 but had seen help page locally only.

      In earlier strategies, I have used SetProfitTarget and SetTrailStop and they work as expected but here I cannot use SetTrailStop. Not sure about SetStopLoss on this one... but my understanding is that those methods are ideally suited for strategies with set-and-forget approach.

      I need a method in which I can specify SL in absolute price value and I need to do the trailing logic myself. Also, if I shift Stop loss 10 times, I do not want 10 pending stop orders lying around. Need to know with certainty whether I should cancel or will it be done for me within managed mode?.

      In the same vein, I will also be shifting targets and I want to work out logic (if and when) I should cancel 'em.

      Another thing that I am unable to find is left over quantity in position or order class.
      Last edited by cdjindia; 03-03-2014, 07:36 AM.

      Comment


        #4
        cdjindia, for the Set methods first of all you would lose the IOrder object access for them, unless you monitor for them in OnOrderUpdate and custom store the references which would be more work so using the exit methods would be easier in this respect as they directly provider the IOrder returns for working with. Second SetStopLoss and SetTrailStop could not be combined on the same position, generally for a custom trail we recommend working with SetStopLoss only and calling it again in OnBarUpdate() when you want to update the value of the stop. The same would be true for the exit methods, if you call them again with the same name > it would just update the order and not issue a new one. Cancelleation is something though you would need to manage, as they are not OCO'ed per default like the Sets.

        Comment


          #5
          Thank you Bertrand for all your help ... I am on to it ... This makes sense now.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          646 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          367 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          570 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X