Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongLimit() and EnterShortLimit place no orders

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

    EnterLongLimit() and EnterShortLimit place no orders

    Hi all,

    I just tested this sample script:

    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Close[0] < Open[0])
    {
    EnterLongLimit(GetCurrentBid());
    }

    // Condition set 2
    if (Close[0] > Open[0])
    {
    EnterShortLimit(GetCurrentAsk());
    }
    }

    NinjaTrader places no limit orders. If I use EnterLong() or EnterShort instead this sample script works. I used a ZenFire connection and the Sim101 account to test it. Why are no limit orders placed?

    There is no error in the log window and there are also buy and sell signals printed on the chart. Any ideas? Thank you!

    #2
    Hello amusche,
    Welcome to the forum and I am happy to assist you.

    In the Control Center strategies tab, what is the color of the strategy? If it is yellow then the strategy is waiting until it reaches a flat position http://www.ninjatrader.com/support/h...egies_tab2.htm

    To submit the order unlock the strategy (if you are coding via the strategy wizard), and put this code below the OnBarUpdate
    Code:
    protected override void OnBarUpdate()
    {
       [B] if (Historical) return;[/B]
        // rest of the code goes below.
    Also since you have set CalculateOnBarClose = true, the orders will be placed only on the end of the bar.

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hi
      thank you for your quick answer. That was a good hint. It works now.

      Comment


        #4
        Hello amusche,
        Glad to know the strategy is working fine.

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Yes, you can actually. I have some questions concerning the order filling simulation algo used for account Sim101.

          How are limit orders assumed to be filled?

          Only if there is a tick above the limit (for sell) or below the limit price (for buy)?

          What is the impact of adjusting the delay properties (in the Simulator Tab under Options)? I am using a Zen-Fire datafeed on a colocated machine (equinix data center Chicago) to trade the mini S&P 500 future. I have about 1-2 msec delay to the order routing gateway. What is a reasonable value for Delay exchange?

          To what degree to you think a series of simulated limit orders is realistic or archeivable in real trading?

          That's a lot of questions but the answers would be very helpful for my further development projects. Thank you.

          Comment


            #6
            Hello amusche,
            In Sim, an buy limit order gets filled when the bid price goes below the buy limit price and in case of a sell limit order gets filled when the ask price goes above the sell limit price.
            The simulated orders try to replicate a real time environment. The delay is built in to simulate the lag/latency which we witness in RT while submitting orders.

            Please refer to the help files for detals:
            Delay comm. (msec)* - Simulated delay of sending an order from your PC to a virtual exchange server
            Delay exchange (msec)* - Simulated delay of a virtual exchange server processing an order


            Its difficult to say on our part to comment anything on the lag part.

            In Sim a buy order will get filled only when the bid price goes below buy limit price. In live trading you can get filled/part filled in bid price only. If your strategy is a low latency buy bid/sell ask type then it is difficult to replicate.

            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Joydeep View Post
              In Sim, an buy limit order gets filled when the bid price goes below the buy limit price ...
              I' m bit worried by the statement above.
              If it was true then it looks like SIM would give unrealistically favorable buy prices for EnterLongLimit or equivalent.
              Example: If the Ask was a long way above Bid (and above limit price) but Bid has gone below limit then the statement implies the buy limit order is 'filled' by SIM (presumably at Bid).

              The simulated orders try to replicate a real time environment.
              But on a real exchange surely no buy will be triggered until the Ask comes down to the buy limit (or below).
              So who is correct?

              Comment


                #8
                Hi,

                Re-reading this response, I think there may be some confusion due to the language barrier, please allow me to clarify:
                • A buy limit order will only be filled at the ask price, and will be filled if the best offer is below or at the limit price.
                • A sell limit order will only be filled at the bid price, and will be filled if the best bid is above or at the limit price.


                If you're dealing with instruments with a large bid ask spread, a buy limit order will always and only be filled once the ask price comes down to that order.

                If you take forex for example, you can absolutely see a buy limit order above the bid price, that is waiting until the ask comes down to fill.
                MatthewNinjaTrader Product Management

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by FAQtrader, Yesterday, 10:05 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by NM_eFe, Today, 06:14 AM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by EB Worx, 03-07-2023, 05:05 AM
                5 responses
                104 views
                1 like
                Last Post NinjaTrader_BrandonH  
                Started by PaulMohn, Today, 02:06 AM
                2 responses
                11 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by burtoninlondon, 04-28-2024, 12:38 AM
                2 responses
                22 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X