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

ChangeOrder

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

    ChangeOrder

    I'm using e.g. EnterLongStopLimit(1, true, 1, 3951.5, 3951.5, "LSL") to get an entry at a particular price.

    if marketposition is flat and order.Filled = 0 then I may use ChangeOrder to lower the price.

    in real-time (but not historically) I sometimes get this in my log: "Stop price can't be changed below the market"

    any ideas what I may be doing wrong?

    #2
    Hi, thanks for posting. The price you are using is below the Bid price at the time you change the order. Make sure to compare the changed price to the GetCurrentBid() value to make sure you are not changing the order below the market.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      ok thanks.

      I'm trying to make sure I only change the price of an order that hasn't yet been executed (Filled = 0). So I can wait for that price to arrive (or not). Would that make a difference?

      I also use GetRealtimeOrder if state changes to realtime.

      Comment


        #4
        can we leave this for now, what I thought was a flat market may not be and I could be trying to change an order that has been executed.

        Comment


          #5
          I think were I'm going wrong is knowing what state an order "myOrder" is in after it has been created

          e.g. (A) null, (B) created and waiting to be filled (in this state I can change the limit price), (C) filled (now I don't want to change the limit price) and then (D) closed by a profit target or stoploss and then (E) back to null.

          I know this is a lot to ask but any tips or advice appreciated..
          Last edited by dibDab; 11-21-2022, 11:09 AM.

          Comment


            #6
            Hi, thanks for the follow up. You can keep track of an order's state by using the OnOrderUpdate event method. The order must be in Working state to be changed, After Filled state is too late. We have an example of advanced order handling techniques here on this page for reference:



            Kind regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              thanks again

              can I clarify ...

              if (myLongOrder != null && myLongOrder.OrderState == OrderState.Working) then Stop price can't be changed below the GetCurrentBid()

              if (myShortOrder != null && myShortOrder.OrderState == OrderState.Working) then Stop price can't be changed above the GetCurrentAsk()

              Comment


                #8
                Hi, that looks correct to me.
                Chris L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by llanqui, Today, 03:53 AM
                0 responses
                4 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by burtoninlondon, Today, 12:38 AM
                0 responses
                10 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                14 views
                0 likes
                Last Post AaronKoRn  
                Started by carnitron, Yesterday, 08:42 PM
                0 responses
                11 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Yesterday, 07:51 PM
                0 responses
                14 views
                0 likes
                Last Post strategist007  
                Working...
                X