Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Price vs Bar Price

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

    Market Price vs Bar Price

    NT,

    I am trying to set up a fully mechanical system in strategy builder.

    I am using the "calculate on bar close" feature.

    My buy and sell signals are determined from the bars on the chart.

    I need to be able to do position reversals throughout the trading day.


    Here's my problem.

    I am using a custom bar chart to run my strategy.

    The first tick of bar price on this chart does not always equal the current market price.

    Your strategy builder acts like first tick of bar price equals current market price.

    Your strategy builder wants to use bar price data to place first tick of bar orders.

    I need to place market orders on first tick of bar.



    Can you help???

    RJay
    Last edited by RJay; 04-01-2009, 06:42 PM.
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    #2
    RJay,

    Not sure I follow. If you are using CalculateOnBarClose = true you are not doing anything on the first tick of a bar. You are calculating on the closing of the last bar which happens to coincide with the first tick of the new bar. As you submit a market order that first tick is likely already gone, especially in a fast moving market. Since you are submitting market orders there are no prices associated with the market order. Market orders fill you whenever possible independent of any designated price.

    Not sure I follow you on multiple order executions either. NinjaTrader will only make trades told to by the code. If your code tells it to EnterLong() multiple times then it will try. If you have one very large EnterLong() order for sure there is potential you get multiple partial fills (executions) to fill that one order. There is nothing NinjaTrader can do about such a scenario since that is just market dynamics.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      My orders are being filled at the first tick of new bar price, not the close of currentbar price.

      Also, is "firsttickofbar" a time tick or a price tick?
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        rt6176,

        For sure when you submit at the close of a bar you will get filled around the open of the new bar. The closing event of a bar is the same event as the opening of a new bar (aka first tick of a bar). There is no difference between a time tick or a price tick. A tick is a tick. It comes in whenever your data provider sends that information. Hope that helps.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I would be thrilled if I could place orders off of Close[1]. It doesn't work.

          I've tried but Strategy Builder keeps using firsttickof bar.

          I need to be able to place market orders in either direction in my strategy.

          Your platform doesn't seem to allow this scenario. How can I make this happen?

          Thanks,

          RJay
          Last edited by RJay; 04-01-2009, 01:52 PM.
          RJay
          NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

          Comment


            #6
            RJay,

            Not sure I follow. For sure Close[1] and Open[0] are not the same and for sure you cannot place orders to Close[1]. That bar is already closed. There is absolutely no tradeable opportunity on a closed bar. Everything you do is in relation to the current market environment which may even already be ahead of Open[0] as your computer calculates if it should place an order or not, as your order traverses the internet, as your brokerage routes the order to the exchange, and finally as the exchange fills you. This is the reality of electronic trading. You will most certainly have slippage especially in a fast moving market as these things occur.

            FirstTickOfBar is the event of you starting to build a new bar. As you build a new bar there is no way you can place a market order to fill at the close price of the previous bar. A market order does not care what price you submit at. It will fill however the market sees fit. This is not controlled by NinjaTrader in any which way. This is simply the definition of a market order.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              rt6176,

              If you have CalculateOnBarClose = true and you find a trade signal on your signal bar, the order is already placed on the first tick of the next bar. A market order never guarantees you fill at any price. Slippage is the name of the game when you use market orders. Not sure I follow what you want. You already are doing the order on the first tick of the bar. Please outline exactly what you want to happen in the sequence you want it to happen.

              In your code example for sure you will get an order cancelled. If you do not resubmit them they will expire and thus cancel. Still not following you on your comment about two orders. If you are referring to a "Close position" order this is expected behavior. If you hold a long position and try to go EnterShort() it will first close your long position and then get you a short position. Vice versa as well. If you only want to close the long position don't call EnterShort() then and just call ExitLong().
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                I have spent the last couple of days researching market orders for automated trading.

                I have two observations:

                1. I could not find a single posted working strategy that uses market orders.

                2. There sure are a lot of postings for assistance from forum users unable to get their market order strategies to work properly.

                If there is anyone out there who can post the code for the market order entry part of their strategy so I and others here can study and learn from it, that would be appreciated.

                Thanks,

                RJay
                RJay
                NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                Comment


                  #9
                  RJay,

                  1. People use whichever order type they are comfortable with. I would imagine post people don't like the slippage involved with market orders and as such always submit limit orders which are guaranteed to fill at a certain price.

                  2. I would have to respectfully disagree with this. Many users do use market orders and do use it successfully. When you submit a market order you have to be fully prepared to be filled at any price. Whatever the market conditions happen to be is where you will be filled.

                  You already are placing a market order at the first tick of the bar. Placing it at the first tick of a bar does NOT guarantee you fill at any price. You could fill at the previous bar's close price, the current bar's open price, or even a much worse price.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    NT,

                    I changed my order entry to the following code.

                    when I load it to the chart, it shows all the historical trades on the chart correctly.

                    However, it will not execute any trades in real time.

                    There are no errors in the log.

                    What am I doing wrong???


                    // Condition set 1
                    if (Close[0] > Close[1])
                    {
                    EnterShortLimit(DefaultQuantity, GetCurrentBid(),
                    "");
                    }
                    // Condition set 2
                    if (Close[0] < Close[1])
                    {
                    EnterLongLimit(DefaultQuantity, GetCurrentAsk(),
                    "");

                    Thanks,

                    RJay
                    RJay
                    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                    Comment


                      #11
                      RJay,

                      Add print functions inside your if-statements to see if they are evaluated to true. Then use TraceOrders = true in Initialize() to know if your orders are ignored for any reason.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        I set "calculate on bar close" to true and it started processing orders.

                        Thanks,

                        Rjay
                        RJay
                        NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by kevinenergy, 02-17-2023, 12:42 PM
                        118 responses
                        2,778 views
                        1 like
                        Last Post kevinenergy  
                        Started by briansaul, Today, 05:31 AM
                        0 responses
                        9 views
                        0 likes
                        Last Post briansaul  
                        Started by traderqz, Yesterday, 12:06 AM
                        11 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by PaulMohn, Today, 03:49 AM
                        0 responses
                        8 views
                        0 likes
                        Last Post PaulMohn  
                        Started by inanazsocial, Today, 01:15 AM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Jason  
                        Working...
                        X