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

Understanding Order Flow

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

    Understanding Order Flow

    Is there a link which explains how NT goes about entering/cancelling orders that a strategy generates?

    I am really wanting to understand the flow and timing of how this works, including when each method, OnBarClose and OnEachTick is used.

    #2
    Hello Trader_Mark,

    Thank you for your note.

    I have provided a link on OnOrderUpdate as well as order methods,




    If you have any specific questions please let us know.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the links. Again, I am trying to understand the order that NT does everything once a strategy says conditions are currently true for placing an order.

      If my strategy is set to Calculate.OnEachTick, does my description in the picture accurately show what is happening? If so, why do I never see an entry order attempted until the next bar actually opens even if the conditions for an entry are true on the current bar? Can/should the order be placed before the bar closes and thus is there waiting when the next bar does open?
      Attached Files

      Comment


        #4
        Hello Trader_Mark,

        Historical orders when a strategy enabled are going to appear exactly as if Calculate was set to OnBarClose.

        When using backtesting the strategy will run exactly the same as if CalculateOnBarClose is set to true. This is true whenever the strategy runs on historical type data. The reason for this is because the only info known historically is the Bar open, High, Low and close and not all of the ticks that make up the bar. You can also get extremely misleading results if you are using a bar that changes shape such as renko bar type as the finished bar does not show the true range of price movement.

        Please see Discrepancies: Real-Time vs Backtest section of our helpguide.


        Adding a secondary data series of a smaller time duration would allow your strategy to enter/exit intra bar and give you results closer to market replay.

        Please see Backtesting NinjaScript Strategies with an intrabar granularity for a reference example on how you’d set this up.
        You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          I never said anything about backtesting. I am running the strategy live. With Calculate.OnEachTick set, should the order(s) be placed even before the current bar closes?

          Comment


            #6
            Hello Trader_Mark,

            When running the strategy on live data, with calculate on each tick set to true, should your conditions become true, an order would be sent on the current bar.

            Please see the following section of our helpguide,


            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_AlanP View Post
              When running the strategy on live data, with calculate on each tick set to true, should your conditions become true, an order would be sent on the current bar.
              Alan,

              Yes, but what happens is the order gets cancelled as soon as the current bar closes - so no chance to get filled.

              Remember, the order is placed on the current bar, I am wanting it to get filled or cancelled on the next bar.

              To recap, it is a range bar chart, bars will be 1 point in range. The strategy places an order 1 tick above/below the bars maximum size, so it can't be filled on the current bar by design. I want the buy or sell stop order sitting there waiting when the next bar opens.

              Comment


                #8
                Hello Trader_Mark,

                If you'd like a order placed 1 tick above or below the current bars high/low, then you should run the strategy with Calculate set to OnBarClose, and have your strategy logic refer to the previous bar.

                Please let us know if you need further assistance.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_AlanP View Post
                  Hello Trader_Mark,

                  If you'd like a order placed 1 tick above or below the current bars high/low, then you should run the strategy with Calculate set to OnBarClose, and have your strategy logic refer to the previous bar.

                  Please let us know if you need further assistance.
                  Is that the only way because that creates other issues, like rejected orders due to price moving past the stop order price before the stop order gets submitted (hence why I want it placed prior to the new bar)?

                  Comment


                    #10
                    Hello Trader_Mark,

                    There may be other ways, you could use EnterLongStopMarket, using the syntax,
                    EnterLongStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName)


                    Then run the strategy with calculate on each tick, have the order submitted on the current bar, but prevent the order from being modified on the next bar, which would achieve what you're looking to do as well.

                    Or under the other approach, you could write logic to not submit the order if the stop price was not valid, thus preventing rejected orders.

                    Please let us know if you need further assistance.
                    Alan P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by devatechnologies, 04-14-2024, 02:58 PM
                    3 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by tkaboris, Today, 08:01 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post tkaboris  
                    Started by BarzTrading, Today, 07:25 AM
                    1 response
                    11 views
                    1 like
                    Last Post NinjaTrader_Clayton  
                    Started by EB Worx, 04-04-2023, 02:34 AM
                    7 responses
                    161 views
                    0 likes
                    Last Post VFI26
                    by VFI26
                     
                    Started by Mizzouman1, Today, 07:35 AM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X