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

Order and IOrder object

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

    Order and IOrder object

    Hi, please help me
    I have defined:

    private Order tempOrd = null
    private IOrder myOrd = null

    then in the script (when the tempOrd is not "null"), I would like to copy the content of tempOrd to myOrd:

    myOrd = (IOrder)tempOrd

    I hope it will make the conversion from Order object to IOrder object, but I got an error message:
    Unable to cast object of type 'NinjaTrader.Cbi.Order' to type 'NinjaTrader.Cbi.IOrder'.

    What does it mean exactly, and how can I resolve this problem?

    Thank you for advance

    Akos

    #2
    Hello akkiss,
    Thanks for posting today.

    IOrder object is an interface and Order object is not supported or documented. The IOrder object is how you use NinjaScript to get information from an Order object. It is a read only interface. The code you are using is unsupported since Order is not support or documented.

    Your best solution would be to use the IOrder object to access information needed from an Order object.

    Here is the documentation for the IOrder object. http://www.ninjatrader.com/support/h...tml?iorder.htm

    Are you trying to track the order or duplicate?

    If you are trying to duplicate the Order object casting to the IOrder would not do this. You would have to use an order entry method such as EnterLong() or SubmitOrder() using the managed or unmanaged approach respectively. These methods will return an IOrder object that you then can use to track your orders.

    Please let us know if we may be of further assistance for anything NinjaTrader.
    Alex G.NinjaTrader Customer Service

    Comment


      #3
      Hi Alex
      I see, the keyword: the IOrder object is a read-only interface, so I can't modify the content. My project is to write a script, wich will modify a running manual position. I want to use unmanaged approach, so to modify the stop loss, with the ChageOrder() methods. In this case I need the IOrder parameter. But the entry was manually, how the IOrder will be refreshed? (I have only one position everytime) The OneBarUpdate method will update the IOrder?

      Comment


        #4
        Hello akkiss,
        Thanks for the reply.

        The IOrder iOrder parameter from the method
        Code:
        ChangeOrder(IOrder iOrder, int quantity, double limitPrice, double stopPrice)
        is an IOrder object. You pass in the IOrder object you wish to make changes to that for that particular order. Remember the IOrder object is an interface that accesses parameters from an Order but does not change the Order it self. This is why the ChangeOrder() method is needed to make changes to an order.

        The IOrder object will not update when the OnBarUpdate method, it is simply an interface accessing Order information for a particular Order.

        You will not be able to access a manually placed order IOrder object(an order placed outside of a strategy). You can however adapt this code to receive the information from a position filled by a manually placed order. However, this tidbit of code is not officially supported.
        Code:
        foreach (Account acct in Cbi.Globals.Accounts)
        {
        if (acct.Positions != null)
        {
        PositionCollection positions = acct.Positions;
        foreach (Position pos in positions)
        {
        Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
        }
        }
        Please let me know if this clarifies the issue for you.
        Alex G.NinjaTrader Customer Service

        Comment


          #5
          HI AlexG
          Thank you for your answer. Now I run your script, so I have lot of information about the manually placed order. But how can I use this data at the ChangeOrder() method? But to change the order I have to use (f. ex.) the ChangeOrder() method. The first parameter of it is the iOrder. You wrote, we can't access the iOrder object of a manually order. So my question is: what can we put on the place of iOrder, or what can we do to use the commands of unmanaged approach?
          Could you help me?

          Comment


            #6
            Hello akkiss,
            Thanks for the reply.

            To use the ChangeOrder() method you would need an IOrder object which is not created or accessible for manually placed trades.

            The code given in the last post will simply give you information about a manually traded order than then can be used to make decisions on when to place another order using a managed or unmanaged approach.

            Manually placed orders are not changeable using supported NinjaScript code.

            If you wish to be able to make a change to order is has to be entered from within the strategy script using an ATM strategy, a managed approach order entry or an unmanaged approach order entry.
            Alex G.NinjaTrader Customer Service

            Comment


              #7
              Hi AlexG
              Thank you for your answer. It is clear, that the ninja not supports this "half-auto" programming mode. But may be, there are lot of nonja-fan, who would like this mode. The Ninja is based on C# one of the most flexible program language. What is the reason, that there is no developing in this direction?

              regards Akos

              Comment


                #8
                Hello Akos,

                Thanks for your reply.

                As has been discussed you cannot detect manual orders with a script. We will add a feature request to the development team to consider this.
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by GwFutures1988, Today, 02:48 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                6 responses
                32 views
                0 likes
                Last Post ScottWalsh  
                Started by frankthearm, Today, 09:08 AM
                10 responses
                36 views
                0 likes
                Last Post frankthearm  
                Started by mmenigma, Today, 02:22 PM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by NRITV, Today, 01:15 PM
                2 responses
                10 views
                0 likes
                Last Post NRITV
                by NRITV
                 
                Working...
                X