• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trade Markers Plotting on wrong bar

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

    Trade Markers Plotting on wrong bar

    I have a strategy that will go long or short at the open of the bar using a market order if certain conditions are met. Primarily, if the Open of the bar is above the SMA line it goes long at the open if below the SMA line it goes short at the open.

    The strategy seems to be working okay when trading tick data in MarketReplay and is opening the trades in and around the open price when a new bar is formed. Problem is that the Trade markers are plotting on the wrong bar.

    I have attached a screenshot to show you the problem. If a new trade is open at the open of the bar, should the blue sideways triangle and the up arrow not show up on the bar that the trade is opening at? But it doesn't, it is plotting both on the previous bar that just closed making it look like it went long at the open price of the correct bar but somewhere in the middle of the previous bar.

    If you visually move the markers one bar to the right it would be correct and you can see that the sideways triangle aligns with the open price and the up arrow indicates a trade on the correct bar.

    Any ideas why this is happening? In real time it doesn't plot the arrows until the trade is closed and then it plots it as shown. The close trade markers are showing up correctly, only the open trade markers are off.

    Any insight would be appreciated.
    Attached Files

    #2
    Hello wcmaria,

    Am I correct in understanding that the trades we are looking at here are historical trades and not ones taken live?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Well not exactly live as in a live account but live in the sense that they were taken using MarketReplay data on a 15 minutes timeframe. I downloaded tick data and ran the market tick by tick from 9 am to 4 pm.

      Comment


        #4
        wcmaria,

        Are you running the strategy with CalculateOnBarClose set to false or true?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          CalculateOnBarClose is set to false since my strategy exits or reverses trades mid bar if conditions are met.

          Comment


            #6
            wcmaria,

            With these settings, I'm not seeing anything out of the ordinary.

            Is it that, the arrows and markers don't show on the chart until the full trade has occurred, so both entry and exit?
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              The issue is this.

              Take one of the trades for example. On the Third bar shown on my screenshot, there is a LE 1 @ 1129.8

              This long entry according to my strategy is a long at the open of the next bar (the fourth bar in the series). The LE market, the sideways triangle and the up arrow should show up on the fourth bar since this trade takes place at the open price of the fourth bar, not the third bar. The only thing that happens on the third bar is the exit on the stop for the previous trade. The strategy does not reenter a trade until the open of the next bar.

              So the price where it is entering the trade is correct, you can see that if you were to move the sideways arrow over to the next bar, it would match up with the open of that bar.

              But why is it plotting on the third bar when the trade is taken at the open of the fourth bar?

              It happens each time on every trade, once a trade exits, it does not enter again until the open of the next bar, but you can see that each bar where there is an exit, the markers plot the entry on the same bar as the exit at or around the open price of the next bar to the right which is where the trade should be shown.

              Comment


                #8
                wcmaria,

                Thank you for the break down.

                What is the syntax you are using to place the exit orders and entry orders?

                Do you see the same behavior if you switched the CalculateOnBarClose set to true?

                You can try using BarsSinceExit() to have the strategy wait a bar or two before placing the long entry order.
                http://www.ninjatrader.com/support/h...ssinceexit.htm
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  I understand your point but the strategy needs to enter again at the open of the next bar after exiting a trade.

                  What I am getting hung up on is that my strategy when trading on MarketReplay is working correctly. It will exit the trade say at the stop loss and will wait until the next bar opens in order to place the trade. It's not placing the trade on the same bar that the previous trade exits.

                  When trading in sim with CalculateOnBarClose set to false let's say I am in a long trade on a 15 minute bar from the open price at 9:15 am. If my stop loss is hit on the next bar say at 9:32 am. The strategy does wait until the open of the 9:45 am bar to place the next trade.

                  The problem is that when this trade closes and the strategy plots the markers, instead of plotting a marker on the 9:45 am bar showing a long entry at the open price, it plots the marker on the 9:30 am bar at the same price level as the open of the 9:45 am bar. The trade time stamp will show the trade happening after 9:45 but the marker will be on the bar that ended at 9:44:59 which is the bar the ends before the trade takes place.

                  Comment


                    #10
                    Another thing I notice which may explain the discrepancy is the timestamp of the trade.

                    All my order to enter at the open of the bar are showing up with a timestamp of say 10:00:00 am or 10:15:00 am.

                    So my question in Ninjatrader, at what time does a new bar begin?

                    Obviously if a new bar begin to print only after 10:00:01 am or 10:15:01 am then that would explain why the markers are plotting on the previous bar because that bar ends at 10:00:00 am or 10:15:00 am.

                    Comment


                      #11
                      wcmaria,

                      Bars within in NinjaTrader are plotted with the next time that the interval is set for.

                      For a 5 minute chart, a 10:00 bar will contain information from 9:55:00 to 9:59:59

                      When 10:00 is reached, then a new bar will form for 10:10 in this case.
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks for that info.

                        So what may cause the marker to plot on the wrong bar?

                        When I look at my trade window my entries which are supposed to occur at the open of a new bar are all time stamped at the correct time of say 10:00:00 or 11:15:00 meaning they are occurring right at the open of a new bar according to your description of what times are contained within a bar.

                        But the marker for the Long Entry is plotting on the bar that ends at 9:59:59 or 11:14:59. Should the time stamp for the trade no match with the bars that are on the chart?

                        Comment


                          #13
                          wcmaria,

                          Can you provide your script, so I can test this on my end?

                          The screenshot you sent in the first post does not show the Entry orders matching the same price with the next bars' open.
                          Cal H.NinjaTrader Customer Service

                          Comment


                            #14
                            Can I send it to you privately?

                            I don't wish to make this strategy public at this time in respect to the trader who designed it.

                            Comment


                              #15
                              Please send me a note to platformsupport [at] ninjatrader [dot] com

                              Put ATTN Cal in the subject and reference this thread in the body
                              Cal H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by yukashg, Yesterday, 09:56 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_ChrisSch  
                              Started by cutzpr, Yesterday, 09:19 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post cutzpr
                              by cutzpr
                               
                              Started by nestorjt23, Yesterday, 08:55 PM
                              3 responses
                              18 views
                              0 likes
                              Last Post NinjaTrader_EricB  
                              Started by 7robert, Yesterday, 08:30 PM
                              1 response
                              11 views
                              0 likes
                              Last Post 7robert
                              by 7robert
                               
                              Started by mav8rick, Yesterday, 07:46 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post mav8rick  
                              Working...
                              X