• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing an existing order from an AddOn

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

    Changing an existing order from an AddOn

    Hello,

    I have used the AddOn Framework as a basis for my addon. I submit a bracket order with my stop loss and profit target like so:

    profitTarget = accountSelector.SelectedAccount.CreateOrder(e.Orde r.Instrument, thisOrderAction, OrderType.Limit, TimeInForce.Day, e.Order.QuantityChanged, localProfitTarget, localProfitTarget, oco, "LATA - Target", null);
    stopLoss = accountSelector.SelectedAccount.CreateOrder(e.Orde r.Instrument, thisOrderAction, OrderType.StopMarket, TimeInForce.Day, e.Order.QuantityChanged, localStopLoss, localStopLoss, oco, "LATA - Stop", null);
    accountSelector.SelectedAccount.Submit(new[] { profitTarget, stopLoss });

    Now I need to programmatically change the quantity and/or price of these orders but cannot figure out how it should be done. Is it even possible?

    Thank you,

    Libor
    Last edited by liborc; 06-05-2017, 02:51 PM.

    #2
    Hello liborc,

    This would be possible.

    You'll have to change the order objects price or size parameter, then pass the order object to the Change() call.

    A sample can be found at the following,
    http://ninjatrader.com/support/helpG...us/?change.htm

    Please let us know if this is unclear or you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      thank you very much for this info. I believe I discovered a bug in NT in this area.
      As I was looking for the solution, I tried changing the quantity of the order in the Orders collection. It is apparently supposed to be read only, but in fact it is read/write as it has a setter exposed. When I changed the quantity, it did not throw any error, only changed the order quantity in the order list in the Control Center. Naturally, the real order on the broker's server stayed unchanged.

      I hope this helps. Please let me know if you need more information or if I should log a bug report in a different fashion.

      Thank you again,

      Libor

      Comment


        #4
        Hello Libor,

        I'm trying to reproduce with no luck.

        I use the following code to submit an order to myInstrument which I have set to ES,

        Code:
        MyOrder = accountSelector.SelectedAccount.CreateOrder(myInstrument, buyOrSell, OrderType.Limit, TimeInForce.Day, 1,2450.00, 0, "", "EntryOrder", null);
        
        accountSelector.SelectedAccount.Submit(new[] {MyOrder});
        Then I use the following to amend the order, increasing it by a quantity of 2.

        Code:
        MyOrder.QuantityChanged= MyOrder.Quantity +2;
        
        accountSelector.SelectedAccount.Change(new[] { MyOrder });
        Is this similar to how your code looks? Would you be able to provide a sample or the logic you use to submit and amend the order?

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hi Alan,

          I have changed my code since I posted, but will try to see if I can reproduce and then update this thread with my findings.
          Overall, though, my code was along the lines of what you were using.

          Thank you,

          Libor



          Edit: I think actually I was doing something like:
          MyOrder = accountSelector.SelectedAccount.CreateOrder(myInst rument, buyOrSell, OrderType.Limit, TimeInForce.Day, 1,2450.00, 0, "", "EntryOrder", null);
          accountSelector.SelectedAccount.Submit(new[] {MyOrder});

          Subsequently modifying it like so (pseudocode):

          Order thisOrder = getReferenceToTheOriginal_MyOrder();
          thisOrder.Quantity = 33;



          I believe the Quantity property has a public setter.
          Last edited by liborc; 06-05-2017, 02:52 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by priceisking, Today, 12:51 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by chartish, Today, 10:33 AM
          3 responses
          19 views
          0 likes
          Last Post chartish  
          Started by casabella, Today, 11:51 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by Johnny, Today, 11:42 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_Jermaine  
          Started by habibalex, Today, 09:03 AM
          2 responses
          14 views
          0 likes
          Last Post sledge
          by sledge
           
          Working...
          X