Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inside 5m Bar

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

    Inside 5m Bar

    One of the strategy that I'm working on may finish inside same 5m candle. Backtest has shown some promising result but I'm not sure about the exact execution logic used in the strategy backtest.

    Say my position was opened at open of that 5m candle but target and stop both are within the range of the candle so how will backtest engine report it? A winner or loser?

    Is there a way to perform this backtest with more confidence? My current data provider is IB and does impose pacing restriction so getting whole length of tick data is virtually impossible :-( Guess I'll need another feed to run this test...
    Last edited by TraderSU; 06-18-2010, 02:19 PM.

    #2
    Hi TraderSU,

    NinjaTrader will take the most conservative approach in this case, "executing" and reporting the Stop Loss.

    I suggest using the Market Replay, which would better simulate live trading.
    More info at - http://www.ninjatrader-support.com/H...tml?Overview14
    TimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Tim View Post
      Hi TraderSU,

      NinjaTrader will take the most conservative approach in this case, "executing" and reporting the Stop Loss.[/url]
      Looks like I found another bug. I took a trade sample and your comment about conservative approach is not looking valid.

      Can you please confirm that 1m candle between 12:16-12:20 makes 12:20 candle on 5m chart.

      Thanks for your response.

      Comment


        #4
        Also how will my LIMIT buy will be handled if BID touches my LIMIT price... In real life I may or may not get the fill.. How will backtest engine handle it?

        Comment


          #5
          Hello,

          Looks like I found another bug. I took a trade sample and your comment about conservative approach is not looking valid.
          >>Can you give us more information? You are using NT6.5?

          Can you please confirm that 1m candle between 12:16-12:20 makes 12:20 candle on 5m chart
          >>I'm sorry, I don't understand. Any ticks that occur during the 5 minute span will constitute the five minute bar. Maybe give us more detail or screen shots of what you mean?

          Also how will my LIMIT buy will be handled if BID touches my LIMIT price... In real life I may or may not get the fill.. How will backtest engine handle it?
          >>For this it will depend on your fill setting: Default or liberal, which is described about half way down on this page:
          DenNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Ben View Post
            Hello,

            Looks like I found another bug. I took a trade sample and your comment about conservative approach is not looking valid.
            >>Can you give us more information? You are using NT6.5?
            NT7 - and it is 100% confirmed. I'm not attaching screen-shot because you won't be able to reproduce it anyway until I give you strategy & settings.

            My limit buy and limit sell falls inside same 5m candle and engine reported it as a WIN :-) When I look at 1m candle that is not correct.

            Should I try NT 6.5? I was also thinking of throwing trade on 1m bar but generate signal from usual 5m bar...

            Comment


              #7
              I tried with NT 6.5 and same issue :-(

              And if approach is conservative then we really don't care how 1m zoom looks. We should never have target fill on the same 5m candle.

              Comment


                #8
                Hello,

                I am sorry you will need to give more details for us to help you.

                As for this statement:

                "We should never have target fill on the same 5m candle."

                Why not? If you were trading live and you placed an order with a target then the price moved to hit that target (and a new bar has not be created yet and it is the "same 5m candle") you should be filled at that target even though the bar is the same bar as your fill bar.

                Or am I not understanding you? It is likely that something is wrong in your strategy logic or I am not explaining the conservative nature of the backtester properly. Please review this link:


                If you are using multiple time frames in you strategy please review this link:
                DenNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Ben View Post
                  "We should never have target fill on the same 5m candle."
                  Ok, let me rephrase it. From a conservative backtesting tool, "we should never have got target-sell fill on the same 5m candle if close < target".

                  Originally posted by NinjaTrader_Ben View Post
                  If you are using multiple time frames in you strategy please review this link:
                  http://www.ninjatrader-support.com/H...ameInstruments
                  I tried to include 2 data series in the strategy

                  1. 5m bar - this is where signal is generated.
                  2. 1m bar - this is where execution happens.

                  Code:
                  		protected override void Initialize()
                  		{
                  
                  			// primary series is 5m
                  			Add(PeriodType.Minute, 1); // BarsArray[1]
                  			// more code
                  
                  		}
                  
                  		protected override void OnBarUpdate()
                  		{
                  			if (BarsInProgress == 0)
                  			{
                  				// this (5m) is called before (1m) bar
                  				// so do calculations, store result in member variable
                  			}
                  			else if (BarsInProgress == 1 && ToTime(Time[0]) % 500 == 0)
                  			{
                  				// guess trade generated using secondary series will 
                  				// execute using secondary bar series.
                  				// but something unexpected is happening here. i get no fill at all.
                   				if (TimeToTrade) 
                  				{
                  					// access stored variables and make trade decisions
                  					// place limit order with attached target-stop OCA
                  				}
                  			}
                  		}
                  Let me try debugging it using visual studio ; but based on my debug statements I'm almost certain that the engine is not following conservative approach.

                  I also made 1m as primary, 5m bar as second and another 1m bar as third series to place order, but similar problem with fill. Same fill is happening without any issue when using only 5m bar series (but target exit is screwed up).

                  Is there a private email where I can send you the screen-shots / details ?
                  Last edited by TraderSU; 06-20-2010, 10:34 AM.

                  Comment


                    #10
                    Hello,

                    Your first statement: However, if the backtest is accurate and price breeched the target price during the candle formation then is should be triggered. The backtest value triggers have been tested by 1000's of users for many years and the current way is the best way of doing it and the way that most backtesters work.

                    Sorry, I hope that helps some. I will have someone help you more on Monday.
                    DenNinjaTrader Customer Service

                    Comment


                      #11
                      Hi TraderSU,

                      Please let me know if you have additional questions.
                      TimNinjaTrader Customer Service

                      Comment


                        #12
                        Please find the attached test strategy that cane be used to re-produce the issue.

                        Just run it against ES (ESU0) 5m data series on "6/18/2010" - regular session.

                        For conservative approach, this trade should exit on sixth candle after the entry but NT backtest engine is marking exit on same candle. BUG BUG BUG ;-)

                        Thanks,
                        Attached Files

                        Comment


                          #13
                          Hi TraderSU,

                          What are you strategy settings? What session template are you using?
                          TimNinjaTrader Customer Service

                          Comment


                            #14
                            Just a comment, looking at your strategy I see you are using a 4 ticks target. That is too small for the smaller timeframe ( 1 Min ) you are using, so it is going to be filled most times in the same bar than entry.
                            You could use a smaller timeframe ( a 4 range bar chart would be ok ) or just set the targets and stops on next bar....
                            pmaglio
                            NinjaTrader Ecosystem Vendor - The Indicator Store

                            Comment


                              #15
                              Originally posted by NinjaTrader_Tim View Post
                              Hi TraderSU,

                              What are you strategy settings? What session template are you using?
                              Does not matter - RTH will work. It's afternoon entry anyway...

                              Just zoom to 1m to see my point but the main point is that the execution is not conservative :-(

                              @pmaglio - yes, that sounds like a good idea but if close > my_target then fill is 100% guaranteed on same bar. Guess I don't want to discard that possibility.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X