Announcement

Collapse
No announcement yet.

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

    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

            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.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by CarlTrading, 03-31-2026, 09:41 PM
                1 response
                79 views
                1 like
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 04-01-2026, 02:41 AM
                0 responses
                40 views
                0 likes
                Last Post CarlTrading  
                Started by CaptainJack, 03-31-2026, 11:44 PM
                0 responses
                63 views
                2 likes
                Last Post CaptainJack  
                Started by CarlTrading, 03-30-2026, 11:51 AM
                0 responses
                63 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 03-30-2026, 11:48 AM
                0 responses
                54 views
                0 likes
                Last Post CarlTrading  
                Working...
                X