Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A rookie question

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

    A rookie question

    Please,


    I'm trying to close a buy order sending inmediately a sell order to de current Bid offer with the following statement:

    ExitLongLimit(0, false, 1, GetCurrentBid(0), "Hout1", "Hin1")

    Why it doesn'ts fills the order inmediately, and it's waiting as an accepted order?

    With this one I've the same problem:

    EnterShortLimit(1, false, 1, GetCurrentBid(1), "Hin2");

    And this two work fine:
    EnterLongLimit(0, false, 1, GetCurrentAsk(0), "Hin1")
    ExitShortStop(1, false, 1, GetCurrentAsk(1), "Hout2", "Hin2")

    Thanks.

    #2
    Hello JoanNT,

    Thank you for your post.

    You can use the line TraceOrders = true; to the Initialize() method that will provide some helpful output on orders.


    If you want to be filled immediately you can consider selling at the ask instead of the bid.

    Have you considered having just the short entry? This will create the reversal behavior you're after. If the condition for short entry is true while you are in a long position then it will close your position and enter short.

    Also note that you're using the advanced overload for these methods. One of the parameters is the BarsInProgress index, which is used for multi-instrument strategies. In some places in your code this is a 0 for the first series and in other places it's a 1 for the second series. It might be better to work on one aspect of the strategy before adding the extra complexity of a multiseries strategy.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you RyanM,

      When you say:

      "If you want to be filled immediately you can consider selling at the ask instead of the bid." --> But when you send a sell market order the price filled is the price of the bid, or I'm wrong? that is what I need, but I must be sure this is the reason of sending to the bid price with the GetCurrentBid statement.

      "Have you considered having just the short entry?" --> Thanks, but I'm trying to buy/sell one spread of two different instruments, this is not the behavior I need now.

      "Also note that you're using the advanced overload for these methods" -->yes, I need to develop a strategy between two assets.

      Comment


        #4
        Hi Joan,

        Sell market orders can fill at any price. The price you typically pay is the bid, but there's no guarantee. You were submitting a sell limit order at the bid. This is likely to fill soon, but it will be behind other limit orders and market orders. If the market then ticks downward you risk not being filled at all. To evaluate what may have happend in your particular case you should use TraceOrders.

        You're welcome to try getting everything working at once. My suggestion to focus on one issue at a time is just for ease of development and learning. If order submission isn't working to your expectations then you may find it easier to work on that before adding extra complexity.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thank you very much. I'll focus in one operation only.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          67 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          36 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          59 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          62 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          53 views
          0 likes
          Last Post CarlTrading  
          Working...
          X